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

Fix the FormSum memory leak #3897

Merged
merged 12 commits into from
Dec 6, 2024
Prev Previous commit
Next Next commit
It looks like I have to add axpy also at glob
Ig-dolci committed Dec 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit bbf298e3428469feae477eb55416a46525782676
28 changes: 21 additions & 7 deletions pyop2/types/dat.py
Original file line number Diff line number Diff line change
@@ -499,13 +499,12 @@
:arg other: the :class:`Dat` to add to this one
Ig-dolci marked this conversation as resolved.
Show resolved Hide resolved

"""
for dat_result, dat_other in zip(self.split, other.split):
if isinstance(dat_result._data, np.ndarray):
np.add(
alpha * dat_other.data_ro, dat_result.data_ro,
out=dat_result.data_wo)
else:
raise NotImplementedError("Not implemented for GPU")
if isinstance(other._data, np.ndarray):
connorjward marked this conversation as resolved.
Show resolved Hide resolved
np.add(
alpha * other.data_ro, self.data_ro,
out=self.data_wo)
else:
raise NotImplementedError("Not implemented for GPU")

def __pos__(self):
pos = Dat(self)
@@ -1036,6 +1035,21 @@
for s, o in zip(self, other):
ret += s.inner(o)
return ret

Check failure on line 1038 in pyop2/types/dat.py

GitHub Actions / Run linter

W293

pyop2/types/dat.py:1038:1: W293 blank line contains whitespace
def axpy(self, alpha: float, other: 'MixedDat') -> None:
Ig-dolci marked this conversation as resolved.
Show resolved Hide resolved
"""Compute the operation :math:`y = \\alpha x + y`.

:arg alpha: a scalar
:arg other: the :class:`Dat` to add to this one
Ig-dolci marked this conversation as resolved.
Show resolved Hide resolved

"""
for dat_result, dat_other in zip(self, other):
connorjward marked this conversation as resolved.
Show resolved Hide resolved
if isinstance(dat_result._data, np.ndarray):
np.add(
alpha * dat_other.data_ro, dat_result.data_ro,
out=dat_result.data_wo)
else:
raise NotImplementedError("Not implemented for GPU")

def _op(self, other, op):
ret = []
9 changes: 9 additions & 0 deletions pyop2/types/glob.py
Original file line number Diff line number Diff line change
@@ -203,6 +203,15 @@
assert issubclass(type(other), type(self))
return np.dot(self.data_ro, np.conj(other.data_ro))

def axpy(self, alpha, other):
Ig-dolci marked this conversation as resolved.
Show resolved Hide resolved
"""Compute the operation :math:`y = \\alpha x + y`.
"""
JHopeCollins marked this conversation as resolved.
Show resolved Hide resolved
if isinstance(self._data, np.ndarray):
np.add(alpha * other.data_ro, self.data_ro,
out=self.data_wo)

Check failure on line 211 in pyop2/types/glob.py

GitHub Actions / Run linter

E128

pyop2/types/glob.py:211:17: E128 continuation line under-indented for visual indent
else:
raise NotImplementedError("Not implemented for GPU")


# must have comm, can be modified in parloop (implies a reduction)
class Global(SetFreeDataCarrier, VecAccessMixin):