Skip to content

Commit

Permalink
data:init
Browse files Browse the repository at this point in the history
  • Loading branch information
georgebisbas committed Aug 3, 2023
1 parent e54cd7b commit a6217b8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
8 changes: 4 additions & 4 deletions devito/data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion devito/data/decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion devito/data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 11 additions & 9 deletions fast/wave3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[:]
Expand All @@ -140,14 +140,17 @@ 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]))
print("Devito linalg norm 1:", np.linalg.norm(u.data[1]))
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
Expand All @@ -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)
print("XDSL output linalg norm 2:", np.linalg.norm(u.data[2]))

0 comments on commit a6217b8

Please sign in to comment.