Skip to content

Commit 5dc34ab

Browse files
authored
Merge branch 'bartgol/ekat-update-051425' (PR #7362)
Update the EKAT submodule and change EAMxx to conform to the new version of EKAT.
2 parents b8fd8b5 + 340ba08 commit 5dc34ab

File tree

410 files changed

+1339
-1390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

410 files changed

+1339
-1390
lines changed

components/eam/src/physics/crm/pam/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ endif()
6969

7070

7171
if (PAM_SCREAM_USE_CXX)
72-
set(EKAT_ENABLE_YAML_PARSER OFF CACHE BOOL "" FORCE)
7372
add_subdirectory(external/physics/scream_cxx_p3_shoc)
7473
add_subdirectory(external/physics/scream_cxx_interfaces)
7574
# add these here to allow driver to intialize P3
@@ -126,7 +125,7 @@ target_compile_options(pam_driver PUBLIC
126125
)
127126

128127
if (PAM_SCREAM_USE_CXX)
129-
target_link_libraries(pam_driver pam_core physics dynamics pam_scream_cxx_interfaces ekat p3 shoc physics_share scream_share)
128+
target_link_libraries(pam_driver pam_core physics dynamics pam_scream_cxx_interfaces ekat::AllLibs p3 shoc physics_share scream_share)
130129
else()
131130
target_link_libraries(pam_driver pam_core physics dynamics )
132131
endif()

components/eamxx/CMakeLists.txt

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,6 @@ set(SCREAM_FPE ${DEFAULT_FPE} CACHE BOOL "Enable floating point error exception"
237237
option (SCREAM_ENABLE_GETRUSAGE "Whether getrusage can be used to get memory usage." OFF)
238238
option (SCREAM_ENABLE_STATM "Whether /proc/self/statm can be used to get memory usage." OFF)
239239

240-
# Whether to disable warnings from tpls.
241-
set (SCREAM_DISABLE_TPL_WARNINGS ON CACHE BOOL "")
242-
243240
# Dycore settings
244241
set(DEFAULT_SCREAM_DYNAMICS_DYCORE "NONE")
245242
if (SCREAM_CIME_BUILD AND SCREAM_DYN_TARGET STREQUAL "theta-l_kokkos")
@@ -462,6 +459,8 @@ endif()
462459
# Configure all tpls and subfolders #
463460
####################################################################
464461

462+
set (EKAT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../externals/ekat)
463+
465464
if (DEFINED ENV{SCREAM_FAKE_ONLY})
466465
# We don't really need to build ekat, but we do need to configure the test-launcher
467466

@@ -486,8 +485,6 @@ if (DEFINED ENV{SCREAM_FAKE_ONLY})
486485
set (TEST_LAUNCHER_ON_GPU False)
487486
endif()
488487

489-
set (EKAT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../externals/ekat)
490-
491488
if (EKAT_ENABLE_MPI)
492489
find_package(MPI REQUIRED COMPONENTS C)
493490

@@ -516,11 +513,29 @@ if (DEFINED ENV{SCREAM_FAKE_ONLY})
516513
endif()
517514

518515
else()
519-
include(EkatBuildEkat)
520-
BuildEkat(PREFIX "SCREAM"
521-
ENABLE_TESTS OFF
522-
ENABLE_FPE ON
523-
ENABLE_FPE_DEFAULT_MASK OFF)
516+
# Enable all EKAT packages
517+
set(EKAT_ENABLE_ALL_PACKAGES ON)
518+
set(EKAT_DISABLE_TPL_WARNINGS ON)
519+
520+
# Disable tests by default (user can override via -D EKAT_ENABLE_TESTS=ON)
521+
set (EKAT_ENABLE_TESTS OFF)
522+
523+
# Ensure testing options are consistent with EAMxx settings (threads, ranks, packs, etc)
524+
set (EKAT_TEST_MAX_THREADS ${SCREAM_TEST_MAX_THREADS} CACHE STRING "Max number of threads for tests")
525+
set (EKAT_TEST_THREAD_INC ${SCREAM_TEST_THREAD_INC} CACHE STRING "Thread count increment for threaded tests")
526+
set (EKAT_TEST_MAX_RANKS ${SCREAM_TEST_MAX_RANKS} CACHE STRING "Max number of ranks for tests")
527+
set (EKAT_TEST_PACK_SIZE ${SCREAM_PACK_SIZE} CACHE STRING
528+
" The number of scalars in a pack::Pack and Mask. Larger packs have good performance on conditional-free loops due to improved caching.")
529+
530+
if (SCREAM_DOUBLE_PRECISION)
531+
set (EKAT_TEST_SINGLE_PRECISION OFF)
532+
set (EKAT_TEST_DOUBLE_PRECISION ON)
533+
else()
534+
set (EKAT_TEST_SINGLE_PRECISION ON)
535+
set (EKAT_TEST_DOUBLE_PRECISION OFF)
536+
endif()
537+
538+
add_subdirectory(${EKAT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/externals/ekat)
524539
endif()
525540

526541
# Set compiler-specific flags

components/eamxx/cmake/ScreamUtils.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ set(SCREAM_CUT_TEST_MV_ARGS ${CUT_TEST_MV_ARGS})
8181
#
8282

8383
# Scream always excludes the ekat test session since it has its own
84-
list(REMOVE_ITEM SCREAM_CUT_EXEC_OPTIONS EXCLUDE_TEST_SESSION)
84+
list(REMOVE_ITEM SCREAM_CUT_EXEC_OPTIONS USER_DEFINED_TEST_SESSION)
8585

8686
###############################################################################
8787
function(CreateUnitTestExec exec_name test_srcs)
8888
###############################################################################
8989
# Call Ekat function, with a couple of extra params
9090
EkatCreateUnitTestExec("${exec_name}" "${test_srcs}" ${ARGN}
91-
EXCLUDE_TEST_SESSION LIBS scream_share scream_test_support)
91+
USER_DEFINED_TEST_SESSION LIBS scream_share scream_test_support)
9292
endfunction(CreateUnitTestExec)
9393

9494
###############################################################################

components/eamxx/docs/developer/kokkos_ekat.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ where
5757
run-time dimensions). E.g., a 2D view of doubles will have `DataType =
5858
double**`. There is also an ability to define compile-time dimensions by
5959
using `[]`, see
60-
[Kokkos wiki section on views]
61-
(<https://kokkos.org/kokkos-core-wiki/API/core/view/view.html).
60+
[Kokkos wiki section on views](https://kokkos.org/kokkos-core-wiki/API/core/view/view.html).
6261
- `LayoutType`: mapping of indices into the underlying 1D memory storage. Types
6362
are:
6463
- `LayoutRight` (used in EAMxx): strides increase from the right most to the
@@ -242,7 +241,9 @@ will _not_ error out, but race conditions will exist among threads.
242241

243242
### KokkosTypes
244243

245-
### ExeSpaceUtils
244+
### TeamPolicyFactory
245+
246+
### ReductionUtils
246247

247248
### Vectorization: Packs
248249

components/eamxx/scripts/gen_boiler.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
f"""#include "catch2/catch.hpp"
1616
1717
#include "share/eamxx_types.hpp"
18-
#include "ekat/ekat_pack.hpp"
19-
#include "ekat/kokkos/ekat_kokkos_utils.hpp"
2018
#include "physics/{phys}/{phys}_functions.hpp"
2119
#include "physics/{phys}/tests/infra/{phys}_test_data.hpp"
2220
2321
#include "{phys}_unit_tests_common.hpp"
2422
23+
#include <ekat_pack.hpp>
24+
#include <ekat_team_policy_utils.hpp>
25+
2526
namespace scream {{
2627
namespace {phys} {{
2728
namespace unit_test {{
@@ -1903,7 +1904,7 @@ def gen_cxx_f2c_bind_impl(self, phys, sub, force_arg_data=None):
19031904
vals_d(btemp_d_1[0]);
19041905
<BLANKLINE>
19051906
const Int nk_pack = ekat::npack<Spack>(nlev);
1906-
const auto policy = ekat::ExeSpaceUtils<ExeSpace>::get_default_team_policy(shcol, nk_pack);
1907+
const auto policy = ekat::TeamPolicyFactory<ExeSpace>::get_default_team_policy(shcol, nk_pack);
19071908
Kokkos::parallel_for(policy, KOKKOS_LAMBDA(const MemberType& team) {
19081909
const Int i = team.league_rank();
19091910
<BLANKLINE>
@@ -2111,7 +2112,7 @@ def gen_cxx_f2c_bind_impl(self, phys, sub, force_arg_data=None):
21112112
# 4) Get nk_pack and policy, launch kernel
21122113
#
21132114
impl += " const Int nk_pack = ekat::npack<Spack>(nlev);\n"
2114-
impl += " const auto policy = ekat::ExeSpaceUtils<ExeSpace>::get_default_team_policy(shcol, nk_pack);\n"
2115+
impl += " const auto policy = ekat::TeamPolicyFactory<ExeSpace>::get_default_team_policy(shcol, nk_pack);\n"
21152116
impl += " Kokkos::parallel_for(policy, KOKKOS_LAMBDA(const MemberType& team) {\n"
21162117
impl += " const Int i = team.league_rank();\n\n"
21172118

components/eamxx/scripts/query-cf-database/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ target_compile_definitions(query-cf-database PUBLIC
1111
CF_SCREAM_NAME_FILE=${CF_SCREAM_NAME_FILE})
1212

1313
find_package (ekat HINTS ${EKAT_ROOT})
14-
find_package (yaml-cpp HINTS ${YAML_CPP_ROOT})
15-
target_link_libraries(query-cf-database ekat yaml-cpp)
14+
target_link_libraries(query-cf-database ekat::AllLibs)

components/eamxx/src/control/atmosphere_driver.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
#include "share/io/eamxx_io_utils.hpp"
1515
#include "share/property_checks/mass_and_energy_column_conservation_check.hpp"
1616

17-
#include "ekat/ekat_assert.hpp"
18-
#include "ekat/util/ekat_string_utils.hpp"
19-
#include "ekat/ekat_parameter_list.hpp"
20-
#include "ekat/ekat_parse_yaml_file.hpp"
21-
#include "ekat/std_meta/ekat_std_utils.hpp"
17+
#include <ekat_assert.hpp>
18+
#include <ekat_string_utils.hpp>
19+
#include <ekat_parameter_list.hpp>
20+
#include <ekat_yaml.hpp>
21+
#include <ekat_std_utils.hpp>
2222

2323
// The global variable fvphyshack is used to help the initial pgN implementation
2424
// work around some current AD constraints. Search the code for "fvphyshack" to
@@ -955,23 +955,23 @@ void AtmosphereDriver::restart_model ()
955955

956956
for (auto& it : m_atm_process_group->get_restart_extra_data()) {
957957
const auto& name = it.first;
958-
auto& any = it.second;
959-
960-
if (any.isType<int>()) {
961-
ekat::any_cast<int>(any) = scorpio::get_attribute<int>(filename,"GLOBAL",name);
962-
} else if (any.isType<std::int64_t>()) {
963-
ekat::any_cast<std::int64_t>(any) = scorpio::get_attribute<std::int64_t>(filename,"GLOBAL",name);
964-
} else if (any.isType<float>()) {
965-
ekat::any_cast<float>(any) = scorpio::get_attribute<float>(filename,"GLOBAL",name);
966-
} else if (any.isType<double>()) {
967-
ekat::any_cast<double>(any) = scorpio::get_attribute<double>(filename,"GLOBAL",name);
968-
} else if (any.isType<std::string>()) {
969-
ekat::any_cast<std::string>(any) = scorpio::get_attribute<std::string>(filename,"GLOBAL",name);
958+
auto& any = *it.second;
959+
960+
if (any.type()==typeid(int)) {
961+
std::any_cast<int&>(any) = scorpio::get_attribute<int>(filename,"GLOBAL",name);
962+
} else if (any.type()==typeid(std::int64_t)) {
963+
std::any_cast<std::int64_t&>(any) = scorpio::get_attribute<std::int64_t>(filename,"GLOBAL",name);
964+
} else if (any.type()==typeid(float)) {
965+
std::any_cast<float&>(any) = scorpio::get_attribute<float>(filename,"GLOBAL",name);
966+
} else if (any.type()==typeid(double)) {
967+
std::any_cast<double&>(any) = scorpio::get_attribute<double>(filename,"GLOBAL",name);
968+
} else if (any.type()==typeid(std::string)) {
969+
std::any_cast<std::string&>(any) = scorpio::get_attribute<std::string>(filename,"GLOBAL",name);
970970
} else {
971971
EKAT_ERROR_MSG (
972972
"Error! Unrecognized/unsupported concrete type for restart extra data.\n"
973973
" - extra data name : " + name + "\n"
974-
" - extra data typeid: " + any.content().type().name() + "\n");
974+
" - extra data typeid: " + std::string(any.type().name()) + "\n");
975975
}
976976
}
977977

components/eamxx/src/control/atmosphere_driver.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
#include "share/atm_process/SCDataManager.hpp"
1313
#include "share/atm_process/IOPDataManager.hpp"
1414

15-
#include "ekat/logging/ekat_logger.hpp"
16-
#include "ekat/mpi/ekat_comm.hpp"
17-
#include "ekat/ekat_parameter_list.hpp"
15+
#include <ekat_logger.hpp>
16+
#include <ekat_comm.hpp>
17+
#include <ekat_parameter_list.hpp>
1818

1919
#include <memory>
2020

components/eamxx/src/control/atmosphere_surface_coupling_exporter.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#include "atmosphere_surface_coupling_exporter.hpp"
22

3-
#include "ekat/ekat_assert.hpp"
4-
#include "ekat/util/ekat_units.hpp"
3+
#include <ekat_team_policy_utils.hpp>
4+
#include <ekat_assert.hpp>
5+
#include <ekat_units.hpp>
56

67
#include <iomanip>
78

@@ -87,7 +88,7 @@ void SurfaceCouplingExporter::create_helper_field (const std::string& name,
8788
Field f(id);
8889
f.get_header().get_alloc_properties().request_allocation();
8990
f.allocate_view();
90-
f.deep_copy(ekat::ScalarTraits<Real>::invalid());
91+
f.deep_copy(ekat::invalid<Real>());
9192

9293
m_helper_fields[name] = f;
9394
}
@@ -266,7 +267,7 @@ void SurfaceCouplingExporter::initialize_impl (const RunType /* run_type */)
266267
++m_num_from_file_exports;
267268
--m_num_from_model_exports;
268269
auto& f_helper = m_helper_fields.at(fname);
269-
// We want to add the field as a deep copy so that the helper_fields are automatically updated.
270+
// We want to add the field as a deep copy so that the helper_fields are automatically updated.
270271
m_time_interp.add_field(f_helper.alias(rname), true);
271272
m_export_from_file_field_names.push_back(fname);
272273
}
@@ -288,9 +289,9 @@ void SurfaceCouplingExporter::initialize_impl (const RunType /* run_type */)
288289
for (size_t ii=0; ii<export_constant_fields.size(); ii++) {
289290
auto fname = export_constant_fields[ii];
290291
// Find the index for this field in the list of export fields.
291-
auto v_loc = std::find(m_export_field_names_vector.begin(),m_export_field_names_vector.end(),fname);
292-
EKAT_REQUIRE_MSG(v_loc != m_export_field_names_vector.end(), "ERROR!! surface_coupling_exporter::init - prescribed_constants has field with name " << fname << " which can't be found in set of exported fields\n.");
293-
auto idx = v_loc - m_export_field_names_vector.begin();
292+
auto v_loc = std::find(m_export_field_names_vector.begin(),m_export_field_names_vector.end(),fname);
293+
EKAT_REQUIRE_MSG(v_loc != m_export_field_names_vector.end(), "ERROR!! surface_coupling_exporter::init - prescribed_constants has field with name " << fname << " which can't be found in set of exported fields\n.");
294+
auto idx = v_loc - m_export_field_names_vector.begin();
294295
// This field should not have been set to anything else yet (recall FROM_MODEL is the default)
295296
EKAT_REQUIRE_MSG(m_export_source_h(idx)==FROM_MODEL,"Error! surface_coupling_exporter::init - attempting to set field " + fname + " export type, which has already been set. Please check namelist options");
296297
m_export_source_h(idx) = CONSTANT;
@@ -364,7 +365,8 @@ void SurfaceCouplingExporter::set_from_file_exports()
364365
// index query in the below.
365366
void SurfaceCouplingExporter::compute_eamxx_exports(const double dt, const bool called_during_initialization)
366367
{
367-
using PC = physics::Constants<Real>;
368+
using PC = physics::Constants<Real>;
369+
using TPF = ekat::TeamPolicyFactory<KT::ExeSpace>;
368370

369371
const auto& p_int = get_field_in("p_int").get_view<const Real**>();
370372
const auto& pseudo_density = get_field_in("pseudo_density").get_view<const Spack**>();
@@ -432,7 +434,7 @@ void SurfaceCouplingExporter::compute_eamxx_exports(const double dt, const bool
432434

433435
// Preprocess exports
434436
auto export_source = m_export_source;
435-
const auto setup_policy = ekat::ExeSpaceUtils<KT::ExeSpace>::get_thread_range_parallel_scan_team_policy(num_cols, num_levs);
437+
const auto setup_policy = TPF::get_thread_range_parallel_scan_team_policy(num_cols, num_levs);
436438
Kokkos::parallel_for(setup_policy, KOKKOS_LAMBDA(const Kokkos::TeamPolicy<KT::ExeSpace>::member_type& team) {
437439
const int i = team.league_rank();
438440

0 commit comments

Comments
 (0)