Skip to content

Commit eb388ae

Browse files
authored
Work around compiler bug in nvcc 12.2 by using functor instead of lambda (#3653)
This fixes an issue seen in ERF on garuda. The proposed changes: - [ ] fix a bug or incorrect behavior in AMReX - [ ] add new capabilities to AMReX - [ ] changes answers in the test suite to more than roundoff level - [ ] are likely to significantly affect the results of downstream AMReX users - [ ] include documentation in the code and/or rst files, if appropriate
1 parent 2f47fa7 commit eb388ae

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

Src/Particle/AMReX_ParticleIO.H

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
3232
}
3333
}
3434

35+
struct FilterPositiveID {
36+
template <typename P>
37+
AMREX_GPU_HOST_DEVICE
38+
int operator() (const P& p) const {
39+
return p.id() > 0;
40+
}
41+
};
42+
3543
template <typename ParticleType, int NArrayReal, int NArrayInt,
3644
template<class> class Allocator, class CellAssignor>
3745
void
@@ -77,10 +85,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
7785

7886
WriteBinaryParticleData(dir, name, write_real_comp, write_int_comp,
7987
tmp_real_comp_names, tmp_int_comp_names,
80-
[=] AMREX_GPU_HOST_DEVICE (const SuperParticleType& p) -> int
81-
{
82-
return p.id() > 0;
83-
}, true);
88+
FilterPositiveID{}, true);
8489
}
8590

8691
template <typename ParticleType, int NArrayReal, int NArrayInt,
@@ -111,10 +116,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
111116

112117
WriteBinaryParticleData(dir, name, write_real_comp, write_int_comp,
113118
real_comp_names, int_comp_names,
114-
[=] AMREX_GPU_HOST_DEVICE (const SuperParticleType& p)
115-
{
116-
return p.id() > 0;
117-
});
119+
FilterPositiveID{});
118120
}
119121

120122
template <typename ParticleType, int NArrayReal, int NArrayInt,
@@ -141,10 +143,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
141143
WriteBinaryParticleData(dir, name,
142144
write_real_comp, write_int_comp,
143145
real_comp_names, int_comp_names,
144-
[=] AMREX_GPU_HOST_DEVICE (const SuperParticleType& p)
145-
{
146-
return p.id() > 0;
147-
});
146+
FilterPositiveID{});
148147
}
149148

150149
template <typename ParticleType, int NArrayReal, int NArrayInt,
@@ -177,10 +176,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
177176
WriteBinaryParticleData(dir, name,
178177
write_real_comp, write_int_comp,
179178
real_comp_names, int_comp_names,
180-
[=] AMREX_GPU_HOST_DEVICE (const SuperParticleType& p)
181-
{
182-
return p.id() > 0;
183-
});
179+
FilterPositiveID{});
184180
}
185181

186182
template <typename ParticleType, int NArrayReal, int NArrayInt,
@@ -213,10 +209,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
213209

214210
WriteBinaryParticleData(dir, name, write_real_comp, write_int_comp,
215211
real_comp_names, int_comp_names,
216-
[=] AMREX_GPU_HOST_DEVICE (const SuperParticleType& p)
217-
{
218-
return p.id() > 0;
219-
});
212+
FilterPositiveID{});
220213
}
221214

222215
template <typename ParticleType, int NArrayReal, int NArrayInt,
@@ -234,10 +227,7 @@ WritePlotFile (const std::string& dir, const std::string& name,
234227
WriteBinaryParticleData(dir, name,
235228
write_real_comp, write_int_comp,
236229
real_comp_names, int_comp_names,
237-
[=] AMREX_GPU_HOST_DEVICE (const SuperParticleType& p)
238-
{
239-
return p.id() > 0;
240-
});
230+
FilterPositiveID{});
241231
}
242232

243233
template <typename ParticleType, int NArrayReal, int NArrayInt,

0 commit comments

Comments
 (0)