Hi-PACE / hipace

Highly efficient Plasma Accelerator Emulation, quasistatic particle-in-cell code
https://hipace.readthedocs.io
Other
54 stars 15 forks source link

DepositCurrent: atomicAdd -> lockAdd #1059

Closed WeiqunZhang closed 10 months ago

WeiqunZhang commented 10 months ago

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. I did not test the new function using hipace. But I used https://github.com/WeiqunZhang/amrex-devtests/tree/main/fab_atomicAdd for testing.

AlexanderSinn commented 10 months ago

Hipace has AMREX_SPACEDIM == 3 but the array for DepositCurrent is only 2D with a length in the z direction of one. I think lockAdd would then only have one lock which probably would result in bad performance.

WeiqunZhang commented 10 months ago

Yes, I overlooked that. Let me try to handle that in amrex.