Skip to content

Commit

Permalink
fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjward committed Dec 19, 2024
1 parent 8d2c32c commit b07d1dc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
8 changes: 6 additions & 2 deletions firedrake/preconditioners/fdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1835,13 +1835,17 @@ def setSubMatCSR(comm, triu=False):
return cache.setdefault(key, SparseAssembler.load_setSubMatCSR(comm, triu))

@staticmethod
def load_c_code(code, name, **kwargs):
def load_c_code(code, name, comm, argtypes, restype):
petsc_dir = get_petsc_dir()
cppargs = [f"-I{d}/include" for d in petsc_dir]
ldargs = ([f"-L{d}/lib" for d in petsc_dir]
+ [f"-Wl,-rpath,{d}/lib" for d in petsc_dir]
+ ["-lpetsc", "-lm"])
return load(code, "c", name, cppargs=cppargs, ldargs=ldargs, **kwargs)
dll = load(code, "c", cppargs=cppargs, ldargs=ldargs, comm=comm)
fn = getattr(dll, name)
fn.argtypes = argtypes
fn.restype = restype
return fn

@staticmethod
def load_setSubMatCSR(comm, triu=False):
Expand Down
13 changes: 7 additions & 6 deletions firedrake/preconditioners/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,12 +505,13 @@ def load_c_function(code, name, comm):
ldargs = (["-L%s/lib" % d for d in get_petsc_dir()]
+ ["-Wl,-rpath,%s/lib" % d for d in get_petsc_dir()]
+ ["-lpetsc", "-lm"])
return load(code, "c", name,
argtypes=[ctypes.c_voidp, ctypes.c_int, ctypes.c_voidp,
ctypes.c_voidp, ctypes.c_voidp, ctypes.c_int,
ctypes.c_voidp, ctypes.c_voidp, ctypes.c_voidp],
restype=ctypes.c_int, cppargs=cppargs, ldargs=ldargs,
comm=comm)
dll = load(code, "c", cppargs=cppargs, ldargs=ldargs, comm=comm)
fn = getattr(dll, name)
fn.argtypes = [ctypes.c_voidp, ctypes.c_int, ctypes.c_voidp,
ctypes.c_voidp, ctypes.c_voidp, ctypes.c_int,
ctypes.c_voidp, ctypes.c_voidp, ctypes.c_voidp]
fn.restype = ctypes.c_int
return fn


def make_c_arguments(form, kernel, state, get_map, require_state=False,
Expand Down
9 changes: 5 additions & 4 deletions firedrake/supermeshing.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,14 +432,15 @@ def likely(cell_A):
includes = ["-I%s/include" % d for d in dirs]
libs = ["-L%s/lib" % d for d in dirs]
libs = libs + ["-Wl,-rpath,%s/lib" % d for d in dirs] + ["-lpetsc", "-lsupermesh"]
lib = load(
supermesh_kernel_str, "c", "supermesh_kernel",
dll = load(
supermesh_kernel_str, "c",
cppargs=includes,
ldargs=libs,
argtypes=[ctypes.c_voidp, ctypes.c_voidp, ctypes.c_voidp, ctypes.c_voidp, ctypes.c_voidp, ctypes.c_voidp, ctypes.c_voidp],
restype=ctypes.c_int,
comm=mesh_A._comm
)
lib = getattr(dll, "supermesh_kernel")
lib.argtypes = [ctypes.c_voidp, ctypes.c_voidp, ctypes.c_voidp, ctypes.c_voidp, ctypes.c_voidp, ctypes.c_voidp, ctypes.c_voidp]
lib.restype = ctypes.c_int

ammm(V_A, V_B, likely, node_locations_A, node_locations_B, M_SS, ctypes.addressof(lib), mat)
if orig_value_size == 1:
Expand Down

0 comments on commit b07d1dc

Please sign in to comment.