Skip to content

Commit

Permalink
CMake: improve MSVC+CUDA support (#996)
Browse files Browse the repository at this point in the history
The primary issue now is that nvcc doesn't seem to be parsing with
/Za enabled, so alternate tokens are causing compile failures.
  • Loading branch information
Robert Maynard authored Jun 10, 2020
1 parent 37224d3 commit 3bee527
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 9 additions & 2 deletions Tools/CMake/AMReXFlagsTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,17 @@ add_library(AMReX::Flags_CXX_REQUIRED ALIAS Flags_CXX_REQUIRED)

target_compile_options( Flags_CXX_REQUIRED
INTERFACE
$<${_cxx_msvc}:/Za /bigobj
$<IF:$<VERSION_LESS:$<CXX_COMPILER_VERSION>,19.26>,/experimental:preprocessor,/Zc:preprocessor> >
$<${_cxx_msvc}:/Za /bigobj>
)

# Currently can't make this a generator expression as amrex_evaluate_genex fails
# to parse it and propagate the flags to cuda
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND CXX_COMPILER_VERSION VERSION_LESS 19.26)
target_compile_options( Flags_CXX_REQUIRED
INTERFACE
$<${_cxx_msvc}:/experimental:preprocessor /Zc:preprocessor>
)
endif()
#
# Fortran REQUIRED flags -- This is for internal use only: it is useless to export it
#
Expand Down
6 changes: 3 additions & 3 deletions Tools/CMake/AMReX_SetupCUDA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ if (NOT (CMAKE_SYSTEM_NAME STREQUAL "Windows" ) )
# For Linux and MAC, we need to enforce that manually
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -m64")
endif ()
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-relaxed-constexpr --expt-extended-lambda")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets ${NVCC_ARCH_FLAGS}")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -maxrregcount=${CUDA_MAXREGCOUNT}")
string(APPEND CMAKE_CUDA_FLAGS " --expt-relaxed-constexpr --expt-extended-lambda")
string(APPEND CMAKE_CUDA_FLAGS " -Wno-deprecated-gpu-targets ${NVCC_ARCH_FLAGS}")
string(APPEND CMAKE_CUDA_FLAGS " -maxrregcount=${CUDA_MAXREGCOUNT}")

if (ENABLE_CUDA_FASTMATH)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --use_fast_math")
Expand Down

0 comments on commit 3bee527

Please sign in to comment.