-
Notifications
You must be signed in to change notification settings - Fork 428
Description
When using more than one OpenMP thread in ImpactX, the addParticles(pc & other) does not work. This might be due to the particular init logic we use in ImpactX for particles when not using collective effects (i.e., redistribute is never called)?
Here is a reproducer:
- pytest-benchmark for all elements BLAST-ImpactX/impactx#987
- uses ParticleContainer: add_particle(other) & make_alike pyamrex#447
In detail, we draw a particle distribution once for a series of tests (which is time consuming) and then copy in the exact same particle container over and over for following tests (to be reproducible in exact particles that we had drawn for other tests & be faster than drawing again).
# once we do
sim.add_particles(bunch_charge_C, distr, npart)
sim.backup_beam = self.sim.particle_container().make_alike() # note: not sure if the issue could also be here?
self.sim.backup_beam.add_particles(self.sim.particle_container())# then repeated for each test we do
# instead of drawing from the distribution again, create a 2nd
# particle container and copy the same initial particles again.
pc = sim.particle_container()
pc.clear_particles()
pc.add_particles(sim.backup_beam) # note: uses default of local=False (no difference if I use local=True)
assert pc.total_number_of_particles() == npart # this fails for more than one OMP threadresults in total_number_of_particles() (with default arguemtns) to return Npart / OpenMP threads.
amrex/Src/Particle/AMReX_ParticleContainer.H
Lines 574 to 582 in cef9e0c
| /** | |
| * \brief Returns # of particles at all levels | |
| * | |
| * If "only_valid" is true it only counts valid particles. | |
| * | |
| * \param only_valid | |
| * \param only_local | |
| */ | |
| Long TotalNumberOfParticles (bool only_valid=true, bool only_local=false) const; |