Hi Durga,

Sorry for the late reply and thanks for reporting that issue. As Rayson mentioned, CUDA is intrinsically C++ and indeed uses the host C++ compiler. Hence linking MPI + CUDA code may need to use mpic++.

It happens to work with mpicc on various platforms where the libstdc++ is linked anyway but in your case it wasn't. We fixed the Makefile on github to use mpic++ as linker.

Sylvain

On 03/20/2016 07:37 PM, dpchoudh . wrote:
I'd tend to agree with Gilles. I have written CUDA programs in pure C (i.e. neither involving MPI nor C++) and a pure C based tool chain builds the code successfully. So I don't see why CUDA should be intrinsically C++.

From the Makefile (that I had attached in my previous mail) the only CUDA library being linked against is this:

/usr/local/cuda/lib64/libcudart.so
and ldd on that shows this:

[durga@smallMPI lib64]$ ldd libcudart.so
    linux-vdso.so.1 =>  (0x00007ffe1e7f1000)
    libc.so.6 => /lib64/libc.so.6 (0x00007ff7e4493000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007ff7e428f000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ff7e4072000)
    librt.so.1 => /lib64/librt.so.1 (0x00007ff7e3e6a000)
    /lib64/ld-linux-x86-64.so.2 (0x00007ff7e4af3000)

I don't see any C++ dependency here either.

And finally, I don't think there is any version issue. This is a clean CUDA 7.5 install directly from NVIDIA CUDA repo (for Redhat) and all provided examples run fine with this installation.

I believe there are NVIDIA employees in this list; hopefully one of them will clarify.

Thanks
Durga

Life is complex. It has real and imaginary parts.

On Sun, Mar 20, 2016 at 10:23 PM, Gilles Gouaillardet <gilles.gouaillar...@gmail.com <mailto:gilles.gouaillar...@gmail.com>> wrote:

    I am a bit puzzled...

    if only cuda uses the c++ std libraries, then it should depend on them
    (ldd libcudaxyz.so can be used to confirm that)
    and then linking with cuda lib should pull the c++ libs

    could there be a version issue ?
    e.g. the missing symbol is not provided by the version of the c++
    lib that is pulled.
    that might occur if you are using cuda built for distro X on distro Y

    could you please double check this ?
    if everything should work, then i recommend you report this to nvidia

    Cheers,

    Gilles

    On Monday, March 21, 2016, Damien Hocking <dam...@0x544745.com
    <mailto:dam...@0x544745.com>> wrote:

        Durga,

        The Cuda libraries use the C++ std libraries.  That's the
        std::ios_base errors.. You need the C++ linker to bring those in.

        Damien

        On March 20, 2016 9:15:47 AM "dpchoudh ." <dpcho...@gmail.com>
        wrote:

        Hello all

        I downloaded some code samples from here:

        https://github.com/parallel-forall/code-samples/

        and tried to build the subdirectory

        posts/cuda-aware-mpi-example/src

        in my CentOS 7 machine.

        I had to make several changes to the Makefile before it would
        build. The modified Makefile is attached (the make targets I
        am talking about are the 3rd and 4th from the bottom). Most
        of the modifications can be explained as possible platform
        specific variations (such as path differences betwen Ubuntu
        and CentOS), except the following:

        I had to use a C++ linker (mpic++) to link in the object
        files that were produced with C host compiler (mpicc) and
        CUDA compiler (nvcc). If I did not do this, (i.e. I stuck to
        mpicc for linking), I got the following link error:

        mpicc -L/usr/local/cuda/lib64 -lcudart -lm -o
        ../bin/jacobi_cuda_normal_mpi jacobi.o input.o host.o
        device.o  cuda_normal_mpi.o
        device.o: In function
        `__static_initialization_and_destruction_0(int, int)':
        tmpxft_00004651_00000000-4_Device.cudafe1.cpp:(.text+0xd1e):
        undefined reference to `std::ios_base::Init::Init()'
        tmpxft_00004651_00000000-4_Device.cudafe1.cpp:(.text+0xd2d):
        undefined reference to `std::ios_base::Init::~Init()'
        collect2: error: ld returned 1 exit status

        Can someone please explain why would I need a C++ linker for
        object files that were generated using C compiler? Note that
        if I use mpic++ both for compiling and linking, there are no
        errors either.

        Thanks in advance
        Durga

        Life is complex. It has real and imaginary parts.
        _______________________________________________
        users mailing list
        us...@open-mpi.org
        Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users
        Link to this post:
        http://www.open-mpi.org/community/lists/users/2016/03/28760.php


    _______________________________________________
    users mailing list
    us...@open-mpi.org <mailto:us...@open-mpi.org>
    Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users
    Link to this post:
    http://www.open-mpi.org/community/lists/users/2016/03/28762.php




_______________________________________________
users mailing list
us...@open-mpi.org
Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users
Link to this post: 
http://www.open-mpi.org/community/lists/users/2016/03/28764.php


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

Reply via email to