NVIDIA / stdexec

`std::execution`, the proposed C++ framework for asynchronous and parallel programming.
Apache License 2.0
1.56k stars 159 forks source link

compilation error using gcc+cuda #996

Closed weilewei closed 1 year ago

weilewei commented 1 year ago

Dear stdexec developers,

I am trying to compile stdexec library with gcc and enable STDEXEC_ENABLE_CUDA and encounter the following errors. I tried two different versions of gcc (12 and 10):

  1. When building the library using gcc 12.2.0, CMake stage is successful, but the build stage (during the nvexec part) gave me error about cuda and gcc compatibility error
    # cmake
    wwei@login24:~/src/stdexec/build_gcc12> CC=$(which cc) CXX=$(which CC) cmake .. -DCMAKE_CUDA_COMPILER=/opt/nvidia/hpc_sdk/Linux_x86_64/23.1/cuda/12.0/bin/nvcc -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_STANDARD=20 -DCMAKE_CUDA_STANDARD=20 -DCMAKE_CUDA_COMPILE_FEATURES=cuda_std_20 -DSTDEXEC_ENABLE_CUDA=ON -DCMAKE_CXX_FLAGS="-std=c++20"
    -- The CXX compiler identification is GNU 12.2.0
    -- Cray Programming Environment 2.7.20 CXX
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: /opt/cray/pe/craype/2.7.20/bin/CC - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- System           : Linux-5.14.21-150400.24.46_12.0.73-cray_shasta_c
    -- System name      : Linux
    -- System ver       : 5.14.21-150400.24.46_12.0.73-cray_shasta_c
    -- 
    -- Library ver      : 0.8.0
    -- Build date       : 2023-07-11
    -- Build year       : 2023
    -- 
    -- CPM: adding package Catch2@2.13.6 (2.13.6)
    -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
    -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
    -- Found Threads: TRUE  
    -- The CUDA compiler identification is NVIDIA 12.0.76
    -- Detecting CUDA compiler ABI info
    -- Detecting CUDA compiler ABI info - done
    -- Check for working CUDA compiler: /opt/nvidia/hpc_sdk/Linux_x86_64/23.1/cuda/12.0/bin/nvcc - skipped
    -- Detecting CUDA compile features
    -- Detecting CUDA compile features - done
    -- Unable to find cublas_v2.h in either "/opt/nvidia/hpc_sdk/Linux_x86_64/23.1/cuda/12.0/include" or "/opt/nvidia/hpc_sdk/Linux_x86_64/23.1/math_libs/include"
    -- Found CUDAToolkit: /opt/nvidia/hpc_sdk/Linux_x86_64/23.1/cuda/12.0/include (found version "12.0.76") 
    -- CPM: adding package libcudacxx@1.9.0 (1.9.0)
    -- Found libcudacxx: /global/homes/w/wwei/src/stdexec/build_gcc12/_deps/libcudacxx-src/lib/cmake/libcudacxx/libcudacxx-config.cmake (found version "1.9.0.0") 
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /global/homes/w/wwei/src/stdexec/build_gcc12

    error:

    ...
    [ 57%] Building CUDA object test/nvexec/CMakeFiles/test.nvexec.dir/ensure_started.cpp.o
    In file included from /opt/nvidia/hpc_sdk/Linux_x86_64/22.7/cuda/11.7/include/cuda_runtime.h:83,
                 from <command-line>:
    /opt/nvidia/hpc_sdk/Linux_x86_64/22.7/cuda/11.7/include/crt/host_config.h:132:2: error: #error -- unsupported GNU version! gcc versions later than 11 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
    132 | #error -- unsupported GNU version! gcc versions later than 11 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
      |  ^~~~~
    In file included from /global/homes/w/wwei/src/stdexec/include/stdexec/__detail/__execution_fwd.hpp:18,
                 from /global/homes/w/wwei/src/stdexec/include/stdexec/execution.hpp:31,
                 from /global/homes/w/wwei/src/stdexec/test/nvexec/ensure_started.cpp:3:
    /global/homes/w/wwei/src/stdexec/include/stdexec/__detail/__config.hpp:19:2: error: #error This library requires the use of C++20.
    19 | #error This library requires the use of C++20.
      |  ^~~~~
    In file included from /global/homes/w/wwei/src/stdexec/include/stdexec/__detail/__intrusive_ptr.hpp:19,
                 from /global/homes/w/wwei/src/stdexec/include/stdexec/execution.hpp:32:
    /global/homes/w/wwei/src/stdexec/include/stdexec/__detail/../concepts.hpp:19:2: error: #error This library requires support for C++20 concepts
    19 | #error This library requires support for C++20 concepts
      |  ^~~~~
    make[2]: *** [test/nvexec/CMakeFiles/test.nvexec.dir/build.make:76: test/nvexec/CMakeFiles/test.nvexec.dir/ensure_started.cpp.o] Error 1
    make[1]: *** [CMakeFiles/Makefile2:1048: test/nvexec/CMakeFiles/test.nvexec.dir/all] Error 2
    make: *** [Makefile:166: all] Error 2

However, using -allow-unsupported-compiler gave me more errors.

  1. Then I switch to gcc 10.3.0, and it complains c++20 standard error:
    
    wwei@login24:~/src/stdexec/build_gcc10> ml gcc/10

The following have been reloaded with a version change: 1) gcc/12.2.0 => gcc/10.3.0

wwei@login24:~/src/stdexec/build_gcc10> CC=$(which cc) CXX=$(which CC) cmake .. -DCMAKE_CUDA_COMPILER=/opt/nvidia/hpc_sdk/Linux_x86_64/23.1/cuda/12.0/bin/nvcc -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_STANDARD=20 -DCMAKE_CUDA_STANDARD=20 -DCMAKE_CUDA_COMPILE_FEATURES=cuda_std_20 -DSTDEXEC_ENABLE_CUDA=ON -DCMAKE_CXX_FLAGS="-std=c++20"^C

wwei@login24:~/src/stdexec/build_gcc10> CXX=$(which CC) cmake .. -DCMAKE_CUDA_COMPILER=/opt/nvidia/hpc_sdk/Linux_x86_64/22.7/cuda/11.7/bin/nvcc -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_STANDARD=20 -DCMAKE_CUDA_STANDARD=20 -DCMAKE_CUDA_COMPILE_FEATURES=cuda_std_20 -DSTDEXEC_ENABLE_CUDA=ON -DCMAKE_CXX_FLAGS="-std=c++20" -- The CXX compiler identification is GNU 10.3.0 -- Cray Programming Environment 2.7.20 CXX -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /opt/cray/pe/craype/2.7.20/bin/CC - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- System : Linux-5.14.21-150400.24.46_12.0.73-cray_shasta_c -- System name : Linux -- System ver : 5.14.21-150400.24.46_12.0.73-cray_shasta_c -- -- Library ver : 0.8.0 -- Build date : 2023-07-11 -- Build year : 2023 -- -- CPM: adding package Catch2@2.13.6 (2.13.6) -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE
-- The CUDA compiler identification is NVIDIA 11.7.64 -- Detecting CUDA compiler ABI info -- Detecting CUDA compiler ABI info - done -- Check for working CUDA compiler: /opt/nvidia/hpc_sdk/Linux_x86_64/22.7/cuda/11.7/bin/nvcc - skipped -- Detecting CUDA compile features -- Detecting CUDA compile features - done -- Found CUDAToolkit: /opt/nvidia/hpc_sdk/Linux_x86_64/22.7/cuda/11.7/include (found version "11.7.64") -- CPM: adding package libcudacxx@1.9.0 (1.9.0) -- Found libcudacxx: /global/homes/w/wwei/src/stdexec/build_gcc10/_deps/libcudacxx-src/lib/cmake/libcudacxx/libcudacxx-config.cmake (found version "1.9.0.0") -- Configuring done -- Generating done -- Build files have been written to: /global/homes/w/wwei/src/stdexec/build_gcc10

wwei@login24:~/src/stdexec/build_gcc10> make [ 0%] Built target nvexec [ 1%] Building CXX object test/CMakeFiles/test.stdexec.dir/test_main.cpp.o [ 2%] Building CXX object test/CMakeFiles/test.stdexec.dir/stdexec/cpos/test_cpo_bulk.cpp.o In file included from /global/homes/w/wwei/src/stdexec/include/stdexec/detail/execution_fwd.hpp:18, from /global/homes/w/wwei/src/stdexec/include/stdexec/execution.hpp:31, from /global/homes/w/wwei/src/stdexec/test/stdexec/cpos/cpo_helpers.cuh:17, from /global/homes/w/wwei/src/stdexec/test/stdexec/cpos/test_cpo_bulk.cpp:17: /global/homes/w/wwei/src/stdexec/include/stdexec/detail/config.hpp:19:2: error: #error This library requires the use of C++20. 19 | #error This library requires the use of C++20. | ^~~~~ make[2]: [test/CMakeFiles/test.stdexec.dir/build.make:90: test/CMakeFiles/test.stdexec.dir/stdexec/cpos/test_cpo_bulk.cpp.o] Error 1 make[1]: [CMakeFiles/Makefile2:1022: test/CMakeFiles/test.stdexec.dir/all] Error 2 make: *** [Makefile:166: all] Error 2 wwei@login24:~/src/stdexec/build_gcc10> which gcc /opt/cray/pe/gcc/10.3.0/bin/gcc

jrhemstad commented 1 year ago

Howdy @weilewei, this is because GPU support requires the use of nvc++. nvcc is a different compiler and is not currently supported.

See https://github.com/NVIDIA/stdexec#gpu-support

weilewei commented 1 year ago

@jrhemstad Oh, true, thanks for the explanation!