Skip to content

Commit

Permalink
Fix YAKL SetCudaFlags
Browse files Browse the repository at this point in the history
  • Loading branch information
jgfouca committed Mar 12, 2024
1 parent 2dfc73c commit 1968006
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions components/eamxx/src/physics/rrtmgp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
"$<$<COMPILE_LANGUAGE:CUDA>:${FLAGS}>")
else()
# We assume the user is setting the src files lang to CXX
target_compile_options (${targetName} INTERFACE
"$<$<COMPILE_LANGUAGE:CXX>:${FLAGS}>")
endif()
endif()
endmacro()

##################################
# YAKL #
##################################
Expand Down Expand Up @@ -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()

##################################
Expand Down

0 comments on commit 1968006

Please sign in to comment.