Skip to content

Commit d49d229

Browse files
authored
SYCL on Windows workaround (#4436)
Replace some std::min and max with amrex::min and max. The issue is the initializer version of std::min and std::max on Windows does not work in SYCL device code.
1 parent eb137e3 commit d49d229

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

Src/Base/AMReX_GpuLaunchFunctsG.H

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ void ParallelFor (Gpu::KernelInfo const& /*info*/,
591591
[[sycl::reqd_work_group_size(MT)]]
592592
[[sycl::reqd_sub_group_size(Gpu::Device::warp_size)]]
593593
{
594-
auto const ncells = std::max({indexer1.numPts(), indexer2.numPts(), indexer3.numPts()});
594+
auto const ncells = amrex::max(indexer1.numPts(), indexer2.numPts(), indexer3.numPts());
595595
for (std::uint64_t icell = item.get_global_id(0), stride = item.get_global_range(0);
596596
icell < ncells; icell += stride) {
597597
if (icell < indexer1.numPts()) {
@@ -680,7 +680,7 @@ void ParallelFor (Gpu::KernelInfo const& /*info*/,
680680
[[sycl::reqd_work_group_size(MT)]]
681681
[[sycl::reqd_sub_group_size(Gpu::Device::warp_size)]]
682682
{
683-
auto const ncells = std::max({indexer1.numPts(), indexer2.numPts(), indexer3.numPts()});
683+
auto const ncells = amrex::max(indexer1.numPts(), indexer2.numPts(), indexer3.numPts());
684684
for (std::uint64_t icell = item.get_global_id(0), stride = item.get_global_range(0);
685685
icell < ncells; icell += stride) {
686686
if (icell < indexer1.numPts()) {

Src/EB/AMReX_EBData.H

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,16 @@ struct EBData
114114
Real y1 = bc1 - ((Real( 0.5)-bc0)*n0+(Real(-0.5)-bc2)*n2)/n1;
115115
Real y2 = bc1 - ((Real(-0.5)-bc0)*n0+(Real( 0.5)-bc2)*n2)/n1;
116116
Real y3 = bc1 - ((Real( 0.5)-bc0)*n0+(Real( 0.5)-bc2)*n2)/n1;
117-
Real ymin = std::min({y0,y1,y2,y3});
118-
Real ymax = std::max({y0,y1,y2,y3});
117+
Real ymin = amrex::min(y0,y1,y2,y3);
118+
Real ymax = amrex::max(y0,y1,y2,y3);
119119
ymin = std::max(ymin, Real(-0.5));
120120
ymax = std::min(ymax, Real( 0.5));
121121
Real z0 = bc2 - ((Real(-0.5)-bc0)*n0+(Real(-0.5)-bc1)*n1)/n2;
122122
Real z1 = bc2 - ((Real( 0.5)-bc0)*n0+(Real(-0.5)-bc1)*n1)/n2;
123123
Real z2 = bc2 - ((Real(-0.5)-bc0)*n0+(Real( 0.5)-bc1)*n1)/n2;
124124
Real z3 = bc2 - ((Real( 0.5)-bc0)*n0+(Real( 0.5)-bc1)*n1)/n2;
125-
Real zmin = std::min({z0,z1,z2,z3});
126-
Real zmax = std::max({z0,z1,z2,z3});
125+
Real zmin = amrex::min(z0,z1,z2,z3);
126+
Real zmax = amrex::max(z0,z1,z2,z3);
127127
zmin = std::max(zmin, Real(-0.5));
128128
zmax = std::min(zmax, Real( 0.5));
129129
Real x, y, z;

Tests/LinearSolvers/Hypre/MyTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ MyTest::solve ()
152152

153153
hp = (!ecx || ecx(i,j,k) == Real(1.0)) ? Real(1.0) : (Real(1.0)+Real(2.)*ecx(i,j,k));
154154
hm = (!ecx || ecx(i-1,j,k) == Real(1.0)) ? Real(1.0) : (Real(1.0)-Real(2.)*ecx(i-1,j,k));
155-
scale = std::min({scale, hp, hm});
155+
scale = amrex::min(scale, hp, hm);
156156
Real s = fac[0]*Real(2.0)/(hp+hm);
157157

158158
if (levset(i+1,j,k) < Real(0.0)) {
@@ -185,7 +185,7 @@ MyTest::solve ()
185185

186186
hp = (!ecy || ecy(i,j,k) == Real(1.0)) ? Real(1.0) : (Real(1.0)+Real(2.)*ecy(i,j,k));
187187
hm = (!ecy || ecy(i,j-1,k) == Real(1.0)) ? Real(1.0) : (Real(1.0)-Real(2.)*ecy(i,j-1,k));
188-
scale = std::min({scale, hp, hm});
188+
scale = amrex::min(scale, hp, hm);
189189
s = fac[1]*Real(2.0)/(hp+hm);
190190

191191
if (levset(i,j+1,k) < Real(0.0)) {
@@ -219,7 +219,7 @@ MyTest::solve ()
219219
#if (AMREX_SPACEDIM > 2)
220220
hp = (!ecz || ecz(i,j,k) == Real(1.0)) ? Real(1.0) : (Real(1.0)+Real(2.)*ecz(i,j,k));
221221
hm = (!ecz || ecz(i,j,k-1) == Real(1.0)) ? Real(1.0) : (Real(1.0)-Real(2.)*ecz(i,j,k-1));
222-
scale = std::min({scale, hp, hm});
222+
scale = amrex::min(scale, hp, hm);
223223
s = fac[2]*Real(2.0)/(hp+hm);
224224

225225
if (levset(i,j,k+1) < Real(0.0)) {

0 commit comments

Comments
 (0)