Skip to content

Commit

Permalink
compiler: remove redundant subgrid check and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Sep 20, 2023
1 parent 441de0f commit ab160dd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
6 changes: 3 additions & 3 deletions devito/ir/stree/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ def preprocess(clusters, options=None, **kwargs):
found = []
for c1 in list(queue):
distributed_aindices = c1.halo_scheme.distributed_aindices
h_indices = set().union(*[(d, d.root)
for d in c1.halo_scheme.loc_indices])
h_indices = set().union(*[d._defines for d in c1.halo_scheme.loc_indices])

# Skip if the Halo echange would end up outside its need iteration space
# Skip if the halo exchange would end up outside
# its iteration space
if h_indices and not h_indices & dims:
continue

Expand Down
4 changes: 1 addition & 3 deletions devito/operator/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ def _prepare_arguments(self, autotune=None, **kwargs):
if len(discretizations) > 1:
discretizations = {g for g in discretizations
if not any(d.is_Derived for d in g.dimensions)}

for i in discretizations:
args.update(i._arg_values(**kwargs))

Expand All @@ -590,9 +591,6 @@ def _prepare_arguments(self, autotune=None, **kwargs):
if configuration['mpi']:
raise ValueError("Multiple Grids found")
try:
# Take biggest grid, i.e discard grids with subdimensions
grids = {g for g in grids if not any(d.is_Sub for d in g.dimensions)}
# First grid as there is no heuristic on how to choose from the leftovers
grid = grids.pop()
except KeyError:
grid = None
Expand Down
12 changes: 5 additions & 7 deletions devito/passes/iet/langbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ def DeviceIteration(self):
def Prodder(self):
return self.lang.Prodder

def _n_device_pointers(self, *args, **kwargs):
return 0
def _device_pointers(self, *args, **kwargs):
return {}


class DeviceAwareMixin(object):
Expand Down Expand Up @@ -328,11 +328,10 @@ def _(iet):

return _initialize(iet)

def _n_device_pointers(self, iet):
def _device_pointers(self, iet):
functions = FindSymbols().visit(iet)
devfuncs = [f for f in functions if f.is_Array and f._mem_local]

return len(devfuncs)
return set(devfuncs)

def _is_offloadable(self, iet):
"""
Expand All @@ -345,8 +344,7 @@ def _is_offloadable(self, iet):
functions = FindSymbols().visit(iet)
buffers = [f for f in functions if f.is_Array and f._mem_mapped]
hostfuncs = [f for f in functions if not is_on_device(f, self.gpu_fit)]

return not (hostfuncs and buffers)
return not (buffers and hostfuncs)


class Sections(tuple):
Expand Down
5 changes: 2 additions & 3 deletions devito/passes/iet/parpragma.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def _select_candidates(self, candidates):
# Iterations and their position (i.e. outermost to innermost) in the nest
score = (
int(root.is_ParallelNoAtomic),
self._n_device_pointers(root), # Outermost offloadable
len(self._device_pointers(root)), # Outermost offloadable
int(len([i for i in collapsable if i.is_ParallelNoAtomic]) >= 1),
int(len([i for i in collapsable if i.is_ParallelRelaxed]) >= 1),
-(n0 + 1) # The outermost, the better
Expand Down Expand Up @@ -375,15 +375,14 @@ def _make_partree(self, candidates, nthreads=None):
ncollapsed=ncollapsed, nthreads=nthreads,
**root.args)
prefix = []
elif all(i.is_ParallelRelaxed for i in candidates) and nthreads is not None:
elif nthreads is not None:
body = self.HostIteration(schedule='static',
parallel=nthreads is not self.nthreads_nested,
ncollapsed=ncollapsed, nthreads=nthreads,
**root.args)
prefix = []
else:
# pragma ... for ... schedule(..., expr)
assert nthreads is None
nthreads = self.nthreads_nonaffine
chunk_size = Symbol(name='chunk_size')
body = self.HostIteration(ncollapsed=ncollapsed, chunk_size=chunk_size,
Expand Down
4 changes: 2 additions & 2 deletions devito/types/dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ def symbolic_incr(self):
def bound_symbols(self):
return set(self.parent.bound_symbols)

def _arg_defaults(self, alias=None, **kwargs):
def _arg_defaults(self, **kwargs):
return {}

def _arg_values(self, *args, **kwargs):
Expand Down Expand Up @@ -1452,7 +1452,7 @@ def symbolic_max(self):
def _arg_names(self):
return (self.min_name, self.max_name, self.name) + self.parent._arg_names

def _arg_defaults(self, _min=None, size=None, **kwargs):
def _arg_defaults(self, _min=None, **kwargs):
"""
A map of default argument values defined by this dimension.
Expand Down

0 comments on commit ab160dd

Please sign in to comment.