You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Disclaimer: This implementation plan was formulated by a core Firedrake developer in collaboration with Gemini.
Summary of Implementation Plan: Avoiding Reassembly into the Same Tensor
This plan introduces a change to PyOP2 to track state changes in global/scalar datasets (Global) alongside standard Dat dependencies. The ParloopAssembler runtime is then updated to leverage these versions, allowing it to skip core execution loops when variational forms, coefficients, constants, and boundary conditions match a previous execution on the same target tensor. This approach is completely memory-safe via a weakref.WeakKeyDictionary caching pattern on the target tensor.
1. Implement .dat_version Tracking in PyOP2 Dat and Global
Files to modify: pyop2/types/dat.py (and/or pyop2/types/abstract.py depending on PyOP2 architecture)
# Inside the AbstractDat or Base class (or added specifically to Dat and Global classes):classAbstractDat(object):
def__init__(self, *args, **kwargs):
# Existing initialization logic...self._dat_version=0@propertydefdat_version(self):
returnself._dat_version@propertydefdata(self):
# Increment version whenever mutable data access is invokedself._dat_version+=1returnself._data_setter_or_buffer# Existing PyOP2 logic returning the numpy/PETSc array pointer
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Note
Disclaimer: This implementation plan was formulated by a core Firedrake developer in collaboration with Gemini.
Summary of Implementation Plan: Avoiding Reassembly into the Same Tensor
This plan introduces a change to PyOP2 to track state changes in global/scalar datasets (
Global) alongside standardDatdependencies. TheParloopAssemblerruntime is then updated to leverage these versions, allowing it to skip core execution loops when variational forms, coefficients, constants, and boundary conditions match a previous execution on the same target tensor. This approach is completely memory-safe via aweakref.WeakKeyDictionarycaching pattern on the target tensor.1. Implement
.dat_versionTracking in PyOP2DatandGlobalpyop2/types/dat.py(and/orpyop2/types/abstract.pydepending on PyOP2 architecture)2. Implement the Assembly Signature Helper
firedrake/assemble.py3. Integrate
WeakKeyDictionaryCache intoParloopAssemblerfiredrake/assemble.pyBeta Was this translation helpful? Give feedback.
All reactions