Skip to content

Commit

Permalink
fusion: Change the way SLOPE is accessed
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioLuporini committed Jul 22, 2016
1 parent 551c188 commit 1993722
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
8 changes: 3 additions & 5 deletions pyop2/fusion/extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"""Classes for fusing parallel loops and for executing fused parallel loops,
derived from ``base.py``."""

import sys
import os
import ctypes
from copy import deepcopy as dcopy
Expand Down Expand Up @@ -471,15 +472,12 @@ def compile(self):
raise RuntimeError("JITModule not in cache, but has no args associated")

# Set compiler and linker options
slope_dir = os.environ['SLOPE_DIR']
self._kernel._name = 'executor'
self._kernel._headers.extend(slope.Executor.meta['headers'])
if self._use_prefetch:
self._kernel._headers.extend(['#include "xmmintrin.h"'])
self._kernel._include_dirs.extend(['%s/%s' % (slope_dir,
slope.get_include_dir())])
self._libraries += ['-L%s/%s' % (slope_dir, slope.get_lib_dir()),
'-l%s' % slope.get_lib_name()]
self._kernel._include_dirs.extend(['%s/include/SLOPE' % sys.prefix])
self._libraries += ['-L%s/lib' % sys.prefix, '-l%s' % slope.get_lib_name()]
compiler = coffee.system.compiler.get('name')
self._cppargs += slope.get_compile_opts(compiler)
fun = super(TilingJITModule, self).compile()
Expand Down
12 changes: 4 additions & 8 deletions pyop2/fusion/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,11 @@

from pyop2.base import _LazyMatOp
from pyop2.mpi import MPI
from pyop2.logger import warning, info as log_info
from pyop2.logger import warning, debug
from pyop2.utils import flatten

try:
"""Is SLOPE accessible ?"""
sys.path.append(os.path.join(os.environ['SLOPE_DIR'], 'python'))
import slope_python as slope

# Set the SLOPE backend
from pyslope import slope
backend = os.environ.get('SLOPE_BACKEND')
if backend not in ['SEQUENTIAL', 'OMP']:
backend = 'SEQUENTIAL'
Expand All @@ -59,8 +55,8 @@
if backend == 'OMP':
backend = 'OMP_MPI'
slope.set_exec_mode(backend)
log_info("SLOPE backend set to %s" % backend)
except:
debug("SLOPE backend set to %s" % backend)
except ImportError:
slope = None

lazy_trace_name = 'lazy_trace'
Expand Down
10 changes: 4 additions & 6 deletions pyop2/fusion/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

"""Core loop fusion mechanisms."""

import sys
import os
from collections import OrderedDict, namedtuple
from copy import deepcopy as dcopy
Expand Down Expand Up @@ -399,14 +400,11 @@ def _tile(self):
rettype = slope.Executor.meta['py_ctype_exec']

# Compiler and linker options
slope_dir = os.environ['SLOPE_DIR']
compiler = coffee.system.compiler.get('name')
cppargs = slope.get_compile_opts(compiler)
cppargs += ['-I%s/%s' % (slope_dir, slope.get_include_dir())]
ldargs = ['-L%s/%s' % (slope_dir, slope.get_lib_dir()),
'-l%s' % slope.get_lib_name(),
'-Wl,-rpath,%s/%s' % (slope_dir, slope.get_lib_dir()),
'-lrt']
cppargs += ['-I%s/include/SLOPE' % sys.prefix]
ldargs = ['-L%s/lib' % sys.prefix, '-l%s' % slope.get_lib_name(),
'-Wl,-rpath,%s/lib' % sys.prefix, '-lrt']

# Compile and run inspector
fun = compilation.load(src, "cpp", "inspector", cppargs, ldargs,
Expand Down

0 comments on commit 1993722

Please sign in to comment.