Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #690 from OP2/JDBetteridge/global_fix
Browse files Browse the repository at this point in the history
Add comm to Global constructor in dat op
  • Loading branch information
JDBetteridge authored Feb 14, 2023
2 parents 3748115 + 1c6068a commit 233f6dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pyop2/types/dat.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def _op(self, other, op):

ret = Dat(self.dataset, None, self.dtype)
if np.isscalar(other):
other = Global(1, data=other)
other = Global(1, data=other, comm=self.comm)
globalp = True
else:
self._check_shape(other)
Expand Down Expand Up @@ -403,7 +403,7 @@ def _iop(self, other, op):

globalp = False
if np.isscalar(other):
other = Global(1, data=other)
other = Global(1, data=other, comm=self.comm)
globalp = True
elif other is not self:
self._check_shape(other)
Expand Down Expand Up @@ -450,7 +450,7 @@ def inner(self, other):
from pyop2.types.glob import Global

self._check_shape(other)
ret = Global(1, data=0, dtype=self.dtype)
ret = Global(1, data=0, dtype=self.dtype, comm=self.comm)
parloop(self._inner_kernel(other.dtype), self.dataset.set,
self(Access.READ), other(Access.READ), ret(Access.INC))
return ret.data_ro[0]
Expand Down
3 changes: 3 additions & 0 deletions pyop2/types/glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ def __init__(self, dim, data=None, dtype=None, name=None, comm=None):
EmptyDataMixin.__init__(self, data, dtype, self._dim)
self._buf = np.empty(self.shape, dtype=self.dtype)
self._name = name or "global_#x%x" % id(self)
if comm is None:
import warnings
warnings.warn("PyOP2.Global has no comm, this is likely to break in parallel!")
self.comm = mpi.internal_comm(comm)
# Object versioning setup
petsc_counter = (comm and self.dtype == PETSc.ScalarType)
Expand Down

0 comments on commit 233f6dc

Please sign in to comment.