@@ -2,153 +2,24 @@ include(EkatUtils)
2
2
include (EkatSetCompilerFlags)
3
3
include (ScreamUtils)
4
4
5
- # Copied from EKAT, YAKL is an interface target so requires special
6
- # handling. Get rid of this once RRTMGP is using kokkos.
7
- macro (SetCudaFlagsYakl targetName)
8
- if (Kokkos_ENABLE_CUDA)
9
- # We must find CUDA
10
- find_package (CUDA REQUIRED)
11
-
12
- # Still check if CUDA_FOUND is true, since we don't know if the particular
13
- # FindCUDA.cmake module being used is checking _FIND_REQUIRED
14
- if (NOT CUDA_FOUND)
15
- message (FATAL_ERROR "Error! Unable to find CUDA." )
16
- endif ()
17
-
18
- set (options CUDA_LANG)
19
- set (args1v)
20
- set (argsMv FLAGS )
21
- cmake_parse_arguments (SCF "${options} " "${args1v} " "${argsMv} " ${ARGN} )
22
-
23
- if (SCF_FLAGS)
24
- set (FLAGS ${SCF_FLAGS} )
25
- else ()
26
- # We need host-device lambdas
27
- set (FLAGS --expt-extended-lambda)
28
-
29
- IsDebugBuild (SCF_DEBUG)
30
- if (SCF_DEBUG)
31
- # Turn off fused multiply add for debug so we can stay BFB with host
32
- list (APPEND FLAGS --fmad=false )
33
- endif ()
34
- endif ()
35
-
36
- # Set the flags on the target
37
- if (SCF_CUDA_LANG)
38
- # User is setting the src files language to CUDA
39
- target_compile_options (${targetName} INTERFACE
40
- "$<$<COMPILE_LANGUAGE:CUDA>:${FLAGS} >" )
41
- else ()
42
- # We assume the user is setting the src files lang to CXX
43
- target_compile_options (${targetName} INTERFACE
44
- "$<$<COMPILE_LANGUAGE:CXX>:${FLAGS} >" )
45
- endif ()
46
- endif ()
47
- endmacro ()
48
-
49
- ##################################
50
- # YAKL #
51
- ##################################
52
-
53
- # RRTMGP++ requires YAKL
54
- if (SCREAM_RRTMGP_ENABLE_YAKL)
55
- string (TOLOWER "${CMAKE_BUILD_TYPE} " CMAKE_BUILD_TYPE_ci)
56
- if (TARGET yakl)
57
- # Other E3SM components are building YAKL...
58
- message ("It appears some other part of E3SM is building YAKL.\n "
59
- "We will reuse that, but if this is a debug build we will\n "
60
- "add the --fmad=false flag to the cuda flags used by YAKL\n " )
61
- else ()
62
- # Prepare CUDA/HIP flags for YAKL
63
- if (CUDA_BUILD)
64
- string (REPLACE ";" " " KOKKOS_CUDA_OPTIONS_STR "${KOKKOS_CUDA_OPTIONS} " )
65
- set (YAKL_ARCH "CUDA" )
66
- set (YAKL_CUDA_FLAGS "-DYAKL_ARCH_CUDA ${KOKKOS_CUDA_OPTIONS_STR} --expt-relaxed-constexpr -ccbin ${CMAKE_CXX_COMPILER} " )
67
- string (REPLACE " " ";" YAKL_CUDA_FLAGS_LIST ${YAKL_CUDA_FLAGS} )
68
- endif ()
69
- if (HIP_BUILD)
70
- set (YAKL_ARCH "HIP" )
71
- set (YAKL_HIP_FLAGS "-DYAKL_ARCH_HIP -O3 -D__HIP_ROCclr__ -D__HIP_ARCH_GFX90A__=1 --rocm-path=${ROCM_PATH} --offload-arch=gfx90a -x hip" )
72
- string (REPLACE " " ";" YAKL_HIP_FLAGS_LIST ${YAKL_HIP_FLAGS} )
73
- endif ()
74
- if (SYCL_BUILD)
75
- set (YAKL_ARCH "SYCL" )
76
- set (YAKL_SYCL_FLAGS " -fp-model precise -DYAKL_ARCH_SYCL -\- intel -fsycl -fsycl-targets=spir64_gen -mlong-double-64" )
77
- string (REPLACE " " ";" YAKL_SYCL_FLAGS_LIST ${YAKL_SYCL_FLAGS} )
78
- endif ()
79
-
80
- set (YAKL_SOURCE_DIR ${SCREAM_BASE_DIR} /../../externals/YAKL)
81
- add_subdirectory (${YAKL_SOURCE_DIR} ${CMAKE_BINARY_DIR} /externals/YAKL)
82
-
83
- # Set some additional flag/cpp option on the yakl target
84
-
85
- cmake_policy (SET CMP0079 NEW) # Allow to link to a tgt from a different directory
86
-
87
- # EAMxx *requires* MPI, so simply look for it, then link against it
88
- find_package (MPI REQUIRED COMPONENTS C)
89
- target_link_libraries (yakl INTERFACE MPI::MPI_C)
90
-
91
- # For debug builds, set -DYAKL_DEBUG
92
- if (CMAKE_BUILD_TYPE_ci STREQUAL "debug" )
93
- target_compile_definitions (yakl INTERFACE YAKL_DEBUG)
94
- endif ()
95
- endif ()
96
-
97
- # See eamxx/src/dynamics/homme/CMakeLists.txt for an explanation of this
98
- # workaround.
99
- if ((SCREAM_MACHINE STREQUAL "ascent" OR SCREAM_MACHINE STREQUAL "pm-gpu" ) AND CMAKE_BUILD_TYPE_ci STREQUAL "debug" )
100
- SetCudaFlagsYakl(yakl CUDA_LANG FLAGS -UNDEBUG)
101
- else ()
102
- SetCudaFlagsYakl(yakl CUDA_LANG)
103
- endif ()
104
-
105
- list (APPEND CMAKE_MODULE_PATH ${YAKL_SOURCE_DIR} )
106
- include (yakl_utils)
107
- endif ()
108
-
109
5
##################################
110
6
# RRTMGP #
111
7
##################################
112
8
113
9
set (EAM_RRTMGP_DIR ${SCREAM_BASE_DIR} /../eam/src/physics/rrtmgp)
114
10
# Build RRTMGP library; this builds the core RRTMGP external source as a library named "rrtmgp"
115
11
# NOTE: The external RRTMGP build needs some fixes to work with CUDA in a library build, so for now we will build these ourselves
116
- set (EXTERNAL_SRC
117
- ${EAM_RRTMGP_DIR} /external/cpp/rrtmgp/kernels/mo_gas_optics_kernels.cpp
118
- ${EAM_RRTMGP_DIR} /external/cpp/rrtmgp/mo_rrtmgp_util_reorder.cpp
119
- ${EAM_RRTMGP_DIR} /external/cpp/rte/expand_and_transpose.cpp
120
- ${EAM_RRTMGP_DIR} /external/cpp/rte/kernels/mo_fluxes_broadband_kernels.cpp
121
- ${EAM_RRTMGP_DIR} /external/cpp/rte/kernels/mo_optical_props_kernels.cpp
122
- ${EAM_RRTMGP_DIR} /external/cpp/rte/kernels/mo_rte_solver_kernels.cpp
123
- ${EAM_RRTMGP_DIR} /external/cpp/extensions/fluxes_byband/mo_fluxes_byband_kernels.cpp
124
- ${EAM_RRTMGP_DIR} /external/cpp/examples/all -sky/mo_garand_atmos_io.cpp
125
- ${EAM_RRTMGP_DIR} /external/cpp/examples/all -sky/mo_load_cloud_coefficients.cpp
126
- ${EAM_RRTMGP_DIR} /external/cpp/examples/mo_load_coefficients.cpp
127
- )
128
- add_library (rrtmgp ${EXTERNAL_SRC} )
129
- target_compile_definitions (rrtmgp PUBLIC EAMXX_HAS_RRTMGP)
130
- EkatDisableAllWarning(rrtmgp)
131
- if (SCREAM_RRTMGP_ENABLE_YAKL)
132
- yakl_process_target(rrtmgp)
133
- else ()
134
- if (CUDA_BUILD)
135
- target_compile_options (rrtmgp PUBLIC $<$<COMPILE_LANGUAGE:CXX>:--expt-relaxed-constexpr>)
136
- endif ()
12
+ add_library (rrtmgp INTERFACE )
13
+ target_compile_definitions (rrtmgp INTERFACE EAMXX_HAS_RRTMGP)
14
+ if (Kokkos_ENABLE_CUDA)
15
+ target_compile_options (rrtmgp INTERFACE $<$<COMPILE_LANGUAGE:CXX>:--expt-relaxed-constexpr>)
137
16
endif ()
138
17
139
- # NOTE: cannot use 'PUBLIC' in target_link_libraries,
140
- # since yakl_process_target already used it
141
- # with the "plain" signature
142
18
if (NOT TARGET Kokkos::kokkos)
143
19
find_package (Kokkos REQUIRED)
144
20
endif ()
145
- if (SCREAM_RRTMGP_ENABLE_YAKL)
146
- target_link_libraries (rrtmgp yakl Kokkos::kokkos)
147
- else ()
148
- target_link_libraries (rrtmgp Kokkos::kokkos)
149
- endif ()
150
- target_include_directories (rrtmgp PUBLIC
151
- ${SCREAM_BASE_DIR} /../../externals/YAKL
21
+ target_link_libraries (rrtmgp INTERFACE Kokkos::kokkos)
22
+ target_include_directories (rrtmgp INTERFACE
152
23
${EAM_RRTMGP_DIR} /external/cpp
153
24
${EAM_RRTMGP_DIR} /external/cpp/extensions/cloud_optics
154
25
${EAM_RRTMGP_DIR} /external/cpp/examples
@@ -166,29 +37,14 @@ target_include_directories(rrtmgp PUBLIC
166
37
# separates out the code that comprises the core RRTMGP library from the extensions
167
38
# and examples that we have modified for use in SCREAM specifically.
168
39
169
- # However, due to the mix of YAKL and Kokkos, we split the target in two:
170
- # - scream_rrtmgp: kokkos-based interface to EAMxx
171
- # - scream_rrtmgp_yakl: source codes to be built with YAKL flags/options
172
-
173
- ##################################
174
- # SCREAM_RRTMGP_YAKL #
175
- ##################################
176
-
177
40
set (SCREAM_RRTMGP_SOURCES_INTERFACE
178
41
eamxx_rrtmgp_interface.cpp
179
42
)
180
43
181
44
add_library (eamxx_rrtmgp_interface ${SCREAM_RRTMGP_SOURCES_INTERFACE} )
182
- if (SCREAM_RRTMGP_ENABLE_YAKL)
183
- yakl_process_target(eamxx_rrtmgp_interface)
184
- endif ()
185
-
186
- # NOTE: cannot use 'PUBLIC' in target_link_libraries,
187
- # since yakl_process_target already used it
188
- # with the "plain" signature
189
45
190
46
find_library (NETCDF_C netcdf HINTS ${NetCDF_C_PATH} PATH_SUFFIXES lib lib64)
191
- target_link_libraries (eamxx_rrtmgp_interface ${NETCDF_C} rrtmgp scream_share Kokkos::kokkos)
47
+ target_link_libraries (eamxx_rrtmgp_interface PUBLIC ${NETCDF_C} rrtmgp scream_share Kokkos::kokkos)
192
48
target_include_directories (eamxx_rrtmgp_interface PUBLIC
193
49
${CMAKE_CURRENT_SOURCE_DIR} )
194
50
target_include_directories (eamxx_rrtmgp_interface SYSTEM PUBLIC
@@ -213,19 +69,6 @@ target_include_directories(scream_rrtmgp PUBLIC
213
69
${CMAKE_CURRENT_SOURCE_DIR}
214
70
${CMAKE_CURRENT_BINARY_DIR} /modules)
215
71
216
- # If yakl builds with LANG!=CXX, then the yakl CPP defines don't transfer to scream
217
- # targets, b/c of the lang difference. So, if YAKL_ARCH is set, we add
218
- # ${YAKL_${YAKL_ARCH}_FLAGS} flags to the CXX flags of scream_rrtmgp.
219
- # In particular, this will ensure that all the yakl macros
220
- # are correctly defined in YAKL headers, depending on the backend
221
- if (SCREAM_RRTMGP_ENABLE_YAKL)
222
- if (YAKL_ARCH)
223
- target_compile_options (scream_rrtmgp PUBLIC
224
- "$<$<COMPILE_LANGUAGE:CXX>:${YAKL_${YAKL_ARCH} _FLAGS_LIST}>" )
225
- endif ()
226
- endif ()
227
-
228
-
229
72
# Ensure RRTMGP lookup tables are present in the data dir
230
73
set (RRTMGP_TABLES
231
74
scream/init/rrtmgp-data-sw-g112-210809.nc
0 commit comments