enable_language(CUDA) fails with Intel icpc set as host compiler
Hi,
I am having a problem configuring a CUDA project which uses Intel compiler (icpc) as the cuda host compiler.
Here is a minimal CMakeLists.txt that produces the error:
cmake_minimum_required(VERSION 3.18)
project(my_test)
set(CMAKE_CUDA_HOST_COMPILER icpc)
enable_language(CUDA)
add_executable(my_program src.cu)
src.cu
is a simple hello world program:
#include <cstdio>
__global__ void hello()
{
printf("Hello %d %d\n", threadIdx.x, blockIdx.x);
}
int main()
{
hello<<<2,4>>>();
cudaDeviceSynchronize();
return 0;
}
The error produced:
CMake Error at /apps/all/CMake/3.23.1-GCCcore-11.3.0/share/cmake-3.23/Modules/CMakeDetermineCompilerId.cmake:743 (message):
Compiling the CUDA compiler identification source file
"CMakeCUDACompilerId.cu" failed.
Compiler: /apps/all/CUDA/11.4.1/bin/nvcc
Build flags:
Id flags: --keep;--keep-dir;tmp;-ccbin=icpc -v
The output was:
1
#$ _NVVM_BRANCH_=nvvm
#$ _SPACE_=
#$ _CUDART_=cudart
#$ _HERE_=/apps/all/CUDA/11.4.1/bin
#$ _THERE_=/apps/all/CUDA/11.4.1/bin
#$ _TARGET_SIZE_=
#$ _TARGET_DIR_=
#$ _TARGET_DIR_=targets/x86_64-linux
#$ TOP=/apps/all/CUDA/11.4.1/bin/..
#$ NVVMIR_LIBRARY_DIR=/apps/all/CUDA/11.4.1/bin/../nvvm/libdevice
#$
LD_LIBRARY_PATH=/apps/all/CUDA/11.4.1/bin/../lib:/apps/all/CUDA/11.4.1/nvvm/lib64:/apps/all/CUDA/11.4.1/extras/CUPTI/lib64:/apps/all/CUDA/11.4.1/lib:/apps/all/imkl-FFTW/2022.1.0-iimpi-2022a/lib:/apps/all/imkl/2022.1.0/mkl/2022.1.0/lib/intel64:/apps/all/imkl/2022.1.0/compiler/2022.1.0/linux/compiler/lib/intel64_lin:/apps/all/impi/2021.6.0-intel-compilers-2022.1.0/mpi/2021.6.0/libfabric/lib:/apps/all/impi/2021.6.0-intel-compilers-2022.1.0/mpi/2021.6.0/lib/release:/apps/all/impi/2021.6.0-intel-compilers-2022.1.0/mpi/2021.6.0/lib:/apps/all/UCX/1.12.1-GCCcore-11.3.0/lib:/apps/all/numactl/2.0.14-GCCcore-11.3.0/lib:/apps/all/intel-compilers/2022.1.0/tbb/2021.6.0/lib/intel64/gcc4.8:/apps/all/intel-compilers/2022.1.0/compiler/2022.1.0/linux/compiler/lib/intel64_lin:/apps/all/intel-compilers/2022.1.0/compiler/2022.1.0/linux/lib/x64:/apps/all/intel-compilers/2022.1.0/compiler/2022.1.0/linux/lib:/apps/all/binutils/2.38-GCCcore-11.3.0/lib:/apps/all/libarchive/3.6.1-GCCcore-11.3.0/lib:/apps/all/XZ/5.2.5-GCCcore-11.3.0/lib:/apps/all/cURL/7.83.0-GCCcore-11.3.0/lib:/apps/all/OpenSSL/1.1/lib:/apps/all/bzip2/1.0.8-GCCcore-11.3.0/lib:/apps/all/zlib/1.2.12-GCCcore-11.3.0/lib:/apps/all/ncurses/6.3-GCCcore-11.3.0/lib:/apps/all/GCCcore/11.3.0/lib64:/home/hom0056/apps/hipBLAS/installation/lib:/home/hom0056/apps/rocRAND/installation/hiprand/lib
#$
PATH=/apps/all/CUDA/11.4.1/bin/../nvvm/bin:/apps/all/CUDA/11.4.1/bin:/apps/all/CUDA/11.4.1/nvvm/bin:/apps/all/CUDA/11.4.1/bin:/apps/all/impi/2021.6.0-intel-compilers-2022.1.0/mpi/2021.6.0/libfabric/bin:/apps/all/impi/2021.6.0-intel-compilers-2022.1.0/mpi/2021.6.0/bin:/apps/all/UCX/1.12.1-GCCcore-11.3.0/bin:/apps/all/numactl/2.0.14-GCCcore-11.3.0/bin:/apps/all/intel-compilers/2022.1.0/compiler/2022.1.0/linux/bin/intel64:/apps/all/intel-compilers/2022.1.0/compiler/2022.1.0/linux/bin:/apps/all/binutils/2.38-GCCcore-11.3.0/bin:/apps/all/CMake/3.23.1-GCCcore-11.3.0/bin:/apps/all/libarchive/3.6.1-GCCcore-11.3.0/bin:/apps/all/XZ/5.2.5-GCCcore-11.3.0/bin:/apps/all/cURL/7.83.0-GCCcore-11.3.0/bin:/apps/all/OpenSSL/1.1/bin:/apps/all/bzip2/1.0.8-GCCcore-11.3.0/bin:/apps/all/ncurses/6.3-GCCcore-11.3.0/bin:/apps/all/GCCcore/11.3.0/bin:/home/hom0056/apps/HIP/installation/bin:/opt/clmgr/sbin:/opt/clmgr/bin:/opt/sgi/sbin:/opt/sgi/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/c3/bin:/opt/pbs/bin:/sbin:/bin
#$ INCLUDES="-I/apps/all/CUDA/11.4.1/bin/../targets/x86_64-linux/include"
#$ LIBRARIES=
"-L/apps/all/CUDA/11.4.1/bin/../targets/x86_64-linux/lib/stubs"
"-L/apps/all/CUDA/11.4.1/bin/../targets/x86_64-linux/lib"
#$ CUDAFE_FLAGS=
#$ PTXAS_FLAGS=
#$ rm tmp/a_dlink.reg.c
#$ icpc -D__CUDA_ARCH__=520 -E -x c++ -DCUDA_DOUBLE_MATH_FUNCTIONS
-D__CUDACC__ -D__NVCC__ -D__INTEL_COMPILER_USE_INTRINSIC_PROTOTYPES
"-I/apps/all/CUDA/11.4.1/bin/../targets/x86_64-linux/include"
-D__CUDACC_VER_MAJOR__=11 -D__CUDACC_VER_MINOR__=4
-D__CUDACC_VER_BUILD__=100 -D__CUDA_API_VER_MAJOR__=11
-D__CUDA_API_VER_MINOR__=4 -include "cuda_runtime.h" -m64
"CMakeCUDACompilerId.cu" -o "tmp/CMakeCUDACompilerId.cpp1.ii"
#$ cicc --c++14 --icc --gnu_version=110300 --icc_version=2021
--orig_src_file_name "CMakeCUDACompilerId.cu" --allow_managed -arch
compute_52 -m64 --no-version-ident -ftz=0 -prec_div=1 -prec_sqrt=1 -fmad=1
--include_file_name "CMakeCUDACompilerId.fatbin.c" -tused
--gen_module_id_file --module_id_file_name
"tmp/CMakeCUDACompilerId.module_id" --gen_c_file_name
"tmp/CMakeCUDACompilerId.cudafe1.c" --stub_file_name
"tmp/CMakeCUDACompilerId.cudafe1.stub.c" --gen_device_file_name
"tmp/CMakeCUDACompilerId.cudafe1.gpu" "tmp/CMakeCUDACompilerId.cpp1.ii" -o
"tmp/CMakeCUDACompilerId.ptx"
/apps/all/GCCcore/11.3.0/include/c++/11.3.0/bits/stl_pair.h(460): error:
argument list for class template "std::pair" is missing
/apps/all/GCCcore/11.3.0/include/c++/11.3.0/bits/stl_pair.h(460): error:
expected a ")"
/apps/all/GCCcore/11.3.0/include/c++/11.3.0/bits/stl_pair.h(460): error:
template parameter "_T1" may not be redeclared in this scope
/apps/all/GCCcore/11.3.0/include/c++/11.3.0/bits/stl_pair.h(460): error:
expected a ";"
4 errors detected in the compilation of "CMakeCUDACompilerId.cu".
# --error 0x1 --
Call Stack (most recent call first):
/apps/all/CMake/3.23.1-GCCcore-11.3.0/share/cmake-3.23/Modules/CMakeDetermineCompilerId.cmake:6 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
/apps/all/CMake/3.23.1-GCCcore-11.3.0/share/cmake-3.23/Modules/CMakeDetermineCompilerId.cmake:48 (__determine_compiler_id_test)
/apps/all/CMake/3.23.1-GCCcore-11.3.0/share/cmake-3.23/Modules/CMakeDetermineCUDACompiler.cmake:339 (CMAKE_DETERMINE_COMPILER_ID)
CMakeLists.txt:9 (enable_language)
It fais on the enable_language(CUDA)
line, where it tries to determine the compiler ID, but fails. It seems that the problem is that only c++14 is passed to cicc (when I try to manually run the command, but with c++17, it works). If I do not set the cuda host compiler, c++17 option is used and everything works correctly. I have no idea what to do about it, I tried setting CMAKE_CUDA_STANDARD
, CMAKE_CXX_STANDARD
to 17, but nothing changed.
I a using CMake 3.23.1 (tried with some older versions and the problem persists), Intel 2021.6.0.20220226 (problem persists with other versions), CUDA 11.4.1.
I would appreciate any help with this.