Hey guys
Recently I am using CUDA 8 for our project development, I am trying to use C++14 features in our code. However, nvcc seem to behave differently between windows and linux platform. It seems like windows version nvcc support it but linux does not. The beneath is the relevant sample code.
using namespace std;
int main()
{
unique_ptr<int> p1(new int[7]); // C++11
unique_ptr<int> p2 = make_unique<int>(8); //C++14
return 0;
}
For windows, (windows 7, Visual Studio 2015, CUDA 8)
D:\Cuda_test>“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\nvcc.exe” -gencode=arch=compute_20,code="sm_20,compute_20" --use-local-env --cl-version 2015 -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin” -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include" -G --keep-dir Debug -maxrregcount=0 --machine 32 --compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /FS /Zi /RTC1 /MDd " -o Debug\kernel.cu.obj “D:\Cuda_test\kernel.cu”
1>CUDACOMPILE : nvcc warning : The ‘compute_20’, ‘sm_20’, and ‘sm_21’ architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
1> kernel.cu
1> Cuda_test.vcxproj → D:\Cuda_test\Debug\Cuda_test.exe
1> Cuda_test.vcxproj → D:\Cuda_test\Debug\Cuda_test.pdb (Full PDB)
1> copy “C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\cudart*.dll” "D:\Cuda_test\Debug"
1> C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\cudart32_80.dll
1> C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\cudart64_80.dll
1> 2 file(s) copied.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
It compiles.
But on linux, (Ubuntu 16.04, CUDA 8)
george@dx064:~/Work/software_projects/cuda_test$ nvcc --std=c++11 cuda_test_cpp14.cu
nvcc warning : The ‘compute_20’, ‘sm_20’, and ‘sm_21’ architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
cuda_test_cpp14.cu(9): error: identifier “make_unique” is undefined
cuda_test_cpp14.cu(9): error: type name is not allowed
cuda_test_cpp14.cu(9): error: expected an expression
3 errors detected in the compilation of “/tmp/tmpxft_0000634a_00000000-9_cuda_test_cpp14.cpp1.ii”.
george@dx064:~/Work/software_projects/cuda_test$ nvcc --std=c++14 --version
nvcc fatal : Value ‘c++14’ is not defined for option ‘std’
It seems like I can not turn C++14 on or I did it in a wrong way.
So I am just wondering if the cuda 8 linux version support c++ 14 or not.
If anybody knows anything, please just let me know. Thanks a lot.
Best regards
George Liao