Compile with GCC and CUDA toolkit OSX

Hello,

I’m trying to compile a software (gromacs-5.0.5) using GCC and CUDA to enable the multithreading with the openmp flag.
I use cmake to configure and I specify:
-DCMAKE_C_COMPILER=gcc
-DCMAKE_CXX_COMPILER=gcc
-DGMX_GPU=on
as indicated in the software installation instructions (http://www.gromacs.org/Documentation/Installation_Instructions_5.0).

It uses the flag as follow :
– Try OpenMP C flag = [-fopenmp]
– Performing Test OpenMP_FLAG_DETECTED
– Performing Test OpenMP_FLAG_DETECTED - Success
– Try OpenMP CXX flag = [-fopenmp]
– Performing Test OpenMP_FLAG_DETECTED
– Performing Test OpenMP_FLAG_DETECTED - Success
– Found OpenMP: -fopenmp
[…]
– Configuring done
– Generating done
– Build files have been written to: /Users/jimi/Desktop/GROMACS/gromacs-5.0.5/build

Everything goes right for the configuration.
Then I run make and it issues the following fatal error :
[ 0%] Building NVCC (Device) object src/gromacs/gmxlib/gpu_utils/CMakeFiles/gpu_utils.dir//./gpu_utils_generated_me mtestG80_core.cu.o
nvcc fatal : GNU C/C++ compiler is no longer supported as a host compiler on Mac OS X.
CMake Error at gpu_utils_generated_memtestG80_core.cu.o.cmake:206 (message):
Error generating
/Users/jimi/Desktop/GROMACS/gromacs-5.0.5/build/src/gromacs/gmxlib/gpu_utils/CM akeFiles/gpu_utils.dir//./gpu_utils_generated_memtestG80_core.cu.o

make[2]: *** [src/gromacs/gmxlib/gpu_utils/CMakeFiles/gpu_utils.dir/./gpu_utils_generated_me mtestG80_core.cu.o] Error 1
make[1]: *** [src/gromacs/gmxlib/gpu_utils/CMakeFiles/gpu_utils.dir/all] Error 2
make: *** [all] Error 2

I’m using the following version of GCC:
gcc --version
gcc (GCC) 4.9.0

nvcc is a part of the CUDA toolkit:
Cuda compilation tools, release 7.0, V7.0.27

about the computer:
MacBook Pro (Retina, 15-inch, Late 2013)
Processor: 2,3 GHz Intel Core i7
Memory: 16 GB 1600 MHz DDR3
GPU: NVIDIA GeForce GT 750M
OS: OS X Yosemite (Version 10.10.3)

I can’t figure out what is the problem. If I don’t specify any special compiler it uses cc and c++ :
– Check for working C compiler: /usr/bin/cc – works
– Check for working CXX compiler: /usr/bin/c++ – works
But it doesn’t support openmp:
– Try OpenMP C flag = [-fopenmp]
– Performing Test OpenMP_FLAG_DETECTED
– Performing Test OpenMP_FLAG_DETECTED - Failed
And it warns:
– Could NOT find OpenMP (missing: OpenMP_C_FLAGS OpenMP_CXX_FLAGS)
CMake Warning at cmake/gmxManageOpenMP.cmake:78 (message):
The compiler you are using does not support OpenMP parallelism. This might
hurt your performance a lot, in particular with GPUs. Try using a more
recent version, or a different compiler. For now, we are proceeding by
turning off OpenMP.

And if I don’t take that into account the installation works and the GPU is supported but it uses only one CPU core.
Any insights would be of great help.

Thank you,
Kind regards

The first error seems clear enough. CUDA 7 no longer supports gcc/g++ on Mac OS X platforms. (ie. only clang is supported):

http://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#unsupported-features

The second error doesn’t seem to have anything to do wtih cuda. It seems your clang installation on Mac OS X doesn’t support OpenMP.

You will probably need to research how to get that working and prove it out with a simple OpenMP code. I don’t believe that has anything to do with CUDA.

The other alternative I can think of would be to downgrade your CUDA version on that machine to a version that supports gcc/g++ on Mac OS X.

I think this is an issue with the CMake module FindCUDA. I can use a hand-written Makefile that first compiles the non-CUDA sources with g+±4.8 or g+±5, then compiles the *.cu files with nvcc, and finally links them with gcc. However, when I go the CMake + FindCUDA route, it tries to make nvcc compile the *.cu files first and throws this error:

[  4%] Building NVCC (Device) object CMakeFiles/<my project>.dir/src/<my project>_generated_<my *.cu file>

Then it fails, after saying “Generating dependency file,” throwing the “nvcc fatal : GNU C/C++ compiler is no longer supported as a host compiler on Mac OS X” message.

I need to use GCC because Apple’s Clang doesn’t support thread-local storage.

Manually removing “-ccbin /usr/local/bin/gcc-5” that CMake automatically passes to nvcc solves the problem, however.

Is there a way to tell CMake not to pass this to nvcc?