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

Minimal support for threads partitioning #277

Merged
merged 33 commits into from
Jun 3, 2024
Merged

Minimal support for threads partitioning #277

merged 33 commits into from
Jun 3, 2024

Conversation

juntyr
Copy link
Owner

@juntyr juntyr commented May 26, 2024

Fixes #106

This PR finally implements multithreading-based partitioning by limiting the scope:

  • MPI partitioning is improved but its partitioning-before-partitioning is not fixed, just made more difficult to observe
  • broadcasting args and folding results are kept minimal for now, both should in the future be serde-based
  • threads partitioning requires an event log for now, in the future it could also support live event reporting with a bit of e.g. timsort
  • no special resource sharing is done beyond exploiting sharing after Clone, e.g. by using Arcs inside scenario cogs
  • no support for parallel pausing exists (see Pausing for parallel algorithms #68) and this is exploited to postpone some implementation decisions

Still, this is an important step forward!

TODOs:

  • implement result folding for MPI
  • check if final steps and time vote is still needed from partitioning
  • use more Arcs for large arrays in scenario cogs
    • initial pass, includes Habitats
    • DispersalSamplers are initialised too late, they would need to be created earlier (no more separate Scenario init and build steps)
  • one short refactoring pass
    • fix event log recorder for MPI
    • fix local partition lifetime API + MPI impl
  • check against MPI implementation for same results
  • check against previous MPI implementation for same results
  • check new in-memory dispersal sampler implementation
    • fix with complete rewrite: when self-dispersal dominates, it may be distributed across several atoms

@juntyr juntyr self-assigned this May 26, 2024
@codecov-commenter
Copy link

codecov-commenter commented May 26, 2024

Codecov Report

Attention: Patch coverage is 0% with 1781 lines in your changes are missing coverage. Please review.

Project coverage is 15.59%. Comparing base (92d8ef1) to head (7ae8180).

Files Patch % Lines
necsim/partitioning/mpi/src/partition/common.rs 0.00% 203 Missing ⚠️
necsim/partitioning/threads/src/lib.rs 0.00% 197 Missing ⚠️
necsim/partitioning/threads/src/partition.rs 0.00% 194 Missing ⚠️
...al_sampler/in_memory/packed_separable_alias/mod.rs 0.00% 137 Missing ⚠️
necsim/impls/std/src/event_log/recorder.rs 0.00% 128 Missing ⚠️
necsim/partitioning/threads/src/vote.rs 0.00% 105 Missing ⚠️
...pler/in_memory/packed_separable_alias/dispersal.rs 0.00% 102 Missing ⚠️
necsim/partitioning/mpi/src/lib.rs 0.00% 79 Missing ⚠️
rustcoalescence/src/args/config/partitioning.rs 0.00% 45 Missing ⚠️
necsim/partitioning/mpi/src/partition/root.rs 0.00% 38 Missing ⚠️
... and 82 more

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #277      +/-   ##
==========================================
- Coverage   16.25%   15.59%   -0.67%     
==========================================
  Files         289      296       +7     
  Lines       20592    21469     +877     
==========================================
  Hits         3348     3348              
- Misses      17244    18121     +877     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner Author

@juntyr juntyr left a comment

Choose a reason for hiding this comment

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

Some small nits, in-memory packed separable dispersal sampler, MPI partitioning, and threads partitioning not yet reviewed

README.md Outdated Show resolved Hide resolved
docs/simulate.ron Outdated Show resolved Hide resolved
necsim/core/src/cogs/rng.rs Show resolved Hide resolved
necsim/impls/no-std/src/array2d.rs Outdated Show resolved Hide resolved
necsim/impls/no-std/src/array2d.rs Outdated Show resolved Hide resolved
necsim/impls/std/src/event_log/recorder.rs Outdated Show resolved Hide resolved
rustcoalescence/scenarios/src/lib.rs Show resolved Hide resolved
Copy link
Owner Author

@juntyr juntyr left a comment

Choose a reason for hiding this comment

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

Some more nits and one bug

@juntyr
Copy link
Owner Author

juntyr commented Jun 2, 2024

Madingley fg0size12 habitat with turnover map and 10^-3 sample percentage

==== speciation 0.1 (with seed 42) ====

new independent monolithic: 4192785
new independent threads: 4192785
new independent MPI: 4192785
new gillespie monolithic: 4192786
new skipping monolithic: 4192313

old skipping monolithic: 4193180
old gillespie monolithic: 4192921
old independent monolithic: 4192909
old independent MPI: 4192909

==== speciation 0.01 (all monolithic with entropy seeds) ====
old independent: 3995287, 3995788, 3995771, 3996757, 3996123
old skipping: 3995004, 3995460, 3995548, 3995990, 3994950, 3996074, 3995850, 3995151, 3996214, 3995426, 3996369, 3996164, 3995796, 3995925

new independent: 3996050, 3995425
new skipping: 3906695, 3905369, 3905860, 3905530, 3905530

@juntyr
Copy link
Owner Author

juntyr commented Jun 2, 2024

While MPI and threads clearly work, the separable dispersal sampler does NOT

@juntyr
Copy link
Owner Author

juntyr commented Jun 3, 2024

==== speciation 0.01 (all monolithic with entropy seeds) ====

new v2 independent: 3995604, 3995902, 3995285, 3996393, 3995210
new v2 skipping: 3995976, 3995564, 3996725, 3995754, 3995576, 3995929, 3995656, 3995466, 3995450, 3996128, 3995070, 3995100, 3995427, 3995644, 3996332, 3995801

@juntyr
Copy link
Owner Author

juntyr commented Jun 3, 2024

The new packed separable alias dispersal sampler should still be optimised further ... but it shall be good enough for now

@juntyr juntyr merged commit c8c3023 into main Jun 3, 2024
6 checks passed
@juntyr juntyr deleted the threads-partitioning branch June 3, 2024 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor Patitioning::into_local_partition into context method + add thread-based partitioning
2 participants