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

Remove comm hash and add per-comm caches #724

Merged
merged 41 commits into from
Oct 9, 2024
Merged

Conversation

JDBetteridge
Copy link
Collaborator

@JDBetteridge JDBetteridge commented Aug 8, 2024

It's broken and it's dangerous!

Now that we actually free our duplicated comms the hash_comm function is less than useless as the same id can be returned by different comms.

This PR also adds per-comm caches, which circumvents the need to hash a communicator in the first place.

Update:

This (necessarily) turned into a much bigger refactor than was intended. The key changes, beyond removing comm hash, are:

  • Removal of Cached a base class used to create an object that would be cached. However, overriding the __new__ method effectively turned instances into singletons, but the objects didn't necessarily fit this design pattern. Moving forward only functions should be wrapped in a cache.
  • Removal of @cached_property decorator as this is now part of the Python standard library.
  • Refactor of load and get_so in compilation.py to fit with the new caching framework. This now compiles shared objects to RAM backed storage (/tmp) and only caches the .so to non-volatile storage ($PYOP2_CACHE_DIR).
  • Add a PYOP2_SPMD_STRICT environment variable, for checking SPMD behaviour by enabling MPI.Comm.Barrier() on logically collective calls. (Switched off by default)

Moving forward (in pyop3???) we should also remove the ObjectCached base class as it suffers from the same issues as Cached, but this is another big refactor.

@JDBetteridge JDBetteridge marked this pull request as draft August 8, 2024 12:15
Copy link
Collaborator

@connorjward connorjward left a comment

Choose a reason for hiding this comment

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

procrastinating

pyop2/caching.py Outdated Show resolved Hide resolved
pyop2/caching.py Outdated Show resolved Hide resolved
pyop2/caching.py Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
pyop2/global_kernel.py Outdated Show resolved Hide resolved
test/unit/test_updated_caching.py Outdated Show resolved Hide resolved
pyop2/caching.py Outdated Show resolved Hide resolved
pyop2/caching.py Outdated Show resolved Hide resolved
pyop2/compilation.py Show resolved Hide resolved
Co-authored-by: Jack Betteridge <[email protected]>
.github/workflows/ci.yml Outdated Show resolved Hide resolved
pyop2/caching.py Outdated Show resolved Hide resolved
pyop2/caching.py Show resolved Hide resolved
pyop2/compilation.py Outdated Show resolved Hide resolved
pyop2/compilation.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@connorjward connorjward left a comment

Choose a reason for hiding this comment

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

Looks fine.

@dham dham merged commit 31471a6 into master Oct 9, 2024
4 checks passed
@dham dham deleted the JDBetteridge/remove_comm_hash branch October 9, 2024 15:45
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.

3 participants