Intel icc compiler and c++11

CUDA (versions 7.5 and 8.0) on Linux does not seem to be able to compile c++11 code when using the Intel icc compiler. In particular, if nvcc is run with the flags ‘-ccbin /opt/intel/compilers_and_libraries_2016.3.210/linux/bin/intel64/icc’ and ‘–std c++11’, then the following error message results:

nvcc warning : The -std=c++11 flag is not supported with the configured host compiler. Flag will be ignored.

This is peculiar, because:

(1) This works fine with g++ (4.8.5)

(2) icc does actually support the -std=c++11 flag (versions 15 and 16).

Any suggestions?

I think the nvcc warning is probably legitimate. Rightly or wrongly, the attitude of the CUDA dev team is to wall off functionality that has not been explicitly tested or QA’d. It’s possible that the combination of c++11 with ICC (supported) and CUDA (unsupported with ICC) may work but was simply untested. Or its possible that the dev team found an issue and walled it off for that reason.

The usual suggestion in these cases is to put the incompatible code (ICC/C++11) in a separate module that does not need to be compiled by nvcc (i.e. contains no CUDA device code. Usually CUDA runtime API functions can still be in such modules). Use (probably non-C++11-dependent) wrapper functions or whatever methodology you wish to link the functionality in that module with the modules that contain your CUDA device code, which will be compiled by nvcc. In these cases, configure nvcc to use the g++ host compiler if you still want to use c++11 features in those modules, otherwise you can use the ICC host compiler for those modules. I assume that there is a compatible link strategy between ICC and g++ but I don’t happen to know that.

You can also file a bug (RFE - Request for Enhancement) to request that support for this combo be added. I would encourage this as well.

Thanks for the response. There are certainly ways to work around this, but it would be nice to see it just work without extra steps. I will file an RFE.

To avoid all this, I compile my device code into libraries with nvcc/gcc and link against them with the Intel compiler. CMake does it all for me (CUDA_ADD_LIBRARY function).

Actually, I just tried this with CUDA 8.0RC, it seems to work for me:

$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Wed_May__4_21:01:56_CDT_2016
Cuda compilation tools, release 8.0, V8.0.26
$ nvcc -ccbin=/cm/shared/apps/intel/compilers_and_libraries_2016.3.210/linux/bin/intel64/icc -std=c++11 -o t912 t912.cu
$

(Perhaps you were using CUDA 8.0EA, support was not added in CUDA 8.0EA but was added in 8.0RC)
I agree it’s not supported in CUDA 7.5