繁体   English   中英

使用其他C ++编译器来编译CUDA代码

[英]using other c++ compiler to compile the CUDA code

我有一个由nvcc编译的CUDA(* .cu)代码,在GPU中运行良好。 但是nvcc不支持某些c ++ 11功能,某些第三方c ++库不能与nvcc一起使用。 我想知道是否可以使用gcc或其他商用c ++编译器来编译.cu代码? 谢谢。

nvcc支持显式指定其使用的主机编译器,以及特定于主机编译器的选项。 您可以在nvcc选项-ccbin-Xcompiler上找到该文档以获取详细信息。

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

例如,我将nvcc与Intel编译器和Intel MKL绑定如下。

$ 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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM