From a6217b85ed75fce37c171123ac01d03164b7de9a Mon Sep 17 00:00:00 2001 From: George Bisbas Date: Thu, 3 Aug 2023 11:26:58 +0300 Subject: [PATCH] data:init --- devito/data/data.py | 8 ++++---- devito/data/decomposition.py | 2 +- devito/data/utils.py | 2 +- fast/wave3d.py | 20 +++++++++++--------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/devito/data/data.py b/devito/data/data.py index 046b162342..17d96d7a0b 100644 --- a/devito/data/data.py +++ b/devito/data/data.py @@ -37,11 +37,11 @@ class Data(np.ndarray): ----- NumPy array subclassing is described at: :: - https://docs.scipy.org/doc/numpy-1.13.0/user/basics.subclassing.html + https://numpy.org/doc/stable/user/basics.subclassing.html Any view or copy created from ``self``, for instance via a slice operation or a universal function ("ufunc" in NumPy jargon), will still be of type - Data. + `Data`. """ def __new__(cls, shape, dtype, decomposition=None, modulo=None, allocator=ALLOC_FLAT, @@ -224,7 +224,7 @@ def __getitem__(self, glb_idx, comm_type, gather_rank=None): glb_shape = self._distributor.glb_shape retval = np.zeros(glb_shape, dtype=self.dtype.type) start, stop, step = 0, 0, 1 - for i, s in enumerate(sendcounts): + for i, _ in enumerate(sendcounts): if i > 0: start += sendcounts[i-1] stop += sendcounts[i] @@ -591,4 +591,4 @@ class CommType(Tag): pass index_by_index = CommType('index_by_index') # noqa serial = CommType('serial') # noqa -gather = CommType('gather') # noqa +gather = CommType('gather') # noqa \ No newline at end of file diff --git a/devito/data/decomposition.py b/devito/data/decomposition.py index 2bb3faf797..471c11a992 100644 --- a/devito/data/decomposition.py +++ b/devito/data/decomposition.py @@ -531,4 +531,4 @@ def reshape(self, *args): # Renumbering items = [i + nleft for i in items] - return Decomposition(items, self.local) + return Decomposition(items, self.local) \ No newline at end of file diff --git a/devito/data/utils.py b/devito/data/utils.py index c854ee81e4..ac9dab63b3 100644 --- a/devito/data/utils.py +++ b/devito/data/utils.py @@ -469,4 +469,4 @@ def distributed_data_size(shape, coords, topology): p_dat = cshape[left_neighbours[j]][j] # Previous length n_dat.append(c_dat+p_dat) cshape[my_coords] = as_tuple(n_dat) - return cshape + return cshape \ No newline at end of file diff --git a/fast/wave3d.py b/fast/wave3d.py index 4dd3647cd6..6fb437ff78 100644 --- a/fast/wave3d.py +++ b/fast/wave3d.py @@ -121,12 +121,12 @@ def plot_3dfunc(u): if args.plot: plot_3dfunc(u) -devito_norm = norm(u) -print("Init linalg norm 0 (inlined) :", norm(u)) -print("Init linalg norm 0 :", np.linalg.norm(u.data[0])) -print("Init linalg norm 1 :", np.linalg.norm(u.data[1])) -print("Init linalg norm 2 :", np.linalg.norm(u.data[2])) -print("Norm of initial data:", np.linalg.norm(u.data[:])) +# devito_norm = norm(u) +# print("Init linalg norm 0 (inlined) :", norm(u)) +print("Init linalg norm 0 :", np.linalg.norm(u.data[0]), + "Init linalg norm 1 :", np.linalg.norm(u.data[1]), + "Init linalg norm 2 :", np.linalg.norm(u.data[2]), + "Norm of initial data:", np.linalg.norm(u.data[:])) configuration['mpi'] = 0 u2.data[:] = u.data[:] @@ -140,6 +140,9 @@ def plot_3dfunc(u): if args.plot: plot_3dfunc(u) +# import os + +# os.environ['DEVITO_MPI'] = '1' #devito_output = u.data[:] print("After Operator 1: Devito norm:", np.linalg.norm(u.data[:])) print("Devito linalg norm 0:", np.linalg.norm(u.data[0])) @@ -147,7 +150,7 @@ def plot_3dfunc(u): print("Devito linalg norm 2:", np.linalg.norm(u.data[2])) # Reset initial data -configuration['mpi'] = 0 +# configuration['mpi'] = 0 u.data[:] = u2.data[:] configuration['mpi'] = 'basic' #v[:, ..., :] = 1 @@ -167,5 +170,4 @@ def plot_3dfunc(u): print(f"xdsl output norm: {norm(xdsl_output)}") print("XDSL output linalg norm 0:", np.linalg.norm(u.data[0])) print("XDSL output linalg norm 1:", np.linalg.norm(u.data[1])) -print("XDSL output linalg norm 2:", np.linalg.norm(u.data[2])) -print("devito-norm:", devito_norm) \ No newline at end of file +print("XDSL output linalg norm 2:", np.linalg.norm(u.data[2])) \ No newline at end of file