Skip to content

Commit

Permalink
misc: Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ZoeLeibowitz committed Sep 4, 2024
1 parent 7ee7856 commit 6208a69
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions devito/ir/iet/nodes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""The Iteration/Expression Tree (IET) hierarchy."""

import abc
import ctypes
import inspect
from functools import cached_property
from collections import OrderedDict, namedtuple
Expand Down Expand Up @@ -1059,6 +1060,7 @@ def functions(self):
def expr_symbols(self):
ret = []
if self.pointer.is_Object:
assert issubclass(self.pointer._C_ctype, ctypes._Pointer)
ret.extend([self.pointer._C_symbol, self.pointee._C_symbol])
elif self.pointer.is_PointerArray or self.pointer.is_TempFunction:
ret.extend([self.pointer.indexed, self.pointee.indexed])
Expand Down
13 changes: 8 additions & 5 deletions devito/petsc/iet/routines.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,13 @@ def create_matvec_body(self, injectsolve, body, solver_objs, objs):
dmda, solver_objs['Y_local'], 'INSERT_VALUES', solver_objs['Y_global']
])

# NOTE: Question: I have placed a chunk of the calls in the `stacks` argument
# of the `CallableBody` to ensure that these calls precede the `cast` statements.
# The 'casts' depend on the calls, so this order is necessary. By doing this,
# I avoid having to manually construct the 'casts' and can allow Devito to handle
# their construction. Are there any potential issues with this approach?
# TODO: Some of the calls are placed in the `stacks` argument of the
# `CallableBody` to ensure that they precede the `cast` statements. The
# 'casts' depend on the calls, so this order is necessary. By doing this,
# you avoid having to manually construct the `casts` and can allow
# Devito to handle their construction. This is a temporary solution and
# should be revisited

body = [body,
vec_restore_array_y,
vec_restore_array_x,
Expand Down Expand Up @@ -402,6 +404,7 @@ def runsolve(self, solver_objs, objs, rhs_callback, injectsolve):

def build_petsc_struct(iet, name, liveness):
# Place all context data required by the shell routines into a struct
# TODO: Clean this search up
basics = FindSymbols('basics').visit(iet)
avoid0 = [i for i in FindSymbols('indexedbases').visit(iet)
if isinstance(i.function, PETScArray)]
Expand Down
3 changes: 1 addition & 2 deletions devito/petsc/types/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
class PETScArray(ArrayBasic, Differentiable):
"""
PETScArrays are generated by the compiler only and represent
a customised variant of ArrayBasic. They are designed to
avoid generating a cast in the low-level code.
a customised variant of ArrayBasic.
Differentiable enables compatability with standard Function objects,
allowing for the use of the `subs` method.
TODO: Potentially re-evaluate and separate into PETScFunction(Differentiable)
Expand Down

0 comments on commit 6208a69

Please sign in to comment.