Skip to content

Commit

Permalink
mpi: Drop redundant check and defs
Browse files Browse the repository at this point in the history
  • Loading branch information
georgebisbas committed Jun 5, 2023
1 parent 6152ca6 commit 958579c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
6 changes: 3 additions & 3 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
14 changes: 5 additions & 9 deletions devito/mpi/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from ctypes import c_int, c_void_p, sizeof
from itertools import groupby, product
from math import ceil, pow
from sympy import root, primefactors
from sympy import primefactors

import atexit

Expand Down Expand Up @@ -618,26 +618,22 @@ class CustomTopology(tuple):
def __new__(cls, items, input_comm):
# Keep track of nstars and already defined decompositions
nstars = len([i for i in items if i == '*'])
alloc_procs = np.prod([i for i in items if i != '*'])
remprocs = int(input_comm.size // alloc_procs)

# If no stars exist we are ready
if nstars == 0:
processed = items
# If all inputs are stars, and nstars root exists slice as evenly as possible
elif nstars == len(items) and root(remprocs, nstars).is_Integer:
dd = root(remprocs, nstars)
processed = as_tuple([int(dd) for i in range(nstars)])
# Process nstars > 0
else:
# Init decomposition list
processed = [1] * len(items)

# Get star and ints positions
# Get star and integer indices
int_pos = [i for i, item in enumerate(items) if isinstance(item, int)]
int_vals = [item for item in items if isinstance(item, int)]
star_pos = [i for i, item in enumerate(items) if not isinstance(item, int)]

# Decompose the processes remaining for allocation to prime factors
alloc_procs = np.prod([i for i in items if i != '*'])
remprocs = int(input_comm.size // alloc_procs)
prime_factors = primefactors(remprocs)

star_i = -1
Expand Down

0 comments on commit 958579c

Please sign in to comment.