Skip to content

Commit 27c3822

Browse files
committed
misc: More clean up
1 parent 198b040 commit 27c3822

10 files changed

Lines changed: 21 additions & 37 deletions

File tree

devito/data/decomposition.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,10 @@ def index_glb_to_loc_unsafe(self, glb_idx, rel=True):
465465
loc_abs_max = self.loc_abs_max
466466
glb_max = self.glb_max
467467

468-
base = loc_abs_min if rel else 0
469468
glb_min = 0
470469

470+
base = loc_abs_min if rel else 0
471+
471472
# index_glb_to_loc(index)
472473
# -> Base case, empty local subdomain
473474
if self.loc_empty:
@@ -476,9 +477,7 @@ def index_glb_to_loc_unsafe(self, glb_idx, rel=True):
476477
if glb_idx < 0:
477478
glb_idx = glb_max + glb_idx + 1
478479
# -> Do the actual conversion
479-
if loc_abs_min <= glb_idx <= loc_abs_max:
480-
return glb_idx - base
481-
elif glb_min <= glb_idx <= glb_max:
480+
if loc_abs_min <= glb_idx <= loc_abs_max or glb_min <= glb_idx <= glb_max:
482481
return glb_idx - base
483482
else:
484483
# This should raise an exception when used to access a numpy.array

devito/ir/equations/equation.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@ def detect(cls, expr):
107107
ReduceMin: OpMin,
108108
PetscEq: OpPetsc
109109
}
110-
# try:
111-
# return reduction_mapper[type(expr)]
112-
# except KeyError:
113-
# pass
114110

115111
for expr_type, op in reduction_mapper.items():
116112
if isinstance(expr, expr_type):

devito/operator/operator.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,7 @@ def _lower_exprs(cls, expressions, **kwargs):
369369
# in particular uniqueness across expressions is ensured
370370
expressions = concretize_subdims(expressions, **kwargs)
371371

372-
# rename etc
373372
expressions = lower_exprs_petsc(expressions, **kwargs)
374-
# from IPython import embed; embed()
375373

376374
processed = [LoweredEq(i) for i in expressions]
377375

devito/passes/iet/linearization.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def linearize(graph, **kwargs):
2525

2626
mode = options.get('linearize')
2727
maybe_callback = kwargs.pop('callback', mode)
28-
# from IPython import embed; embed()
28+
2929
if not maybe_callback:
3030
return
3131
elif callable(maybe_callback):
@@ -230,7 +230,6 @@ def linearize_accesses(iet, key0, tracker=None):
230230
continue
231231

232232
v = generate_linearization(f, i, tracker)
233-
234233
if v is not None:
235234
subs[i] = v
236235

@@ -240,7 +239,7 @@ def linearize_accesses(iet, key0, tracker=None):
240239
# E.g. `{x_fsz0 -> u_vec->size[1]}`
241240
defines = FindSymbols('defines').visit(iet)
242241
offers = filter_ordered(i for i in defines if key0(i.function))
243-
# from IPython import embed; embed()
242+
244243
instances = {}
245244
for i in offers:
246245
f = i.function
@@ -295,7 +294,7 @@ def linearize_accesses(iet, key0, tracker=None):
295294
if stmts:
296295
body = iet.body._rebuild(strides=stmts)
297296
iet = iet._rebuild(body=body)
298-
# from IPython import embed; embed()
297+
299298
return iet
300299

301300

devito/petsc/equations.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def lower_exprs_petsc(expressions, **kwargs):
1818

1919
def constrain_essential_bcs(expressions, **kwargs):
2020
"""
21-
NOTE:
2221
"""
2322
sregistry = kwargs['sregistry']
2423
new_exprs = []
@@ -37,7 +36,7 @@ def constrain_essential_bcs(expressions, **kwargs):
3736
space_dims = [d for d in all_dims if isinstance(d, SpaceDimension)]
3837

3938
mapper = {}
40-
# from IPython import embed; embed()
39+
4140
for d in subdims:
4241
halo = halo_size[d]
4342

@@ -69,8 +68,7 @@ def constrain_essential_bcs(expressions, **kwargs):
6968
symbolic_max=Min(space_dim_max, d.symbolic_max + halo.right),
7069
)
7170

72-
# Apply mapper to all expressions
73-
# from IPython import embed; embed()
71+
# Apply mapper to expressions
7472
for e in expressions:
7573
if not isinstance(e, ConstrainBC):
7674
new_exprs.append(e)

devito/petsc/iet/builder.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def __init__(self, **kwargs):
2323
self.callback_builder = kwargs.get('callback_builder')
2424
self.field_data = self.inject_solve.expr.rhs.field_data
2525
self.formatted_prefix = self.inject_solve.expr.rhs.formatted_prefix
26-
# self.calls = self._setup()
2726

2827
@cached_property
2928
def calls(self):
@@ -40,7 +39,6 @@ def snes_ctx(self):
4039
def _setup(self):
4140
sobjs = self.solver_objs
4241
dmda = sobjs['dmda']
43-
# mainctx = sobjs['userctx']
4442

4543
snes_create = petsc_call('SNESCreate', [sobjs['comm'], Byref(sobjs['snes'])])
4644

@@ -110,8 +108,6 @@ def _setup(self):
110108
mat_set_dm = petsc_call('MatSetDM', [sobjs['Jac'], dmda])
111109

112110
base_setup = dmda_calls + (
113-
# call_struct_callback,
114-
# calls_set_app_ctx,
115111
snes_create,
116112
snes_options_prefix,
117113
set_options,
@@ -337,7 +333,6 @@ def _setup(self):
337333
snes_set_options,
338334
call_struct_callback,
339335
mat_set_dm,
340-
# calls_set_app_ctx,
341336
create_field_decomp,
342337
matop_create_submats_op,
343338
call_coupled_struct_callback,
@@ -378,9 +373,6 @@ def _create_dmda_calls(self, dmda):
378373
'DMGetLocalSection', [dmda, Byref(sobjs['lsection'])]
379374
)
380375

381-
import cgen as c
382-
tmp = c.Line("PetscCall(PetscSectionView(lsection0, NULL));")
383-
384376
get_point_sf = petsc_call('DMGetPointSF', [dmda, Byref(sobjs['sf'])])
385377

386378
create_global_section = petsc_call(
@@ -414,7 +406,6 @@ def _create_dmda_calls(self, dmda):
414406
count_bcs,
415407
set_point_bcs,
416408
get_local_section,
417-
tmp,
418409
get_point_sf,
419410
create_global_section,
420411
dm_set_global_section,
@@ -426,7 +417,7 @@ class ConstrainedBCBuilder(ConstrainedBCMixin, BuilderBase):
426417
pass
427418

428419

429-
# TODO: Implement this properly
420+
# TODO: Implement this class properly
430421
class CoupledConstrainedBCBuilder(ConstrainedBCMixin, CoupledBuilder):
431422
pass
432423

devito/petsc/iet/callbacks.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,11 @@ def _create_initial_guess_body(self, body):
645645
return Uxreplace(subs).visit(body)
646646

647647
def _make_constrain_bc(self):
648+
"""
649+
To constrain essential boundary nodes, two additional callbacks are
650+
required - this function generates the two new efuncs `CountBCs` and
651+
`SetPointBCs`.
652+
"""
648653
increment_exprs = self.field_data.constrain_bc.increment_exprs
649654
point_bc_exprs = self.field_data.constrain_bc.point_bc_exprs
650655
sobjs = self.solver_objs
@@ -694,7 +699,7 @@ def _create_count_bc_body(self, body):
694699
'DMGetApplicationContext', [dmda, Byref(ctx._C_symbol)]
695700
)
696701

697-
# OBVS change names
702+
# TODO: change names
698703
deref_ptr = DummyExpr(Counter, Deref(sobjs['numBCPtr']))
699704
move_ptr = DummyExpr(Deref(sobjs['numBCPtr']), Counter)
700705

devito/petsc/iet/passes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ def lower_petsc_symbols(iet, **kwargs):
137137

138138
@iet_pass
139139
def linear_indices(iet, **kwargs):
140-
140+
"""
141+
"""
141142
if not iet.name.startswith("SetPointBCs"):
142143
return iet, {}
143144

devito/petsc/types/metadata.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -786,14 +786,8 @@ def _make_point_bc_expr(self, expr):
786786
Make the Eq that is used to increment the number of essential
787787
boundary nodes in the generated ccode.
788788
"""
789-
# numBC = PetscInt(name='numBC2')
790789
if isinstance(expr, EssentialBC):
791790
assert expr.lhs == self.target
792-
# return PointEssentialBC(
793-
# Counter, self.target,
794-
# subdomain=expr.subdomain,
795-
# target=self.target
796-
# )
797791
return PointEssentialBC(
798792
Counter, self.target,
799793
subdomain=expr.subdomain,

devito/types/misc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ def bind(self, pname):
152152

153153
@property
154154
def linear_index(self):
155+
"""
156+
"""
155157
f = self.function
156158
strides_map = self.strides_map
157159
indices = self.indices
@@ -170,8 +172,9 @@ def linear_index(self):
170172
__reduce_ex__ = Pickable.__reduce_ex__
171173

172174

173-
# the special postindex type sould live in this file i think
174175
class PostIncrementIndex(LocalObject):
176+
"""
177+
"""
175178
dtype = np.int32
176179

177180

0 commit comments

Comments
 (0)