Skip to content

Commit e97b87a

Browse files
committed
add todos and clean
1 parent d1464b9 commit e97b87a

3 files changed

Lines changed: 9 additions & 24 deletions

File tree

devito/petsc/iet/logging.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ def calls(self):
9696
# TODO: Perform a PetscCIntCast here?
9797
for i in output_params:
9898
if isinstance(i, KSPType):
99-
# KSPType is `const char*` into KSP-owned memory. After
100-
# SNESDestroy that pointer is invalid, so we copy the string
101-
# into the inline char buffer in the profiler struct instead
102-
# of storing the raw pointer.
99+
# Copy string otherwise it is invalid after SNESDestroy
103100
calls.append(
104101
petsc_call('PetscStrncpy', [
105102
FieldFromPointer(i._C_symbol, struct),

devito/petsc/iet/passes.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ def lower_petsc(iet, **kwargs):
7373
# Protect PETSc solve targets from being dropped by `_drop_if_unwritten`.
7474
# `lower_petsc` runs before `mpiize`, replacing `PetscMetaData` (an
7575
# `Expression` subclass whose `.write` reveals the target function) with
76-
# `Call` nodes to run the PETSc solver. Once that happens, `_drop_if_unwritten` can no
77-
# longer see the target as written and incorrectly discards its `HaloSpot`. So we
78-
# compose `dist-drop-unwritten` with a guard that always returns
79-
# False for PETSc targets.
76+
# `Call` nodes to run the PETSc solver. Once that happens,
77+
# `_drop_if_unwritten` can no longer see the target as written and
78+
# incorrectly discards its `HaloSpot`. So we compose `dist-drop-unwritten`
79+
# with a guard that always returns False for PETSc targets.
8080
options = kwargs['options']
8181
petsc_targets = {n.write for n in data if n.write is not None}
8282
if petsc_targets:
@@ -128,12 +128,6 @@ def lower_petsc(iet, **kwargs):
128128
populate_matrix_context(efuncs)
129129

130130
# Strip HaloSpots from PETSc callback efuncs before returning them.
131-
# The callbacks are built via rcompile(..., mpi=False), so HaloSpots
132-
# survive in their IETs but are NOT converted to haloupdate calls there.
133-
# When the main mpiize pass (mpi=True) later processes these callbacks,
134-
# it would convert those HaloSpots into haloupdate calls — which is wrong,
135-
# since halo exchanges must only happen in the main kernel. Strip them here
136-
# before they reach mpiize.
137131
for name, efunc in list(efuncs.items()):
138132
if isinstance(efunc, PETScCallable):
139133
halos = FindNodes(HaloSpot).visit(efunc)
@@ -157,10 +151,7 @@ def strip_petsc_callback_halos(iet, **kwargs):
157151
Remove any HaloSpot nodes that `mpiize` may have injected into PETSc
158152
callback functions (FormFunction, SetPointBCs, FormRHS, etc.).
159153
160-
HaloSpots should only appear in the main kernel, never inside PETSc
161-
callbacks which run as part of the PETSc solver internals. All
162-
PETSc callbacks are instances of `PETScCallable`; the main kernel is
163-
not, so we use that to distinguish the two.
154+
HaloSpots should only appear in the main kernel.
164155
"""
165156
if not isinstance(iet, PETScCallable):
166157
return iet, {}
@@ -205,10 +196,9 @@ def linear_indices(iet, **kwargs):
205196

206197
tracker = Tracker('basic', dtype, kwargs['sregistry'])
207198

208-
# Exclude SubDomainSet backing functions from linearization: they must
209-
# remain as 2D array reads (border[n0][col]), not flat-indexed via a macro.
210-
# SubDomainSet subfunctions are identified by having a DefaultDimension
211-
# (sds_dim) among their dimensions.
199+
# TODO: CLEAN UP this is a hack
200+
# Exclude SubDomainSet backing functions from linearization - in SETPOINTBCS
201+
# I don't want to linearize the accesses to the SubDomainSet
212202
indexeds = [
213203
i for i in FindSymbols('indexeds').visit(iet)
214204
if not isinstance(i.function, LocalType)

devito/petsc/solve.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from devito.types.equation import PetscEq
22
from devito.tools import filter_ordered, as_tuple
33
from devito.types import Symbol, SteppingDimension, TimeDimension, Border
4-
from devito.operations.solve import eval_time_derivatives
54
from devito.symbolics import retrieve_functions, retrieve_dimensions
65

76
from devito.petsc.types import (
@@ -132,7 +131,6 @@ def linear_solve_args(self):
132131
target, exprs = next(iter(self.target_exprs.items()))
133132
exprs = as_tuple(exprs)
134133

135-
136134
# TODO: maybe move into a seprate class/method... or at least clean up
137135
stagger_bc = _stagger_constrain_bc(target)
138136
if stagger_bc is not None:

0 commit comments

Comments
 (0)