Skip to content

Commit

Permalink
Merge pull request #285 from opesci/yask-integration-phase2
Browse files Browse the repository at this point in the history
Yask integration phase2
  • Loading branch information
FabioLuporini authored Jun 27, 2017
2 parents cad098f + 888d6e6 commit 26466e6
Show file tree
Hide file tree
Showing 9 changed files with 553 additions and 44 deletions.
29 changes: 29 additions & 0 deletions devito/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
from tempfile import gettempdir
from time import time
from sys import platform
import subprocess

import numpy.ctypeslib as npct
from codepy.jit import extension_file_from_string
from codepy.toolchain import GCCToolchain

from devito.exceptions import CompilationError
from devito.logger import log
from devito.tools import change_directory

__all__ = ['get_tmp_dir', 'set_compiler', 'jit_compile', 'load', 'GNUCompiler']

Expand Down Expand Up @@ -275,3 +278,29 @@ def jit_compile(ccode, compiler=GNUCompiler):
log("%s: compiled %s [%.2f s]" % (compiler, src_file, toc-tic))

return basename


def make(loc, args):
"""
Invoke ``make`` command from within ``loc`` with arguments ``args``.
"""
hash_key = sha1(loc + str(args).encode()).hexdigest()
logfile = path.join(get_tmp_dir(), "%s.log" % hash_key)
errfile = path.join(get_tmp_dir(), "%s.err" % hash_key)

with change_directory(loc):
with open(logfile, "w") as log:
with open(errfile, "w") as err:

command = ['make'] + args
log.write("Compilation command:\n")
log.write(" ".join(command))
log.write("\n\n")
try:
subprocess.check_call(command, stderr=err, stdout=log)
except subprocess.CalledProcessError as e:
raise CompilationError('Command "%s" return error status %d. '
'Unable to compile code.\n'
'Compile log in %s\n'
'Compile errors in %s\n' %
(e.cmd, e.returncode, logfile, errfile))
1 change: 1 addition & 0 deletions devito/dle/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from devito.dle.inspection import * # noqa
from devito.dle.manipulation import * # noqa
from devito.dle.transformer import * # noqa
from devito.dle.backends import YaskGrid, init # noqa
2 changes: 1 addition & 1 deletion devito/dle/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from devito.dle.backends.basic import BasicRewriter # noqa
from devito.dle.backends.advanced import (DevitoRewriter, DevitoSpeculativeRewriter, # noqa
DevitoCustomRewriter) # noqa
from devito.dle.backends.yask import YaskRewriter # noqa
from devito.dle.backends.yask import * # noqa
Loading

0 comments on commit 26466e6

Please sign in to comment.