Skip to content

Commit 1993722

Browse files
committed
fusion: Change the way SLOPE is accessed
1 parent 551c188 commit 1993722

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

pyop2/fusion/extended.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"""Classes for fusing parallel loops and for executing fused parallel loops,
3535
derived from ``base.py``."""
3636

37+
import sys
3738
import os
3839
import ctypes
3940
from copy import deepcopy as dcopy
@@ -471,15 +472,12 @@ def compile(self):
471472
raise RuntimeError("JITModule not in cache, but has no args associated")
472473

473474
# Set compiler and linker options
474-
slope_dir = os.environ['SLOPE_DIR']
475475
self._kernel._name = 'executor'
476476
self._kernel._headers.extend(slope.Executor.meta['headers'])
477477
if self._use_prefetch:
478478
self._kernel._headers.extend(['#include "xmmintrin.h"'])
479-
self._kernel._include_dirs.extend(['%s/%s' % (slope_dir,
480-
slope.get_include_dir())])
481-
self._libraries += ['-L%s/%s' % (slope_dir, slope.get_lib_dir()),
482-
'-l%s' % slope.get_lib_name()]
479+
self._kernel._include_dirs.extend(['%s/include/SLOPE' % sys.prefix])
480+
self._libraries += ['-L%s/lib' % sys.prefix, '-l%s' % slope.get_lib_name()]
483481
compiler = coffee.system.compiler.get('name')
484482
self._cppargs += slope.get_compile_opts(compiler)
485483
fun = super(TilingJITModule, self).compile()

pyop2/fusion/interface.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,11 @@
4141

4242
from pyop2.base import _LazyMatOp
4343
from pyop2.mpi import MPI
44-
from pyop2.logger import warning, info as log_info
44+
from pyop2.logger import warning, debug
4545
from pyop2.utils import flatten
4646

4747
try:
48-
"""Is SLOPE accessible ?"""
49-
sys.path.append(os.path.join(os.environ['SLOPE_DIR'], 'python'))
50-
import slope_python as slope
51-
52-
# Set the SLOPE backend
48+
from pyslope import slope
5349
backend = os.environ.get('SLOPE_BACKEND')
5450
if backend not in ['SEQUENTIAL', 'OMP']:
5551
backend = 'SEQUENTIAL'
@@ -59,8 +55,8 @@
5955
if backend == 'OMP':
6056
backend = 'OMP_MPI'
6157
slope.set_exec_mode(backend)
62-
log_info("SLOPE backend set to %s" % backend)
63-
except:
58+
debug("SLOPE backend set to %s" % backend)
59+
except ImportError:
6460
slope = None
6561

6662
lazy_trace_name = 'lazy_trace'

pyop2/fusion/transformer.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
"""Core loop fusion mechanisms."""
3535

36+
import sys
3637
import os
3738
from collections import OrderedDict, namedtuple
3839
from copy import deepcopy as dcopy
@@ -399,14 +400,11 @@ def _tile(self):
399400
rettype = slope.Executor.meta['py_ctype_exec']
400401

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

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

0 commit comments

Comments
 (0)