Tags

, ,

I recently began playing with CUDA on my MacBook and ran into a wall when it came to mixing CUDA and C++ 11. (See code here.)

The basic issue is that CUDA requires g++ on Mountain Lion, but the version of g++ that ships with Mountain Lion does not have C++ 11 support. Only clang++ provides C++ 11 support on Mountain Lion.

Luckily clang++ and g++ have some ABI compatibility, though not necessarily when it comes to the standard library.

So the work around to get CUDA and C++ 11 to coexist is to compile CUDA device code with g++ and host code with clang++. Now, obviously one should question the robustness of this solution, but it is a path forward and that’s better than nothing.

Meanwhile we can hope that either CUDA will come to work with clang++ or Apple will ship a version of g++ that includes support for C++ 11. I’m counting on the NVIDIA and clang developers to pull through on this one.

A simple example of the technique outlined above can be found here.

Advertisements