Skip to content

Commit 68a8e1e

Browse files
Bug fix: Mixed precision builds fail due to conflicting types (#6028)
This PR fixes build failures when using double precision fields but single precision particles. --------- Signed-off-by: roelof-groenewald <[email protected]>
1 parent 939fca6 commit 68a8e1e

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

.github/workflows/intel.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ jobs:
8080
export OMP_NUM_THREADS=2
8181
Examples/Physics_applications/laser_acceleration/inputs_test_3d_laser_acceleration_picmi.py
8282
83-
build_dpcc:
84-
name: oneAPI DPC++ SP
83+
build_dpc:
84+
name: oneAPI DPC++ DP SP
8585
runs-on: ubuntu-24.04
8686
# Since 2021.4.0, AMReX_GpuUtility.H: error: comparison with NaN always evaluates to false in fast floating point modes
8787
# oneAPI 2022.2.0 hangs for -O2 and higher:
@@ -121,7 +121,7 @@ jobs:
121121
export CC=$(which icx)
122122
export CXXFLAGS="-fsycl ${CXXFLAGS}"
123123
124-
cmake -S . -B build_sp \
124+
cmake -S . -B build_dpsp \
125125
-DBUILD_SHARED_LIBS=ON \
126126
-DCMAKE_VERBOSE_MAKEFILE=ON \
127127
-DWarpX_COMPUTE=SYCL \
@@ -133,8 +133,9 @@ jobs:
133133
-DWarpX_PYTHON=ON \
134134
-DWarpX_MPI=OFF \
135135
-DWarpX_OPENPMD=ON \
136-
-DWarpX_PRECISION=SINGLE
137-
cmake --build build_sp -j 4
136+
-DWarpX_PRECISION=DOUBLE \
137+
-DWarpX_PARTICLE_PRECISION=SINGLE
138+
cmake --build build_dpsp -j 4
138139
139140
ccache -s
140141
du -hs ~/.cache/ccache

Source/Diagnostics/ReducedDiags/ParticleHistogram2D.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void ParticleHistogram2D::ComputeDiags (int step)
137137
// resize data array
138138
Array<int,2> tlo{0,0}; // lower bounds
139139
Array<int,2> thi{m_bin_num_abs-1, m_bin_num_ord-1}; // inclusive upper bounds
140-
amrex::TableData<amrex::Real,2> d_data_2D(tlo, thi);
140+
amrex::TableData<amrex::ParticleReal,2> d_data_2D(tlo, thi);
141141
m_h_data_2D.resize(tlo, thi, The_Pinned_Arena());
142142
auto const& h_table_data = m_h_data_2D.table();
143143

@@ -228,7 +228,7 @@ void ParticleHistogram2D::ComputeDiags (int step)
228228
// continue function if particle is not filtered out
229229
auto const f_abs = fun_partparser_abs(t, x, y, z, ux, uy, uz, w);
230230
auto const f_ord = fun_partparser_ord(t, x, y, z, ux, uy, uz, w);
231-
auto const weight = fun_valueparser(t, x, y, z, ux, uy, uz, w);
231+
auto const weight = static_cast<amrex::ParticleReal>(fun_valueparser(t, x, y, z, ux, uy, uz, w));
232232

233233
// determine particle bin
234234
int const bin_abs = int(Math::floor((f_abs-bin_min_abs)/bin_size_abs));
@@ -237,7 +237,7 @@ void ParticleHistogram2D::ComputeDiags (int step)
237237
int const bin_ord = int(Math::floor((f_ord-bin_min_ord)/bin_size_ord));
238238
if ( bin_ord<0 || bin_ord>=num_bins_ord ) { return; } // discard if out-of-range
239239

240-
amrex::Real &data = d_table(bin_abs, bin_ord);
240+
auto &data = d_table(bin_abs, bin_ord);
241241
amrex::HostDevice::Atomic::Add(&data, weight);
242242
});
243243
}

Source/Particles/Collision/BinaryCollision/BinaryCollision.H

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public:
314314
}
315315

316316
amrex::Geometry const& geom_lev = WarpX::GetInstance().Geom(lev);
317-
auto const dV = AMREX_D_TERM(geom_lev.CellSize(0), *geom_lev.CellSize(1), *geom_lev.CellSize(2));
317+
amrex::ParticleReal const dV = AMREX_D_TERM(geom_lev.CellSize(0), *geom_lev.CellSize(1), *geom_lev.CellSize(2));
318318
#if defined(WARPX_DIM_RZ)
319319
amrex::Box const& cbx = mfi.tilebox(amrex::IntVect::TheZeroVector()); //Cell-centered box
320320
auto const lo = lbound(cbx);
@@ -331,18 +331,18 @@ public:
331331
int const ri = (i_cell - i_cell%nz)/nz;
332332
// rr is radius at the cell center
333333
amrex::ParticleReal const rr = (ri + 0.5_prt)*dr;
334-
return 2.0_prt*MathConst::pi*rr;
334+
return 2.0_prt*static_cast<amrex::ParticleReal>(MathConst::pi)*rr;
335335
#elif defined(WARPX_DIM_RCYLINDER)
336336
int const ri = i_cell;
337337
// rr is radius at the cell center
338338
amrex::ParticleReal const rr = (ri + 0.5_prt)*dr;
339-
return 2.0_prt*MathConst::pi*rr;
339+
return 2.0_prt*static_cast<amrex::ParticleReal>(MathConst::pi)*rr;
340340
#elif defined(WARPX_DIM_RSPHERE)
341341
// This needs double checking
342342
int const ri = i_cell;
343343
// rr is radius at the cell center
344344
amrex::ParticleReal const rr = (ri + 0.5_prt)*dr;
345-
return 4.0_prt*MathConst::pi*rr*rr;
345+
return 4.0_prt*static_cast<amrex::ParticleReal>(MathConst::pi)*rr*rr;
346346
#else
347347
// No factor is needed for Cartesian
348348
amrex::ignore_unused(i_cell);

Source/Particles/Collision/BinaryCollision/DSMC/SplitAndScatterFunc.H

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ public:
408408
// After C is determined the momentum vectors are arranged
409409
// such that the net linear momentum is zero.
410410

411-
const amrex::ParticleReal n_2 = std::min(E2 / E_coll, 0.5_prt * amrex::Random(engine));
411+
const amrex::ParticleReal n_2 = std::min(E2 / E_coll, 0.5_prt * static_cast<amrex::ParticleReal>(amrex::Random(engine)));
412412

413413
// find ellipse semi-major and minor axis
414414
const amrex::ParticleReal a = 0.5_prt * (1.0_prt - n_2);

0 commit comments

Comments
 (0)