Compiling application with differing cuda_standard and cxx_standard


ROOT Version: 6.25.01
Platform: Ubuntu 20.04.02
Compiler: GCC 9.3.0 and NVCC 11.4.1
Build Tools: CMake 3.16


Hi all,

It is noted in the ROOT build from source instructions that:

Starting with ROOT 6.20.06 it is possible to set CMAKE_CXX_STANDARD and CMAKE_CUDA_STANDARD` to different values to allow to compile ROOT with C++17 while CUDA code with C++14 when using CUDA 9 or 10.

I have succesfully installed ROOT with CXX_STANDARD of 17 and CUDA_STANDARD of 14. However, if I include any ROOT headers in .cu files I am met with compile-time errors like:

/usr/local/lib/root-6.25.01_install/include/ROOT/RStringView.hxx(90): error: expected an operator
/usr/local/lib/root-6.25.01_install/include/ROOT/RStringView.hxx(90): error: explicit type is missing (“int” assumed)
/usr/local/lib/root-6.25.01_install/include/TString.h(115): error: expected an operator
/usr/local/lib/root-6.25.01_install/include/TString.h(115): error: explicit type is missing (“int” assumed)
/usr/local/lib/root-6.25.01_install/include/TString.h(280): error: namespace “std” has no member “string_view”

I assume that this comes from trying to compile these files with an insufficient C++ standard.

I was wondering if anyone had advice as to how to resolve this problem. Some hypotheses/guiding questions I have are:
1.) I notice the instructions say use of mismatching cuda and cxx standards is possible for CUDA 9 or 10. I am using CUDA 11.4. Should I downgrade my CUDA to an earlier version to allow this?

2.) If I upgrade my CMake to a later version which supports CMAKE_CUDA_STANDARD of 17 can I compile both ROOT and CUDA with support for C++17?

3.) Is it possible that the issues above are not the result of mismatched CUDA and CXX standards? Are there any additional CMake flags I need to set at application compile time that I might be missing? I am able to compile CUDA libraries and link them to a ROOT containing project. My issue only occurs when I try to include ROOT headers in a .cu file.

Thank you for your help,

Joseph

I don’t have the insight to answer the other questions, but regarding this one; the CMake included with Ubuntu 20.04 suffered with compiling CUDA + ROOT with 2017 standards for me too and upgrading to a newer CMake fixed this. Something like sudo apt remove cmake && sudo snap install cmake --classic would make experimenting with a newer CMake trivial.

Thanks so much James for the extremely fast response. I’ll give this a try.

This did the trick.

  1. Updating to a newer version of CMake
  2. Compiling CUDA 11 with C++17 support and then
  3. Changing the minimum version of CMake in my own CMakeLists file to a version of 3.18 or newer has gotten rid of the compile-time errors.

Thanks again!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.