Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pyop3/compile/loopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,12 @@ def lower_expr(self, expr, iname_maps, loop_indices, *, intent=READ, paths=None)
def finalize_kernel(self, function_name, compiler_parameters):
preambles = [
("20_debug", "#include <stdio.h>"), # dont always inject
("30_petsc", "#include <petsc.h>"), # perhaps only if petsc callable used?
]
# The PETSc header takes most of the time needed to compile a small
# kernel, so we only include it if we have matrix arguments or local
# kernels (which may use PETSc types such as 'PetscScalar').
if self.subkernels or any(isinstance(arg.dtype, lp.types.OpaqueType) for arg in self.arguments):
preambles.append(("30_petsc", "#include <petsc.h>"))

# add a no-op instruction touching all of the kernel arguments so they are
# not silently dropped
Expand Down
3 changes: 2 additions & 1 deletion pyop3/compile/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ def with_attach_debugger(kernel):
debug_insn,
*(insn.copy(depends_on=insn.depends_on | {debug_insn.id}) for insn in kernel.instructions),
)
return kernel.copy(instructions=insns)
preambles = kernel.preambles + (("99_petscsys", "#include <petscsys.h>"),)
return kernel.copy(preambles=preambles, instructions=insns)
Loading