diff --git a/components/eamxx/src/physics/rrtmgp/CMakeLists.txt b/components/eamxx/src/physics/rrtmgp/CMakeLists.txt index 148186094c1..1c059fd0be1 100644 --- a/components/eamxx/src/physics/rrtmgp/CMakeLists.txt +++ b/components/eamxx/src/physics/rrtmgp/CMakeLists.txt @@ -2,6 +2,50 @@ include(EkatUtils) include(EkatSetCompilerFlags) include(ScreamUtils) +# Copied from EKAT, YAKL is an interface target so requires special +# handling. Get rid of this once RRTMGP is using kokkos. +macro (SetCudaFlagsYakl targetName) + if (Kokkos_ENABLE_CUDA) + # We must find CUDA + find_package(CUDA REQUIRED) + + # Still check if CUDA_FOUND is true, since we don't know if the particular + # FindCUDA.cmake module being used is checking _FIND_REQUIRED + if (NOT CUDA_FOUND) + message (FATAL_ERROR "Error! Unable to find CUDA.") + endif() + + set(options CUDA_LANG) + set(args1v) + set(argsMv FLAGS) + cmake_parse_arguments(SCF "${options}" "${args1v}" "${argsMv}" ${ARGN}) + + if (SCF_FLAGS) + set (FLAGS ${SCF_FLAGS}) + else () + # We need host-device lambdas + set (FLAGS --expt-extended-lambda) + + IsDebugBuild (SCF_DEBUG) + if (SCF_DEBUG) + # Turn off fused multiply add for debug so we can stay BFB with host + list (APPEND FLAGS --fmad=false) + endif() + endif() + + # Set the flags on the target + if (SCF_CUDA_LANG) + # User is setting the src files language to CUDA + target_compile_options (${targetName} INTERFACE + "$<$:${FLAGS}>") + else() + # We assume the user is setting the src files lang to CXX + target_compile_options (${targetName} INTERFACE + "$<$:${FLAGS}>") + endif() + endif() +endmacro() + ################################## # YAKL # ################################## @@ -47,9 +91,9 @@ endif() # See eamxx/src/dynamics/homme/CMakeLists.txt for an explanation of this # workaround. if ((SCREAM_MACHINE STREQUAL "ascent" OR SCREAM_MACHINE STREQUAL "pm-gpu") AND CMAKE_BUILD_TYPE_ci STREQUAL "debug") - SetCudaFlags(yakl CUDA_LANG FLAGS -UNDEBUG) + SetCudaFlagsYakl(yakl CUDA_LANG FLAGS -UNDEBUG) else() - SetCudaFlags(yakl CUDA_LANG) + SetCudaFlagsYakl(yakl CUDA_LANG) endif() ##################################