CUDA CMake build fails with lots of errors about constexpr __host__ functions #2000
-
Hi, I am trying to compile my application with CUDA support enabled in AMReX on Ubuntu 20.04 with CUDA 11 and the latest AMReX development commit (5eedbae). I use CMake to build my code with AMReX as a subdirectory:
However, when building, I get lots (hundreds) of errors like this:
Did I configure something incorrectly? The flag --expt-relaxed-constexpr shows up in the CMake configuration, but for some reason is not passed to nvcc when compiling. |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments
-
@BenWibking thank you for reporting the issue. Could you post the full cmake invocation? Can you also try with GNUMake instead of Ninja? Thanks. |
Beta Was this translation helpful? Give feedback.
-
Hi @mic84, thanks for taking a look at this. I invoke cmake just with: My CMakeLists.txt file sets a few more CMake options:
For my development workflow, using the |
Beta Was this translation helpful? Give feedback.
-
Ah, no, actually it doesn't work with |
Beta Was this translation helpful? Give feedback.
-
I see only now that you are not including the |
Beta Was this translation helpful? Give feedback.
-
I tried that, adding amrex/Tools/CMake to my CMAKE_MODULE_PATH as such:
However, I get this error:
|
Beta Was this translation helpful? Give feedback.
-
The issue is that the CMake minimum required version is too old. AMReX requires CMake >= 3.14. |
Beta Was this translation helpful? Give feedback.
-
@BenWibking could you verify that bumping up the minimum required version to 3.14 helps? |
Beta Was this translation helpful? Give feedback.
-
Yes, that solves the immediate issue. However, my code still does not compile when CUDA is enabled. I get these errors (which do not appear when compiling for CPU only): [build] ../src/simulation.hpp(39): error #304: no instance of overloaded function "amrex::FArrayBox::contains_nan" matches the argument list [build] ../src/linear_advection.hpp(50): error #304: no instance of overloaded function "amrex::FArrayBox::saxpy" matches the argument list |
Beta Was this translation helpful? Give feedback.
-
Ah, nevermind, this looks like an API change that is causing the compile failure due to some strange difference in templated function instantiation between CUDA and non-CUDA compiles. The original issue is solved, so I'll close this issue. Thanks for your help! |
Beta Was this translation helpful? Give feedback.
The issue is that the CMake minimum required version is too old. AMReX requires CMake >= 3.14.
Even if the CMake version you are running is 3.20, the command
cmake_minimum_required(VERSION 3.1)
sets old policies that are not compatible with AMReX CMake.