Skip to content

Commit 686c582

Browse files
authored
Merge pull request #3058 from ambrad/ambrad/eamxx/shoc-0set-bugfix
EAMxx/SHOC: Fix a subtle GPU bug.
2 parents d61d592 + d57208c commit 686c582

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

cime_config/tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@
705705
"PEM_Ln90.ne30pg2_ne30pg2.F2010-SCREAMv1.scream-spa_remap--scream-output-preset-4",
706706
"ERS_Ln90.ne30pg2_ne30pg2.F2010-SCREAMv1.scream-small_kernels--scream-output-preset-5",
707707
"ERP_Ln22.conusx4v1pg2_r05_oECv3.F2010-SCREAMv1-noAero.scream-bfbhash--scream-output-preset-6",
708+
"ERS_Ln22.ne30pg2_ne30pg2.F2010-SCREAMv1.scream-L128--scream-output-preset-4"
708709
)
709710
},
710711

components/eamxx/src/physics/shoc/eamxx_shoc_process_interface.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ class SHOCMacrophysics : public scream::AtmosphereProcess
138138

139139
// Dry static energy
140140
shoc_s(i,k) = PF::calculate_dse(T_mid(i,k),z_mid(i,k),phis(i));
141+
142+
if (k+1 == nlev_packs) zi_grid(i,nlevi_v)[nlevi_p] = 0;
141143
});
142-
zi_grid(i,nlevi_v)[nlevi_p] = 0;
143144
team.team_barrier();
144145

145146
const auto zt_grid_s = ekat::subview(zt_grid, i);

components/eamxx/src/share/atm_process/atmosphere_process.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ class AtmosphereProcess : public ekat::enable_shared_from_this<AtmosphereProcess
274274

275275
// For internal diagnostics and debugging.
276276
void print_global_state_hash(const std::string& label, const bool in = true,
277-
const bool out = true, const bool internal = true) const;
277+
const bool out = true, const bool internal = true,
278+
const Real* mem = nullptr, const int nmem = 0) const;
278279
// For BFB tracking in production simulations.
279280
void print_fast_global_state_hash(const std::string& label) const;
280281

components/eamxx/src/share/atm_process/atmosphere_process_hash.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,32 @@ void hash (const std::list<FieldGroup>& fgs, HashType& accum) {
113113

114114
} // namespace anon
115115

116+
// (mem, nmem) describe an arbitrary device array. If non-0, the array will be
117+
// hashed and reported as a fourth line.
116118
void AtmosphereProcess
117119
::print_global_state_hash (const std::string& label, const bool in, const bool out,
118-
const bool internal) const {
119-
static constexpr int nslot = 3;
120+
const bool internal, const Real* mem, const int nmem) const {
121+
static constexpr int nslot = 4;
120122
HashType laccum[nslot] = {0};
121123
hash(m_fields_in, laccum[0]);
122124
hash(m_groups_in, laccum[0]);
123125
hash(m_fields_out, laccum[1]);
124126
hash(m_groups_out, laccum[1]);
125127
hash(m_internal_fields, laccum[2]);
128+
const bool hash_array = mem != nullptr;
129+
if (hash_array) {
130+
HashType accum = 0;
131+
Kokkos::parallel_reduce(
132+
Kokkos::RangePolicy<ExeSpace>(0, nmem),
133+
KOKKOS_LAMBDA(const int i, HashType& accum) { bfbhash::hash(mem[i], accum); },
134+
bfbhash::HashReducer<>(accum));
135+
Kokkos::fence();
136+
laccum[3] = accum;
137+
}
126138
HashType gaccum[nslot];
127-
bfbhash::all_reduce_HashType(m_comm.mpi_comm(), laccum, gaccum, nslot);
128-
const bool show[] = {in, out, internal};
139+
const int nr = hash_array ? nslot : nslot-1;
140+
bfbhash::all_reduce_HashType(m_comm.mpi_comm(), laccum, gaccum, nr);
141+
const bool show[] = {in, out, internal, hash_array};
129142
if (m_comm.am_i_root())
130143
for (int i = 0; i < nslot; ++i)
131144
if (show[i])

0 commit comments

Comments
 (0)