Skip to content

Commit

Permalink
Add direct .so backdoor capability, and XDSL_SKIP_CLEAN env variable …
Browse files Browse the repository at this point in the history
…to skip temp file cleanup.
  • Loading branch information
PapyChacal committed Aug 7, 2023
1 parent 0895c4e commit 5ff217d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions devito/operator/xdsl_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from io import StringIO

from devito.exceptions import InvalidOperator
from devito.logger import perf
from devito.logger import perf, info
from devito.ir.iet import Callable, MetaCall
from devito.ir.support import SymbolRegistry
from devito.operator.operator import IRs
Expand Down Expand Up @@ -62,8 +62,9 @@ class XDSLOperator(Operator):

def __new__(cls, expressions, **kwargs):
self = super(XDSLOperator, cls).__new__(cls, expressions, **kwargs)
self._tf = tempfile.NamedTemporaryFile(prefix="devito-jit-", suffix='.so')
self._interop_tf = tempfile.NamedTemporaryFile(prefix="devito-jit-interop-", suffix=".o")
delete=not os.getenv("XDSL_SKIP_CLEAN", False)
self._tf = tempfile.NamedTemporaryFile(prefix="devito-jit-", suffix='.so', delete=delete)
self._interop_tf = tempfile.NamedTemporaryFile(prefix="devito-jit-interop-", suffix=".o", delete=delete)
self._make_interop_o()
self.__class__ = cls
return self
Expand Down Expand Up @@ -140,6 +141,10 @@ def _jit_compile(self):
# allow jit backdooring to provide your own xdsl code
backdoor = os.getenv('XDSL_JIT_BACKDOOR')
if backdoor is not None:
if os.path.splitext(backdoor)[1] == ".so":
info(f"JIT Backdoor: skipping compilation and using {backdoor}")
self._tf.name = backdoor
return
print("JIT Backdoor: loading xdsl file from: " + backdoor)
with open(backdoor, 'r') as f:
module_str = f.read()
Expand Down

0 comments on commit 5ff217d

Please sign in to comment.