Hi-PACE / hipace

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

OMP parallelize Beam pusher #1161

Closed AlexanderSinn closed 1 month ago

AlexanderSinn commented 2 months ago

When compiling for CPUs, amrex::ParallelFor only uses a single OMP thread. Some ParallelFor loops in hipace are outside MFIter loops, so to use multiple threads we need to define our own PrallelFor that uses OMP when compiling for CPU.

When compiling for GPU the normal  amrex::ParallelFor is used.

The new omp ParallelFor is used in both the beam and plasma pushers. The plasma pusher was omp parallelized previously. The new version has the same performance but is cleaner (hide whitespace). The beam pusher was not omp parallelized before and could be comparatively very slow when using many threads. Now it's fast.