@@ -87,9 +87,11 @@ ::p3_main_internal(
87
87
const physics::P3_Constants<S> & p3constants)
88
88
{
89
89
using ExeSpace = typename KT::ExeSpace;
90
+ using ScratchViewType = Kokkos::View<bool *, typename ExeSpace::scratch_memory_space>;
90
91
91
92
const Int nk_pack = ekat::npack<Spack>(nk);
92
- const auto policy = ekat::ExeSpaceUtils<ExeSpace>::get_default_team_policy (nj, nk_pack);
93
+ const auto scratch_size = ScratchViewType::shmem_size (2 );
94
+ const auto policy = ekat::ExeSpaceUtils<ExeSpace>::get_default_team_policy (nj, nk_pack).set_scratch_size (0 , Kokkos::PerTeam (scratch_size));
93
95
94
96
// load constants into local vars
95
97
const Scalar inv_dt = 1 / infrastructure.dt ;
@@ -98,9 +100,6 @@ ::p3_main_internal(
98
100
const Int kbot = kdir == -1 ? nk-1 : 0 ;
99
101
constexpr bool debug_ABORT = false ;
100
102
101
- // per-column bools
102
- view_2d<bool > bools (" bools" , nj, 2 );
103
-
104
103
// we do not want to measure init stuff
105
104
auto start = std::chrono::steady_clock::now ();
106
105
@@ -201,9 +200,11 @@ ::p3_main_internal(
201
200
const auto oqv_prev = ekat::subview (diagnostic_inputs.qv_prev , i);
202
201
const auto ot_prev = ekat::subview (diagnostic_inputs.t_prev , i);
203
202
204
- // Need to watch out for race conditions with these shared variables
205
- bool &nucleationPossible = bools (i, 0 );
206
- bool &hydrometeorsPresent = bools (i, 1 );
203
+ // Use Kokkos' scratch pad for allocating 2 bools
204
+ // per team to determine early exits
205
+ ScratchViewType bools (team.team_scratch (0 ), 2 );
206
+ bool &nucleationPossible = bools (0 );
207
+ bool &hydrometeorsPresent = bools (1 );
207
208
208
209
view_1d_ptr_array<Spack, 36 > zero_init = {
209
210
&mu_r, &lamr, &logn0r, &nu, &cdist, &cdist1, &cdistr,
0 commit comments