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

Cannot build with CUDA enabled and C++17 #11013

Closed
Rombur opened this issue Oct 6, 2020 · 6 comments
Closed

Cannot build with CUDA enabled and C++17 #11013

Rombur opened this issue Oct 6, 2020 · 6 comments

Comments

@Rombur
Copy link
Member

Rombur commented Oct 6, 2020

Hey all,

I can't compile the library with CUDA enabled and C++17. Somehow it looks like we inject -std=c++14 in the cuda flags and nvcc does not like to have both c++14 and c++17. Unfortunately, I can't find where the -std=c++14 flag is added. You can see in the detailed.log that the CUDA flags are correct:

#            DEAL_II_CUDA_FLAGS = -arch=sm_70 -std=c++17
#            DEAL_II_CUDA_FLAGS_RELEASE = 
#            DEAL_II_CUDA_FLAGS_DEBUG = -G

but the CUDA flags that are used are different (from source/lac/CMakeFiles/obj_lac_debug.dir/flags.make)

-arch=sm_70 -std=c++17 -G -std=c++14

I obviously tried to grep for -std=c++14 but I couldn't find it. Looking at this I would expect -G to be the last flag. Any idea how to debug this?

@masterleinad
Copy link
Member

Hmmm... I can't quite reproduce. Configuring with CMAKE_CXX_STANDARD=17 and DEAL_II_CUDA_FLAGS= -arch=sm_70 -std=c++17 gives me

CUDA_FLAGS =   -Xcompiler "-fPIC -Wall -Wextra -Wmissing-braces -Woverloaded-virtual -Wpointer-arith -Wsign-compare -Wsuggest-override -Wswitch -Wsynth -Wwrite-strings -Wno-placement-new -Wno-deprecated-declarations -Wno-literal-suffix -Wno-psabi -fopenmp-simd -pthread -Wno-parentheses -Wno-unused-local-typedefs -O0 -ggdb " -arch=sm_70 -std=c++17 -G

The only place I could think of that adds a -std=c++14 flag is

IF(NOT DEAL_II_HAVE_CXX14)
MESSAGE(STATUS "C++14 support not available. Try to set -std=c++14 explicitly")
ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-std=c++14")
_set_up_cmake_required()
_test_cxx14_support()
ENDIF()
.

@Rombur
Copy link
Member Author

Rombur commented Oct 6, 2020

Thanks that's true it works with CMAKE_CXX_STANDARD=17. I was setting the flag through CMAKE_CXX_FLAGS. The reason I didn't use CMAKE_CXX_STANDARD=17 is because the std=c++17 flag is not passed to our C++17 compatibility check. If you set CMAKE_CXX_STANDARD=17 alone, our C++17 check will fail and you will see that deal.II disables C++17. You can see in your CUDA_FLAGS that the std=c++17 flag is not sent to the host compiler. I guess we need to set the flag explicitly for the host and the device compiler and set the CXX standard.

@masterleinad
Copy link
Member

Fair enough. Still, if I set DEAL_II_CXX_FLAGS=-std=c++17 and DEAL_II_CUDA_FLAGS=-arch=sm_70 -std=c++17 (and don't specify CMAKE_CXX_STANDARD), I get

CUDA_FLAGS =   -Xcompiler "-fPIC -Wall -Wextra -Wmissing-braces -Woverloaded-virtual -Wpointer-arith -Wsign-compare -Wsuggest-override -Wswitch -Wsynth -Wwrite-strings -Wno-placement-new -Wno-deprecated-declarations -Wno-literal-suffix -Wno-psabi -fopenmp-simd -std=c++17 -pthread -Wno-parentheses -Wno-unused-local-typedefs -O0 -ggdb " -arch=sm_70 -std=c++17 -G

@Rombur
Copy link
Member Author

Rombur commented Oct 6, 2020

That's so strange. I tried two different versions of CMake (3.17 and 3.18) but I always get the same problem.

@bangerth bangerth added the C++17 label Apr 22, 2021
@tamiko
Copy link
Member

tamiko commented Nov 30, 2022

@Rombur Is this still an issue?

@Rombur
Copy link
Member Author

Rombur commented Nov 30, 2022

I haven't tried in a while but since we are moving to Kokkos anyway this is irrelevant. I'm closing

@Rombur Rombur closed this as completed Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants