Skip to content

Commit 7140e22

Browse files
authored
Merge pull request #398 from E3SM-Project/bartgol/expression-templates-fix
Nano fix for rank-0 expressions
2 parents b2e66d0 + a61cb29 commit 7140e22

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/expression/ekat_expression_eval.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ void evaluate (const Expression<Derived>& e, const ViewT& result)
2424
using Policy1D = Kokkos::RangePolicy<exec_space>;
2525
using PolicyMD = Kokkos::MDRangePolicy<exec_space,Kokkos::Rank<N>>;
2626

27-
int beg[N] = {0};
28-
int end[N];
27+
int beg[N] = {};
28+
int end[N] = {};
2929
for (int i=0; i<N; ++i) end[i] = result.extent(i);
3030

3131
// Cast now, and capture the derived obj in the lambda, to make sure we get the

tests/expression/expressions.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,27 @@ TEST_CASE("expressions", "") {
9191
std::uniform_real_distribution<Real> pdf(0.1, 1);
9292

9393
using kk_t = KokkosTypes<DefaultDevice>;
94+
SECTION ("0d") {
95+
kk_t::view_ND<Real,0> x("x");
96+
kk_t::view_ND<Real,0> y("y");
97+
kk_t::view_ND<Real,0> z("z");
98+
99+
genRandArray(x,engine,pdf);
100+
genRandArray(y,engine,pdf);
101+
102+
bin_ops(x,y,z);
103+
math_fcns(x,y,z);
104+
conditionals(x,y,z);
105+
}
106+
94107
SECTION ("1d") {
95108
kk_t::view_1d<Real> x("x",1000);
96109
kk_t::view_1d<Real> y("y",1000);
97110
kk_t::view_1d<Real> z("z",1000);
98111

99112
genRandArray(x,engine,pdf);
100113
genRandArray(y,engine,pdf);
101-
114+
102115
bin_ops(x,y,z);
103116
math_fcns(x,y,z);
104117
conditionals(x,y,z);
@@ -111,7 +124,7 @@ TEST_CASE("expressions", "") {
111124

112125
genRandArray(x,engine,pdf);
113126
genRandArray(y,engine,pdf);
114-
127+
115128
bin_ops(x,y,z);
116129
math_fcns(x,y,z);
117130
conditionals(x,y,z);
@@ -124,7 +137,7 @@ TEST_CASE("expressions", "") {
124137

125138
genRandArray(x,engine,pdf);
126139
genRandArray(y,engine,pdf);
127-
140+
128141
bin_ops(x,y,z);
129142
math_fcns(x,y,z);
130143
conditionals(x,y,z);

0 commit comments

Comments
 (0)