-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change scatter/gather to allow custom/partial iteration over particles #326
Comments
Before this goes into the Mast I want to see that all Alpine test are running correct, multirank on CPU & GPU! |
Update: I fixed the segmentation fault in the new "TestHashedScatter.cpp" test case. It now works for openmp and CUDA, both single and multi rank (tested for 1, 2, 4 ranks). @aaadelmann Yes absolutely! So far everything I tested in LandauDamping worked without a problem. I will test the rest of Alpine tomorrow morning and then do the pull request. |
I ran LandauDamping, PenningTrap and BumponTailInstability each on CPU/GPU with each 1, 2 and 4 ranks and got no numerical differences in the result (I compared the .out files). The timings are also not affected:
All differences are very likely just fluctuations in available ressources on merlin: in no test case is scatter enough to explain the time difference (nothing else changed in the code). Numerical differences were only visible at machine accuracy for all 36 tests, e.g. |
Goal
Integrating energy binning for the field solver (needed in OPAL-X) requires the functionality to only scatter particles inside a specific bin. Since particles might not be sorted by their bin index in the bunch, there are two aspects to consider:
scatter(...)
to iterate over a customKokkos::range_policy(...)
passed by the user.ippl::hash_type
for defining the index.To get the full field solution on a particle (combined from every individual bin solution),
gather(...)
needs to add the field value to the attribute, not overwrite it ("+=
" instead of "=
").Proposed Changes -
scatter
Modify
ParticleAttrib::scatter
to accept a custom range policy as well as anippl::hash_type
:It uses the
hash_type
if a non-emptyhash_array
is passed and does a sanity check if the policy matches the amount of available elements. The main change is just the usage ofmapped_idx
instead ofidx
. This does not create andy branching on GPU, sinceuseHashView
is constant.Non-Class
scatter
InterfaceIn order to preserve old functionality, I overloaded the arguments in a second implementation:
It is execution space independent (same as the field) and uses the
hash_type
already defined inside the attribute.Proposed Changes -
gather
Modify
ParticleAttrib::gather
to take a bool that overwrites the assignment operator:It saves the gathered value and either overwrites or adds to the values of
dview_m(idx)
. A custom iteration policy in here is not necessary, since a field-per-bin still affects all particles.Non-Class
gather
InterfaceAs before, to preserve old functionality, a default argument is used in the Non-Class
gather
:template <typename Attrib1, typename Field, typename Attrib2> inline void gather(Attrib1& attrib, Field& f, const Attrib2& pp, + const bool addToAttribute = false) { attrib.gather(f, pp, addToAttribute); }
Testing
I added another test file
TestHashedScatter
and modified the existingTestGather
.The text was updated successfully, but these errors were encountered: