Skip to content

Commit

Permalink
DepositCurrent: atomicAdd -> lockAdd
Browse files Browse the repository at this point in the history
The new amrex::BaseFab::lockAdd function is an optimized version of
atomicAdd for OpenMP. In my testing on Frontier CPUs, it's up to 10x faster.
  • Loading branch information
WeiqunZhang committed Jan 16, 2024
1 parent c41482d commit 1156f57
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/particles/deposition/PlasmaDepositCurrent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,20 +301,20 @@ DepositCurrent (PlasmaParticleContainer& plasma, Fields & fields, const MultiLas
amrex::Box srcbx = dstbx;
srcbx -= amrex::IntVect(a_itilex_bs, a_itiley_bs, srcbx.smallEnd(2));
if (jx_cmp != -1) {
isl_fab.atomicAdd(tmp_dens[ithread], srcbx, dstbx, 0, jx_cmp, 1);
isl_fab.atomicAdd(tmp_dens[ithread], srcbx, dstbx, 1, jy_cmp, 1);
isl_fab.lockAdd(tmp_dens[ithread], srcbx, dstbx, 0, jx_cmp, 1);
isl_fab.lockAdd(tmp_dens[ithread], srcbx, dstbx, 1, jy_cmp, 1);
}
if (jz_cmp != -1) {
isl_fab.atomicAdd(tmp_dens[ithread], srcbx, dstbx, 2, jz_cmp, 1);
isl_fab.lockAdd(tmp_dens[ithread], srcbx, dstbx, 2, jz_cmp, 1);
}
if (rho_cmp != -1) {
isl_fab.atomicAdd(tmp_dens[ithread], srcbx, dstbx, 3, rho_cmp, 1);
isl_fab.lockAdd(tmp_dens[ithread], srcbx, dstbx, 3, rho_cmp, 1);
}
if (chi_cmp != -1) {
isl_fab.atomicAdd(tmp_dens[ithread], srcbx, dstbx, 4, chi_cmp, 1);
isl_fab.lockAdd(tmp_dens[ithread], srcbx, dstbx, 4, chi_cmp, 1);
}
if (rhomjz_cmp != -1) {
isl_fab.atomicAdd(tmp_dens[ithread], srcbx, dstbx, 5, rhomjz_cmp, 1);
isl_fab.lockAdd(tmp_dens[ithread], srcbx, dstbx, 5, rhomjz_cmp, 1);
}
}
#endif
Expand Down

0 comments on commit 1156f57

Please sign in to comment.