Skip to content

Commit ea81c8e

Browse files
committed
For top-level beres, need team-shared locals
1 parent c2e67e1 commit ea81c8e

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

components/eamxx/src/physics/gw/gw_functions.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ struct Functions
544544
static void gw_beres_src(
545545
// Inputs
546546
const MemberType& team,
547+
const Workspace& workspace,
547548
const GwCommonInit& init,
548549
const GwConvectInit& cinit,
549550
const Int& pver,

components/eamxx/src/physics/gw/impl/gw_gw_beres_src_impl.hpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ KOKKOS_FUNCTION
1616
void Functions<S,D>::gw_beres_src(
1717
// Inputs
1818
const MemberType& team,
19+
const Workspace& workspace,
1920
const GwCommonInit& init,
2021
const GwConvectInit& cinit,
2122
const Int& pver,
@@ -42,20 +43,26 @@ void Functions<S,D>::gw_beres_src(
4243
Real& hdepth,
4344
Real& maxq0_out)
4445
{
46+
// Note all locals must be shared per team so that we have team-consistent
47+
// views of these values.
48+
auto local_storage = workspace.take("local_storage");
49+
4550
// Maximum heating rate.
46-
Real maxq0(0);
51+
Real& maxq0 = local_storage(0); maxq0 = 0;
4752

4853
// Bottom/top heating range index.
49-
Int mini(0), maxi(0);
54+
Int& mini = reinterpret_cast<Int&>(local_storage(1)); mini = 0;
55+
Int& maxi = reinterpret_cast<Int&>(local_storage(2)); maxi = 0;
5056

5157
// Mean wind in heating region.
52-
Real uh(0);
58+
Real& uh = local_storage(3); uh = 0;
5359

5460
// Min/max projected wind value in each column.
55-
Real Umin(0), Umax(0);
61+
Real& Umin = local_storage(4); Umin = 0;
62+
Real& Umax = local_storage(5); Umax = 0;
5663

5764
// Speed of convective cells relative to storm.
58-
Int storm_speed(0);
65+
Int& storm_speed = reinterpret_cast<Int&>(local_storage(6)); storm_speed = 0;
5966

6067
// note: the heating_altitude_max is probably not needed because there is
6168
// rarely any convective heating above this level and the performance impact
@@ -109,6 +116,8 @@ void Functions<S,D>::gw_beres_src(
109116
Kokkos::TeamVectorRange(team, init.cref.size()), [&] (const int l) {
110117
c(l) = init.cref(l);
111118
});
119+
120+
workspace.release(local_storage);
112121
}
113122

114123
} // namespace gw

components/eamxx/src/physics/gw/impl/gw_gw_convect_gw_sources_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void Functions<S,D>::gw_convect_gw_sources(
4949
//------------------------------------------------------------------
5050

5151
// Shift spectrum so that it is relative to the ground.
52-
const Int shift = -static_cast<Int>(std::round(storm_speed/init.dc));
52+
const Int shift = -static_cast<Int>(std::round(storm_speed/init.dc)) % num_pgwv;
5353

5454
// Adjust for critical level filtering.
5555
const Int Umini = ekat::impl::max(static_cast<Int>(std::round(umin/init.dc)), -pgwv) + pgwv;

components/eamxx/src/physics/gw/impl/gw_gw_heating_depth_impl.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ void Functions<S,D>::gw_heating_depth(
3535
// Find indices for the top and bottom of the heating range.
3636
EKAT_KERNEL_REQUIRE_MSG(!use_gw_convect_old, "The old gw convect algorithm is not supported");
3737

38-
// The type that holds both min and max results
39-
using ResultType = Kokkos::MinMax<Int>::value_type;
40-
ResultType min_max_result;
41-
4238
//---------------------------------------------------------------------
4339
// cleaner version that addresses bug in original where heating max and
4440
// depth were too low whenever heating <=0 occurred in the middle of

components/eamxx/src/physics/gw/tests/infra/gw_test_data.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,8 @@ void gw_beres_src(GwBeresSrcData& d)
13841384

13851385
const auto policy = ekat::TeamPolicyFactory<ExeSpace>::get_default_team_policy(d.ncol, d.init.init.pver);
13861386

1387+
WSM wsm(16, 1, policy);
1388+
13871389
GWF::GwCommonInit init_cp = GWF::s_common_init;
13881390
GWF::GwConvectInit cinit_cp = GWF::s_convect_init;
13891391

@@ -1412,6 +1414,7 @@ void gw_beres_src(GwBeresSrcData& d)
14121414

14131415
GWF::gw_beres_src(
14141416
team,
1417+
wsm.get_workspace(team),
14151418
init_cp,
14161419
cinit_cp,
14171420
pver,

0 commit comments

Comments
 (0)