Skip to content
Merged
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os

model = ARGUMENTS.get('MODEL')
root_dir = ARGUMENTS.get('ROOT')
root_include_dir = ARGUMENTS.get('ROOTINC')
core_dir = ARGUMENTS.get('COREDIR')
build_dir = ARGUMENTS.get('BUILD')

if core_dir is None:
core_dir = build_dir

env = Environment(
tools=['default', 'mingw'],
CPPPATH=[
Dir(f'{root_include_dir}/include'),
Dir(f'{root_include_dir}/external/ANN/include'),
],
LIBPATH=[
Dir(f'{core_dir}/lib'),
],
ENV=os.environ,
# When MSVC (or any other compilers) are supported, update this to be a compiler-specific flag
CXXFLAGS=['-std=c++14'],
)
env.VariantDir(core_dir, f'{root_dir}/src', duplicate=False)
env.VariantDir(f'{core_dir}/external/ANN', f'{root_dir}/external/ANN/src', duplicate=False)

Export('env')
ann = SConscript(f'{root_dir}/external/ANN/src/SConscript', variant_dir=f'{core_dir}/external/ANN', duplicate=False)
core = SConscript(f'{root_dir}/src/SConscript', variant_dir=core_dir, duplicate=False)

env.StaticLibrary(f'{core_dir}/lib/spatialpy-core', core)
env.StaticLibrary(f'{core_dir}/lib/ANN', ann)
env.Program('ssa_sdpd.exe', model, LIBS=['spatialpy-core', 'ANN', 'pthread'])

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Import('env')
libANN = env.Object([
'ANN.cpp',
'brute.cpp',
'kd_tree.cpp',
'kd_util.cpp',
'kd_split.cpp',
'kd_dump.cpp',
'kd_search.cpp',
'kd_pr_search.cpp',
'kd_fix_rad_search.cpp',
'bd_tree.cpp',
'bd_search.cpp',
'bd_pr_search.cpp',
'bd_fix_rad_search.cpp',
'perf.cpp'
])
Return('libANN')
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Import('env')
libspatialpy_core = env.Object([
'count_cores.cpp',
'model.cpp',
'NRMConstant_v5.cpp',
'output.cpp',
'particle.cpp',
'pthread_barrier.cpp',
'simulate.cpp',
'simulate_rdme.cpp',
'simulate_threads.cpp'
])
Return('libspatialpy_core')
49 changes: 17 additions & 32 deletions spatialpy/solvers/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import time
import getpass
import re
import sys

import numpy

Expand Down Expand Up @@ -66,7 +67,7 @@ def __init__(self, model, debug_level=0):
self.build_dir = None
self.propfilename = None
self.prop_file_name = None
self.executable_name = 'ssa_sdpd'
self.executable_name = 'ssa_sdpd.exe'
self.h = None # basis function width

self.spatialpy_root = os.path.dirname(
Expand Down Expand Up @@ -470,51 +471,35 @@ def compile(self, debug=False, profile=False):
self.__create_propensity_file(stoich_matrix, dep_graph, file_name=self.prop_file_name)

# Build the solver
for make_exe_location in ["make", "mingw32-make"]:
make_exe = shutil.which("make")
if make_exe is not None:
break
if make_exe is None:
raise SimulationError("Make executable could not be found")
makefile = self.spatialpy_rootdir+'/build/Makefile'
makefile_ann = self.spatialpy_rootdir+'/external/ANN/src/Makefile.spatialpy'

cmd_ann = [
make_exe, '-d', '-C', self.core_dir, '-f', makefile_ann,
f'ROOTINC={self.spatialpy_rootinc}',
]
cmd_core = [
make_exe, '-d', '-C', self.core_dir, 'CORE', '-f', makefile,
makefile = self.spatialpy_rootdir+'/build/SConstruct'
make_cmd = [
sys.executable, "-m", "SCons", f"-C{self.build_dir}", f"-f{makefile}",
f'ROOT={self.spatialpy_rootparam}',
f'ROOTINC={self.spatialpy_rootinc}',
f'BUILD={self.core_dir}',
]
cmd_build = [
make_exe, '-d', '-C', self.build_dir, '-I', self.core_dir, '-f', makefile,
'ROOT=' + self.spatialpy_rootparam,
'ROOTINC=' + self.spatialpy_rootinc,
'COREDIR=' + self.core_dir,
'MODEL=' + self.prop_file_name, 'BUILD='+self.build_dir
f'COREDIR={self.core_dir}',
f'MODEL={self.prop_file_name}',
f'BUILD={self.build_dir}',
]
if profile:
cmd_build.append('GPROFFLAG=-pg')
# TODO: add profile/debug targets to SConstruct file
make_cmd.append('GPROFFLAG=-pg')
if profile or debug:
cmd_build.append('GDB_FLAG=-g')
make_cmd.append('GDB_FLAG=-g')
if self.debug_level > 1:
cmd = " && ".join([*cmd_ann, *cmd_core, *cmd_build])
cmd = " ".join(make_cmd)
print(f"cmd: {cmd}\n")
try:
for cmd_target in [cmd_ann, cmd_core, cmd_build]:
result = subprocess.check_output(cmd_target, stderr=subprocess.STDOUT)
if self.debug_level > 1:
print(result.stdout.decode("utf-8"))
result = subprocess.check_output(make_cmd, stderr=subprocess.STDOUT)
if self.debug_level > 1:
print(result)
except subprocess.CalledProcessError as err:
try:
print(err.stdout.decode("utf-8"))
except Exception:
pass
raise SimulationError(f"Compilation of solver failed, return_code={result.return_code}")
raise SimulationError(f"Compilation of solver failed, return_code={err.returncode}")
except OSError as err:
cmd = " ".join(make_cmd)
print(f"Error, execution of compilation raised an exception: {err}")
print(f"cmd = {cmd}")
raise SimulationError("Compilation of solver failed") from err
Expand Down