Combining MPI with C ++ 11 and CUDA

I am writing a molecular dynamics simulation, and some cores will be computed using CUDA. I started my code with a simple CPU implementation using some C ++ 11 features. Now that I need to add the CUDA code, I have to use compilers that do not support C ++ 11 functions (gcc <= 4.6).

In my makefile, I create objects from all cpp files separately and linking them all together at the end. In addition, my code breaks in such a way that it would be possible to compile parts without CUDA using the β€œmodern” compiler, and the rest (using CUDA) with the old compiler.

Now my question is: if this is normal or would I encounter such problems?

+4
source share
1 answer

I don’t know about Kuda, but I know that linking C ++ 98 and C ++ 11 object files is very dangerous, because template instances are allocated only once in the final executable. The fact is that ABI can change.

I ran into this problem with std::complex<double>::real() and g ++. One of the two instances returned a pointer to double , the other - double . The linker emitted only one of two instances (the one that immediately returned) to the final executable file, and the calling C ++ 98 code subsequently mistakenly accepted duplicates as pointers, which led to segfault.

For what it happened, just look at <complex> : Depending on the type __cplusplus >= 201103L or not, real() declared like this:

 constexpr _Tp real(); 

or as follows:

 const _Tp& real() const { return _M_real; } 

I doubt there are more examples than just std::complex .

+1
source

All Articles