Skip to content
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

Particle tiling and OpenMP threading #551

Merged
merged 41 commits into from
Jul 27, 2021

Conversation

MaxThevenet
Copy link
Member

@MaxThevenet MaxThevenet commented Jul 3, 2021

This PR proposes to add logical tiling for plasma particles when running on CPU. The option is controlled with hipace.do_tiling (default true), and affects field gather (FG) + push and current deposition (CD). The tile size is controlled with plasmas.sort_bin_size (default 32). When activated, plasma particles are sorted logically (they are not re-ordered in memory, but an index mask is built to allow accessing particles in each tile) and particle operations are done on a per-tile basis:

  • For field gather and particle push, the main operations are encapsulated in a loop over tiles
  • The current deposition is done in temporary arrays, which are atomic-added to the main array

Effect on performance:

  • good: Improve cache re-use in CD and FG
  • bad: plasma particles are accessed randomly
  • good: enable OpenMP threading, to parallelise the simulation transversely.

In practice, the main changes are:

  • Create TileSort.H/cpp that does the logical tile sort (similar to BinSort.H/cpp, renamed SliceSort.H/cpp)
  • Create temporary arrays (in class Fields) for the current on 1 tile
  • Add a loop over tiles for plasma particle operations (Advance and Deposition)
  • Call the tile sort after each plasma particle advance.

@MaxThevenet MaxThevenet added component: plasma About the plasma species performance optimization, benchmark, profiling, etc. labels Jul 3, 2021
@MaxThevenet
Copy link
Member Author

This PR is ready for review.
@atmyers If I understand correctly, findParticlesInEachTile in src/particles/TileSort.cpp is not threaded, which has a noticeable effect on scaling. Do you see an easy way to make it openMP-parallel?

@atmyers
Copy link
Contributor

atmyers commented Jul 23, 2021

I think we want to use a different algorithm there for the OpenMP case. Instead of using parallel prefix sum, we can use data duplication. It will probably be easier to explain this via a quick zoom meeting.

Copy link
Member

@SeverinDiederichs SeverinDiederichs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for this PR!

@MaxThevenet MaxThevenet merged commit 877b138 into Hi-PACE:development Jul 27, 2021
@MaxThevenet MaxThevenet deleted the tiling3 branch July 27, 2021 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: plasma About the plasma species performance optimization, benchmark, profiling, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants