1
votes

I have a CUDA (*.cu) code compiled by nvcc, which is working pretty good in GPU. But nvcc doesn't support some c++11 features and some 3rd party c++ library cannot be used with nvcc. I wonder if it is possible to compile the .cu code with gcc or other commercial c++ compiler? Thanks.

1
If those C++11 features occur only in the host portion of your .cu file, I would suggest separating that code out into a separate file that is built directly with the host compiler. You may also want to file a feature request via the registered developer website for the C++11 features you use (C+11 added many diverse features, I assume your code just needs a few of them)njuffa
I think your first comment is what I am looking for. But there is a few lines of code using C++11 which is critical to the rest of the algorithm. It seems that I cannot separate it from the main code :(user1285419
check separate compilation in this.Sagar Masuti

1 Answers

4
votes

nvcc supports explicitly specifying the host compiler it uses, togather with the host-compiler-specific options. You could find the doc on nvcc options -ccbin and -Xcompiler for details.

http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#nvcc-command-options

For example, I bind nvcc with Intel compiler and Intel MKL as follows.

$ nvcc -ftz true -ccbin icpc -Xcompiler "-Wall -Wno-long-long -ansi -pedantic -ansi-alias -parallel -fopenmp -openmp-link=static -static-intel -wd10237" -O2 -Xcompiler "-O2"   -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -Ilib -c -o test/triangle.o test/triangle.cu
$ nvcc -ftz true -ccbin icpc -Xcompiler "-Wall -Wno-long-long -ansi -pedantic -ansi-alias -parallel -fopenmp -openmp-link=static -static-intel -wd10237" -O2 -Xcompiler "-O2"  -Ilib -Llib test/triangle.o lib/KTiming.o -lpthread -lm /opt/intel/composer_xe_2013.1.117/mkl/lib/intel64/libmkl_intel_lp64.a /opt/intel/composer_xe_2013.1.117/mkl/lib/intel64/libmkl_intel_thread.a /opt/intel/composer_xe_2013.1.117/mkl/lib/intel64/libmkl_core.a /opt/intel/composer_xe_2013.1.117/mkl/lib/intel64/libmkl_core.a -lcublas -lcurand -lcusparse -o test/triangle