Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to C++17 #1466

Merged
merged 1 commit into from
Nov 19, 2021
Merged

Switch to C++17 #1466

merged 1 commit into from
Nov 19, 2021

Conversation

bernhardmgruber
Copy link
Member

@bernhardmgruber bernhardmgruber commented Nov 15, 2021

This PR switches to C++17, including:

  • Require C++17 in CMake
  • Remove nvcc version below 11 from GitHub CI
  • Remove CUDA SDK installer below 9.2 from install scripts
  • Update supported CUDA versions in README.md
  • Eliminate obsolete C++ version checks
  • Remove support for nvcc + clang-5
  • Update documentation
  • Fix warnings
  • Merge GitLab CI CUDA job description files
  • Add more GitLab CI tests with clang as CUDA compiler: clang-11/cuda11.0, clang-12/cuda11.0
  • Add GitHub CI test with clang-12 + nvcc 11.4
  • support passing CMAKE_CUDA_FLAGS variable through CI

@bernhardmgruber bernhardmgruber linked an issue Nov 15, 2021 that may be closed by this pull request
@j-stephan j-stephan added this to the Version 0.9.0 (I/2022) milestone Nov 15, 2021
Copy link
Member

@j-stephan j-stephan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! A few remarks:

cmake/alpakaCommon.cmake Outdated Show resolved Hide resolved
.github/workflows/ci.yml Show resolved Hide resolved
.github/workflows/ci.yml Show resolved Hide resolved
@bernhardmgruber bernhardmgruber force-pushed the cpp17 branch 2 times, most recently from 5618594 to cde7240 Compare November 15, 2021 13:01
@bernhardmgruber
Copy link
Member Author

It looks like we are going to need to drop clang-5 as well:

cd /home/runner/work/alpaka/alpaka/build/example/bufferCopy && /usr/local/cuda-11.0/bin/nvcc -forward-unknown-to-host-compiler -ccbin=/usr/bin/clang++ -DALPAKA_ACC_CPU_B_OMP2_T_SEQ_ENABLED -DALPAKA_ACC_CPU_B_SEQ_T_OMP2_ENABLED -DALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED -DALPAKA_ACC_CPU_B_SEQ_T_THREADS_ENABLED -DALPAKA_ACC_CPU_B_TBB_T_SEQ_ENABLED -DALPAKA_ACC_GPU_CUDA_ENABLED -DALPAKA_BLOCK_SHARED_DYN_MEMBER_ALLOC_KIB=47 -DALPAKA_CI -DALPAKA_DEBUG=0 -DALPAKA_DEBUG_OFFLOAD_ASSUME_HOST -DALPAKA_OFFLOAD_MAX_BLOCK_SIZE=256 -I/home/runner/work/alpaka/alpaka/include -isystem=/usr/local/cuda-11.0/targets/x86_64-linux/include -isystem=/home/runner/work/alpaka/alpaka/boost -isystem=/usr/local/cuda-11.0/include -g --generate-code=arch=compute_80,code=[compute_80,sm_80] --extended-lambda --expt-relaxed-constexpr -g -lineinfo -Xcompiler=-fopenmp -Xcudafe=--display_error_number -Xcudafe=--diag_suppress=esa_on_defaulted_function_ignored -Xcompiler -pthread -std=c++17 -MD -MT example/bufferCopy/CMakeFiles/bufferCopy.dir/src/bufferCopy.cpp.o -MF CMakeFiles/bufferCopy.dir/src/bufferCopy.cpp.o.d -x cu -c /home/runner/work/alpaka/alpaka/example/bufferCopy/src/bufferCopy.cpp -o CMakeFiles/bufferCopy.dir/src/bufferCopy.cpp.o
nvcc warning : The -std=c++17 flag is not supported with the configured host compiler. Flag will be ignored.
In file included from /home/runner/work/alpaka/alpaka/example/bufferCopy/src/bufferCopy.cpp:18:
In file included from /home/runner/work/alpaka/alpaka/include/alpaka/alpaka.hpp:18:
In file included from /home/runner/work/alpaka/alpaka/include/alpaka/acc/AccCpuOmp2Blocks.hpp:19:
In file included from /home/runner/work/alpaka/alpaka/include/alpaka/atomic/AtomicHierarchy.hpp:12:
In file included from /home/runner/work/alpaka/alpaka/include/alpaka/atomic/Traits.hpp:14:
In file included from /home/runner/work/alpaka/alpaka/include/alpaka/core/Concepts.hpp:12:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/type_traits:35:
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/c++0x_warning.h:32:2: error: This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \

@j-stephan
Copy link
Member

Weird, looks like nvcc doesn't know that clang 5 has C++17 support. Maybe we can add a -Xcompiler -std=c++17 here.

@bernhardmgruber
Copy link
Member Author

Weird, looks like nvcc doesn't know that clang 5 has C++17 support. Maybe we can add a -Xcompiler -std=c++17 here.

We could. clang 5 should support it. But then there is no official way to query what host compiler is used via cmake. See also: https://gitlab.kitware.com/cmake/cmake/-/issues/20901.

@psychocoderHPC
Copy link
Member

IMO clang5 should be dropped instead of adding workarounds.

@j-stephan
Copy link
Member

IMO clang5 should be dropped instead of adding workarounds.

Should we keep it as a normal C++ compiler and just disable it for CUDA?

@j-stephan
Copy link
Member

@bernhardmgruber Please also remember to update the support matrix in README.md.

@bernhardmgruber
Copy link
Member Author

@bernhardmgruber Please also remember to update the support matrix in README.md.

Did I update the support matrix incorrectly?

@j-stephan
Copy link
Member

Ah, no, you didn't. I just somehow skipped over it during my last review. My bad.

j-stephan
j-stephan previously approved these changes Nov 15, 2021
@bernhardmgruber
Copy link
Member Author

Switching to C++17 does not fix compilation with nvcc 11.0/11.1 and MSVC. It seems we can therefore not fix #1331 with this PR.

@j-stephan
Copy link
Member

The issue is different, though. The last time it complained about missing ( everywhere, now it is some template instantiation error. So I guess #1331 is technically fixed.

@j-stephan
Copy link
Member

I'm happy to ditch CUDA 11.0 and 11.1, though. @psychocoderHPC, what do you think?

@psychocoderHPC
Copy link
Member

I'm happy to ditch CUDA 11.0 and 11.1, though

Removing the support for CUDA 11.0/11.1 on Windows is IMO no problem.
For linux I would not remove these versions!

@j-stephan
Copy link
Member

The first few lines of README.md (language badge and introductory text) also still refer to C++14.

@bernhardmgruber
Copy link
Member Author

During the alpaka VC we decided to not add nvcc 11.0/11.1 + MSVC support again and also drop support for nvcc with clang-5 as host compiler (clang-5 stays supported without nvcc).

@bernhardmgruber bernhardmgruber changed the title Switch to C++17 Switch to C++17 and CUDA 11+ Nov 17, 2021
@bernhardmgruber
Copy link
Member Author

It seems that with a minimum CUDA SDK of 11.0, we can no longer use clang < 12 as CUDA compiler.

I tried several workarounds locally suggested by @psychocoderHPC, passing --no-cuda-version-check and --cuda-gpu-arch=sm_50 via CMAKE_CUDA_FLAGS without success.

@bernhardmgruber
Copy link
Member Author

bernhardmgruber commented Nov 18, 2021

I can reproduce the issue locally as well. Just run:
CXX=clang++-9 cmake -DCMAKE_CUDA_COMPILER=clang++-9 -DALPAKA_ACC_GPU_CUDA_ENABLE=ON '-DCMAKE_CUDA_ARCHITECTURES=50;70' -DCMAKE_CUDA_FLAGS=--no-cuda-version-check ..
With CUDA 11.0 or higher installed, it will error with:

CMake Error at /usr/share/cmake-3.20/Modules/CMakeDetermineCompilerId.cmake:676 (message):
  Compiling the CUDA compiler identification source file
  "CMakeCUDACompilerId.cu" failed.

  Compiler: /usr/bin/clang++-9

  Build flags:

  Id flags:
  --cuda-path=/usr/local/cuda;--cuda-gpu-arch=sm_50;--cuda-gpu-arch=sm_70 -v

  

  The output was:

  1

  clang version 9.0.1-16.1ubuntu1

  Target: x86_64-pc-linux-gnu

  Thread model: posix

  InstalledDir: /usr/bin

  Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10

  Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11

  Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9

  Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10

  Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11

  Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9

  Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11

  Candidate multilib: .;@m64

  Selected multilib: .;@m64

  Found CUDA installation: /usr/local/cuda, version 7.0

  clang: error: cannot find libdevice for sm_50.  Provide path to different
  CUDA installation via --cuda-path, or pass -nocudalib to build without
  linking with libdevice.

  clang: error: cannot find libdevice for sm_70.  Provide path to different
  CUDA installation via --cuda-path, or pass -nocudalib to build without
  linking with libdevice.

  clang: error: GPU arch sm_70 is supported by CUDA versions between 9.0 and
  10.1 (inclusive), but installation at /usr/local/cuda is 7.0.  Use
  --cuda-path to specify a different CUDA install, pass a different GPU arch
  with --cuda-gpu-arch, or pass --no-cuda-version-check.

  

  

Call Stack (most recent call first):
  /usr/share/cmake-3.20/Modules/CMakeDetermineCompilerId.cmake:6 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
  /usr/share/cmake-3.20/Modules/CMakeDetermineCompilerId.cmake:48 (__determine_compiler_id_test)
  /usr/share/cmake-3.20/Modules/CMakeDetermineCUDACompiler.cmake:278 (CMAKE_DETERMINE_COMPILER_ID)
  cmake/alpakaCommon.cmake:348 (enable_language)
  CMakeLists.txt:87 (include)


-- Configuring incomplete, errors occurred!

@bernhardmgruber
Copy link
Member Author

bernhardmgruber commented Nov 18, 2021

It seems we can also not test clang-6 with nvcc 11 in the Gitlab CI, because libomp-6-dev is not available on either Ubuntu 18.04 or 20.04. I upgrade the job to clang-7 therefore.

@bernhardmgruber
Copy link
Member Author

After feedback from @psychocoderHPC, I removed clang as CUDA compiler runs with clang < 11. See comment here: #1011 (comment).

@bernhardmgruber bernhardmgruber force-pushed the cpp17 branch 7 times, most recently from 4d881cd to 57ed7f8 Compare November 18, 2021 19:00
@bernhardmgruber bernhardmgruber changed the title Switch to C++17 and CUDA 11+ Switch to C++17 Nov 18, 2021
@bernhardmgruber
Copy link
Member Author

@psychocoderHPC suggested to me to keep CUDA < 11 for clang as CUDA compiler, since the objective is just to move to C++17. I therefore readded the runs with clang and older CUDA versions.

* Require C++17 in CMake
* Remove nvcc version below 11 from GitHub CI
* Remove CUDA SDK installer below 9.2 from install scripts
* Update supported CUDA versions in README.md
* Eliminate obsolete C++ version checks
* Remove support for nvcc + clang-5
* Update documentation
* Fix warnings
* Merge GitLab CI CUDA job description files
* Add a GitLab CI test with clang-12 as CUDA compiler and cuda11.0
* Add GitHub CI test with clang-12 + nvcc 11.4
* support passing CMAKE_CUDA_FLAGS variable through CI
@bernhardmgruber
Copy link
Member Author

OK, CI passing, seems we are good! :)

Copy link
Member

@j-stephan j-stephan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, thanks! I'll remove the deleted CI jobs from the branch protection rules. Three questions:

.github/workflows/ci.yml Show resolved Hide resolved
.github/workflows/ci.yml Show resolved Hide resolved
README.md Show resolved Hide resolved
@jkelling
Copy link
Member

Should todos that have been marked for the C++17 move be addressed in this PR?

There is at least this one: https://github.com/jkelling/alpaka/blob/develop/include/alpaka/rand/RandDefault.hpp#L135-L140

@j-stephan
Copy link
Member

IMHO it shouldn't. This PR just enables C++17. We can (and should) do the cleanup of the code base in a follow up PR. This is already large enough as-is.

This was referenced Nov 19, 2021
@j-stephan j-stephan merged commit 0ef767d into alpaka-group:develop Nov 19, 2021
@bernhardmgruber bernhardmgruber deleted the cpp17 branch November 19, 2021 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Considerations for C++17-only release
4 participants