Compare commits
5 Commits
e0a05bbd1a
...
perf/openM
| Author | SHA1 | Date | |
|---|---|---|---|
| b6f452e74c | |||
| 7242c765f3 | |||
| d852ee43fe | |||
| ed2c1d5816 | |||
| 8a22496398 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -82,6 +82,7 @@ subprojects/cvode-*/
|
|||||||
subprojects/kinsol-*/
|
subprojects/kinsol-*/
|
||||||
subprojects/CLI11-*/
|
subprojects/CLI11-*/
|
||||||
subprojects/openssl-*/
|
subprojects/openssl-*/
|
||||||
|
subprojects/tomlplusplus-*/
|
||||||
*.fbundle
|
*.fbundle
|
||||||
*.wraplock
|
*.wraplock
|
||||||
|
|
||||||
@@ -98,6 +99,8 @@ liblogging.wrap
|
|||||||
libplugin.wrap
|
libplugin.wrap
|
||||||
minizip-ng.wrap
|
minizip-ng.wrap
|
||||||
openssl.wrap
|
openssl.wrap
|
||||||
|
glaze.wrap
|
||||||
|
tomlplusplus.wrap
|
||||||
|
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
@@ -121,3 +124,5 @@ meson-boost-test/
|
|||||||
*_pynucastro_network.py
|
*_pynucastro_network.py
|
||||||
|
|
||||||
cross/python_includes
|
cross/python_includes
|
||||||
|
|
||||||
|
*.whl
|
||||||
|
|||||||
0
build-check/CC/meson.build
Normal file
0
build-check/CC/meson.build
Normal file
33
build-check/CPPC/meson.build
Normal file
33
build-check/CPPC/meson.build
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
cppc = meson.get_compiler('cpp')
|
||||||
|
|
||||||
|
if cppc.get_id() == 'clang'
|
||||||
|
message('disabling bitwise-instead-of-logical warnings for clang')
|
||||||
|
add_project_arguments('-Wno-bitwise-instead-of-logical', language: 'cpp')
|
||||||
|
endif
|
||||||
|
|
||||||
|
if cppc.get_id() == 'gcc'
|
||||||
|
message('disabling psabi warnings for gcc')
|
||||||
|
add_project_arguments('-Wno-psabi', language: 'cpp')
|
||||||
|
|
||||||
|
if (cppc.version().version_compare('<14.0'))
|
||||||
|
error('g++ version must be at least 14.0, found ' + cppc.version())
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
if not cppc.has_header('print')
|
||||||
|
error('C++ standard library header <print> not found. Please ensure your compiler and standard library supports C++23. We have already validated your compiler version so this is likely an issue with your standard library installation.')
|
||||||
|
endif
|
||||||
|
if not cppc.has_header('format')
|
||||||
|
error('C++ standard library header <format> not found. Please ensure your compiler and standard library supports C++23. We have already validated your compiler version so this is likely an issue with your standard library installation.')
|
||||||
|
endif
|
||||||
|
|
||||||
|
# For Eigen
|
||||||
|
add_project_arguments('-Wno-deprecated-declarations', language: 'cpp')
|
||||||
|
|
||||||
|
if get_option('build_python')
|
||||||
|
message('enabling hidden visibility for C++ symbols when building Python extension. This reduces the size of the resulting shared library.')
|
||||||
|
add_project_arguments('-fvisibility=hidden', language: 'cpp')
|
||||||
|
else
|
||||||
|
message('enabling default visibility for C++ symbols')
|
||||||
|
add_project_arguments('-fvisibility=default', language: 'cpp')
|
||||||
|
endif
|
||||||
15
build-check/FC/meson.build
Normal file
15
build-check/FC/meson.build
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
if get_option('build_fortran')
|
||||||
|
add_languages('fortran', native: true)
|
||||||
|
message('Found FORTRAN compiler: ' + meson.get_compiler('fortran').get_id())
|
||||||
|
message('Fortran standard set to: ' + get_option('fortran_std'))
|
||||||
|
message('Building fortran module (gridfire_mod.mod)')
|
||||||
|
fc = meson.get_compiler('fortran')
|
||||||
|
if not get_option('unsafe_fortran')
|
||||||
|
if fc.get_id() != 'gcc'
|
||||||
|
error('The only supported fortran compiler for GridFire is gfortran (version >= 14.0), found ' + fc + '. GridFire has not been tested with any other compilers. You can disable this check with the -Dunsafe-fortran=true flag to try other compilers')
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if (fc.version().version_compare('<14.0'))
|
||||||
|
error('gfortran version must be at least 14.0, found ' + fc.version())
|
||||||
|
endif
|
||||||
|
endif
|
||||||
15
build-check/meson.build
Normal file
15
build-check/meson.build
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
message('Found CXX compiler: ' + meson.get_compiler('cpp').get_id())
|
||||||
|
message('C++ standard set to: ' + get_option('cpp_std'))
|
||||||
|
|
||||||
|
cc = meson.get_compiler('c')
|
||||||
|
|
||||||
|
ignore_unused_args = '-Wno-unused-command-line-argument'
|
||||||
|
|
||||||
|
add_global_arguments(ignore_unused_args, language: 'cpp')
|
||||||
|
add_global_arguments(ignore_unused_args, language: 'c')
|
||||||
|
|
||||||
|
|
||||||
|
subdir('CPPC')
|
||||||
|
subdir('FC')
|
||||||
|
|
||||||
|
|
||||||
@@ -1,17 +1,21 @@
|
|||||||
# bring in all of the fourdst utility repositories
|
# bring in all of the fourdst utility repositories
|
||||||
|
|
||||||
fourdst_build_lib_all = true
|
fourdst_build_lib_all = true
|
||||||
if get_option('unity-safe')
|
if not get_option('plugin_support')
|
||||||
fourdst_build_lib_all=false
|
fourdst_build_lib_all=false
|
||||||
|
message('Disabling fourdst plugin support as per user request.')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
fourdst_sp = subproject('fourdst',
|
fourdst_sp = subproject('fourdst',
|
||||||
default_options:
|
default_options:
|
||||||
['build-tests=' + get_option('build-tests').to_string(),
|
['build_tests=' + get_option('build_tests').to_string(),
|
||||||
'build-python=' + get_option('build-python').to_string(),
|
'build_python=' + get_option('build_python').to_string(),
|
||||||
'build-lib-all=' + fourdst_build_lib_all.to_string(),
|
'build_lib_all=' + fourdst_build_lib_all.to_string(),
|
||||||
'pkg-config=' + get_option('pkg-config').to_string(),
|
'build_lib_comp=true',
|
||||||
'build-lib-log=true'
|
'build_lib_config=true',
|
||||||
|
'build_lib_log=true',
|
||||||
|
'build_lib_const=true',
|
||||||
|
'pkg_config=' + get_option('pkg_config').to_string(),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,15 +23,16 @@ composition_dep = fourdst_sp.get_variable('composition_dep')
|
|||||||
log_dep = fourdst_sp.get_variable('log_dep')
|
log_dep = fourdst_sp.get_variable('log_dep')
|
||||||
const_dep = fourdst_sp.get_variable('const_dep')
|
const_dep = fourdst_sp.get_variable('const_dep')
|
||||||
config_dep = fourdst_sp.get_variable('config_dep')
|
config_dep = fourdst_sp.get_variable('config_dep')
|
||||||
if not get_option('unity-safe')
|
if get_option('plugin_support')
|
||||||
|
warning('Including plugin library from fourdst. Note this will bring in minizip-ng and openssl, which can cause build issues with cross compilation due to their complexity.')
|
||||||
plugin_dep = fourdst_sp.get_variable('plugin_dep')
|
plugin_dep = fourdst_sp.get_variable('plugin_dep')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
libcomposition = fourdst_sp.get_variable('libcomposition')
|
libcomposition = fourdst_sp.get_variable('libcomposition')
|
||||||
libconst = fourdst_sp.get_variable('libconst')
|
libconst = fourdst_sp.get_variable('libconst')
|
||||||
libconfig = fourdst_sp.get_variable('libconfig')
|
|
||||||
liblogging = fourdst_sp.get_variable('liblogging')
|
liblogging = fourdst_sp.get_variable('liblogging')
|
||||||
|
|
||||||
if not get_option('unity-safe')
|
if get_option('plugin_support')
|
||||||
|
warning('Including plugin library from fourdst. Note this will bring in minizip-ng and openssl, which can cause build issues with cross compilation due to their complexity.')
|
||||||
libplugin = fourdst_sp.get_variable('libplugin')
|
libplugin = fourdst_sp.get_variable('libplugin')
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
cmake = import('cmake')
|
cmake = import('cmake')
|
||||||
|
|
||||||
|
if get_option('build_python')
|
||||||
subdir('python')
|
subdir('python')
|
||||||
|
subdir('pybind')
|
||||||
|
endif
|
||||||
subdir('fourdst')
|
subdir('fourdst')
|
||||||
subdir('sundials')
|
subdir('sundials')
|
||||||
|
|
||||||
@@ -11,6 +13,5 @@ subdir('eigen')
|
|||||||
|
|
||||||
subdir('json')
|
subdir('json')
|
||||||
|
|
||||||
subdir('pybind')
|
|
||||||
|
|
||||||
subdir('CLI11')
|
subdir('CLI11')
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ cvode_cmake_options.add_cmake_defines({
|
|||||||
'CMAKE_C_FLAGS' : '-Wno-deprecated-declarations',
|
'CMAKE_C_FLAGS' : '-Wno-deprecated-declarations',
|
||||||
'BUILD_SHARED_LIBS' : 'OFF',
|
'BUILD_SHARED_LIBS' : 'OFF',
|
||||||
'BUILD_STATIC_LIBS' : 'ON',
|
'BUILD_STATIC_LIBS' : 'ON',
|
||||||
'EXAMPLES_ENABLE_C': 'OFF',
|
'EXAMPLES_ENABLE_C' : 'OFF',
|
||||||
'CMAKE_POSITION_INDEPENDENT_CODE': true
|
'CMAKE_POSITION_INDEPENDENT_CODE': true
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -16,6 +16,15 @@ cvode_cmake_options.add_cmake_defines({
|
|||||||
'CMAKE_INSTALL_INCLUDEDIR': get_option('includedir')
|
'CMAKE_INSTALL_INCLUDEDIR': get_option('includedir')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if meson.is_cross_build() and host_machine.system() == 'emscripten'
|
||||||
|
cvode_cmake_options.add_cmake_defines({
|
||||||
|
'CMAKE_C_FLAGS': '-s MEMORY64=1 -s ALLOW_MEMORY_GROWTH=1',
|
||||||
|
'CMAKE_CXX_FLAGS': '-s MEMORY64=1 -s ALLOW_MEMORY_GROWTH=1',
|
||||||
|
'CMAKE_SHARED_LINKER_FLAGS': '-s MEMORY64=1 -s ALLOW_MEMORY_GROWTH=1',
|
||||||
|
'CMAKE_EXE_LINKER_FLAGS': '-s MEMORY64=1 -s ALLOW_MEMORY_GROWTH=1'
|
||||||
|
})
|
||||||
|
endif
|
||||||
|
|
||||||
cvode_sp = cmake.subproject(
|
cvode_sp = cmake.subproject(
|
||||||
'cvode',
|
'cvode',
|
||||||
options: cvode_cmake_options,
|
options: cvode_cmake_options,
|
||||||
|
|||||||
32
build-extra/log-level/meson.build
Normal file
32
build-extra/log-level/meson.build
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
llevel = get_option('log_level')
|
||||||
|
|
||||||
|
logbase='QUILL_COMPILE_ACTIVE_LOG_LEVEL_'
|
||||||
|
|
||||||
|
if (llevel == 'traceL3')
|
||||||
|
message('Setting log level to TRACE_L3')
|
||||||
|
log_argument = logbase + 'TRACE_L3'
|
||||||
|
elif (llevel == 'traceL2')
|
||||||
|
message('Setting log level to TRACE_L2')
|
||||||
|
log_argument = logbase + 'TRACE_L2'
|
||||||
|
elif (llevel == 'traceL1')
|
||||||
|
message('Setting log level to TRACE_L1')
|
||||||
|
log_argument = logbase + 'TRACE_L1'
|
||||||
|
elif (llevel == 'debug')
|
||||||
|
message('Setting log level to DEBUG')
|
||||||
|
log_argument = logbase + 'DEBUG'
|
||||||
|
elif (llevel == 'info')
|
||||||
|
message('Setting log level to INFO')
|
||||||
|
log_argument = logbase + 'INFO'
|
||||||
|
elif (llevel == 'warning')
|
||||||
|
message('Setting log level to WARNING')
|
||||||
|
log_argument = logbase + 'WARNING'
|
||||||
|
elif (llevel == 'error')
|
||||||
|
message('Setting log level to ERROR')
|
||||||
|
log_argument = logbase + 'ERROR'
|
||||||
|
elif (llevel == 'critical')
|
||||||
|
message('Setting log level to CRITICAL')
|
||||||
|
log_argument = logbase + 'CRITICAL'
|
||||||
|
endif
|
||||||
|
|
||||||
|
log_argument = '-DQUILL_COMPILE_ACTIVE_LOG_LEVEL=' + log_argument
|
||||||
|
add_project_arguments(log_argument, language: 'cpp')
|
||||||
18
build-extra/pkg-config/meson.build
Normal file
18
build-extra/pkg-config/meson.build
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
if get_option('pkg_config')
|
||||||
|
message('Generating pkg-config file for GridFire...')
|
||||||
|
pkg = import('pkgconfig')
|
||||||
|
pkg.generate(
|
||||||
|
name: 'gridfire',
|
||||||
|
description: 'GridFire nuclear reaction network solver',
|
||||||
|
version: meson.project_version(),
|
||||||
|
libraries: [
|
||||||
|
libgridfire,
|
||||||
|
libcomposition,
|
||||||
|
libconst,
|
||||||
|
liblogging
|
||||||
|
],
|
||||||
|
subdirs: ['gridfire'],
|
||||||
|
filebase: 'gridfire',
|
||||||
|
install_dir: join_paths(get_option('libdir'), 'pkgconfig')
|
||||||
|
)
|
||||||
|
endif
|
||||||
@@ -78,7 +78,7 @@ def fix_rpaths(binary_path):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
print(f"--- Error: Expected one argument (path to .so file), got {sys.argv}", file=sys.stderr)
|
print(f"--- Error: Expected one argument (path to .dylib/.so file), got {sys.argv}", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Get the file path directly from the command line argument
|
# Get the file path directly from the command line argument
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
|
if get_option('build_python')
|
||||||
|
message('Building Python bindings...')
|
||||||
|
|
||||||
gridfire_py_deps = [
|
gridfire_py_deps = [
|
||||||
py_dep,
|
py_dep,
|
||||||
pybind11_dep,
|
pybind11_dep,
|
||||||
const_dep,
|
const_dep,
|
||||||
config_dep,
|
config_dep,
|
||||||
composition_dep,
|
composition_dep,
|
||||||
gridfire_dep
|
gridfire_dep
|
||||||
]
|
]
|
||||||
|
|
||||||
py_sources = [
|
py_sources = [
|
||||||
meson.project_source_root() + '/src/python/bindings.cpp',
|
meson.project_source_root() + '/src/python/bindings.cpp',
|
||||||
meson.project_source_root() + '/src/python/types/bindings.cpp',
|
meson.project_source_root() + '/src/python/types/bindings.cpp',
|
||||||
meson.project_source_root() + '/src/python/partition/bindings.cpp',
|
meson.project_source_root() + '/src/python/partition/bindings.cpp',
|
||||||
@@ -29,7 +31,7 @@ py_sources = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
if meson.is_cross_build() and host_machine.system() == 'darwin'
|
if meson.is_cross_build() and host_machine.system() == 'darwin'
|
||||||
py_mod = shared_module(
|
py_mod = shared_module(
|
||||||
'_gridfire',
|
'_gridfire',
|
||||||
sources: py_sources,
|
sources: py_sources,
|
||||||
@@ -39,7 +41,7 @@ if meson.is_cross_build() and host_machine.system() == 'darwin'
|
|||||||
install: true,
|
install: true,
|
||||||
install_dir: py_installation.get_install_dir() + '/gridfire'
|
install_dir: py_installation.get_install_dir() + '/gridfire'
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
py_mod = py_installation.extension_module(
|
py_mod = py_installation.extension_module(
|
||||||
'_gridfire', # Name of the generated .so/.pyd file (without extension)
|
'_gridfire', # Name of the generated .so/.pyd file (without extension)
|
||||||
sources: py_sources,
|
sources: py_sources,
|
||||||
@@ -47,10 +49,10 @@ else
|
|||||||
install : true,
|
install : true,
|
||||||
subdir: 'gridfire',
|
subdir: 'gridfire',
|
||||||
)
|
)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
py_installation.install_sources(
|
py_installation.install_sources(
|
||||||
files(
|
files(
|
||||||
meson.project_source_root() + '/src/python/gridfire/__init__.py',
|
meson.project_source_root() + '/src/python/gridfire/__init__.py',
|
||||||
meson.project_source_root() + '/stubs/gridfire/_gridfire/__init__.pyi',
|
meson.project_source_root() + '/stubs/gridfire/_gridfire/__init__.pyi',
|
||||||
@@ -64,27 +66,30 @@ py_installation.install_sources(
|
|||||||
meson.project_source_root() + '/stubs/gridfire/_gridfire/type.pyi'
|
meson.project_source_root() + '/stubs/gridfire/_gridfire/type.pyi'
|
||||||
),
|
),
|
||||||
subdir: 'gridfire',
|
subdir: 'gridfire',
|
||||||
)
|
)
|
||||||
|
|
||||||
py_installation.install_sources(
|
py_installation.install_sources(
|
||||||
files(
|
files(
|
||||||
meson.project_source_root() + '/stubs/gridfire/_gridfire/engine/__init__.pyi',
|
meson.project_source_root() + '/stubs/gridfire/_gridfire/engine/__init__.pyi',
|
||||||
meson.project_source_root() + '/stubs/gridfire/_gridfire/engine/diagnostics.pyi',
|
meson.project_source_root() + '/stubs/gridfire/_gridfire/engine/diagnostics.pyi',
|
||||||
),
|
),
|
||||||
subdir: 'gridfire/engine',
|
subdir: 'gridfire/engine',
|
||||||
)
|
)
|
||||||
|
|
||||||
py_installation.install_sources(
|
py_installation.install_sources(
|
||||||
files(
|
files(
|
||||||
meson.project_source_root() + '/stubs/gridfire/_gridfire/utils/__init__.pyi',
|
meson.project_source_root() + '/stubs/gridfire/_gridfire/utils/__init__.pyi',
|
||||||
),
|
),
|
||||||
subdir: 'gridfire/utils',
|
subdir: 'gridfire/utils',
|
||||||
)
|
)
|
||||||
|
|
||||||
py_installation.install_sources(
|
py_installation.install_sources(
|
||||||
files(
|
files(
|
||||||
meson.project_source_root() + '/stubs/gridfire/_gridfire/utils/hashing/__init__.pyi',
|
meson.project_source_root() + '/stubs/gridfire/_gridfire/utils/hashing/__init__.pyi',
|
||||||
meson.project_source_root() + '/stubs/gridfire/_gridfire/utils/hashing/reaction.pyi',
|
meson.project_source_root() + '/stubs/gridfire/_gridfire/utils/hashing/reaction.pyi',
|
||||||
),
|
),
|
||||||
subdir: 'gridfire/utils/hashing',
|
subdir: 'gridfire/utils/hashing',
|
||||||
)
|
)
|
||||||
|
else
|
||||||
|
message('Python bindings disabled')
|
||||||
|
endif
|
||||||
|
|||||||
23
cross/wasm.ini
Normal file
23
cross/wasm.ini
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
[binaries]
|
||||||
|
c = 'emcc'
|
||||||
|
cpp = 'em++'
|
||||||
|
ar = 'emar'
|
||||||
|
strip = 'emstrip'
|
||||||
|
|
||||||
|
exec_wrapper = 'node'
|
||||||
|
|
||||||
|
[built-in options]
|
||||||
|
c_args = ['-Dpkg_config=false', '-Dbuild_tests=false', '-Dbuild_examples=true', '-Dbuild_fortran=falase', '-Dplugin_support=false', '-s', 'MEMORY64=1', '-pthread', '-DQUILL_NO_THREAD_NAME_SUPPORT', '-DQUILL_IMMEDIATE_FLUSH']
|
||||||
|
cpp_args = ['-Dpkg_config=false', '-Dbuild_tests=false', '-Dbuild_examples=true', '-Dbuild_fortran=falase', '-Dplugin_support=false', '-s', 'MEMORY64=1', '-pthread', '-DQUILL_NO_THREAD_NAME_SUPPORT', '-DQUILL_IMMEDIATE_FLUSH']
|
||||||
|
c_link_args = ['-s', 'WASM=1', '-s', 'ALLOW_MEMORY_GROWTH=1', '-s', 'MEMORY64=1', '-fwasm-exceptions', '-pthread', '-s', 'EXPORTED_RUNTIME_METHODS=["FS", "callMain"]', '-s', 'STACK_SIZE=10485760']
|
||||||
|
cpp_link_args = ['-s', 'WASM=1', '-s', 'ALLOW_MEMORY_GROWTH=1', '-s', 'MEMORY64=1', '-fwasm-exceptions', '-pthread', '-s', 'EXPORTED_RUNTIME_METHODS=["FS", "callMain"]', '-s', 'STACK_SIZE=10485760']
|
||||||
|
|
||||||
|
[host_machine]
|
||||||
|
system = 'emscripten'
|
||||||
|
cpu_family = 'wasm64'
|
||||||
|
cpu = 'wasm64'
|
||||||
|
endian = 'little'
|
||||||
|
|
||||||
|
[properties]
|
||||||
|
cmake_toolchain_file = '/home/tboudreaux/Programming/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake'
|
||||||
|
|
||||||
144
meson.build
144
meson.build
@@ -20,141 +20,27 @@
|
|||||||
# *********************************************************************** #
|
# *********************************************************************** #
|
||||||
project('GridFire', ['c', 'cpp'], version: 'v0.7.4_rc2', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0')
|
project('GridFire', ['c', 'cpp'], version: 'v0.7.4_rc2', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0')
|
||||||
|
|
||||||
if get_option('build-python')
|
# Start by running the code which validates the build environment
|
||||||
add_project_arguments('-fvisibility=hidden', language: 'cpp')
|
subdir('build-check')
|
||||||
else
|
|
||||||
add_project_arguments('-fvisibility=default', language: 'cpp')
|
|
||||||
endif
|
|
||||||
|
|
||||||
message('Found CXX compiler: ' + meson.get_compiler('cpp').get_id())
|
# Configure the logging level
|
||||||
message('C++ standard set to: ' + get_option('cpp_std'))
|
subdir('build-extra/log-level')
|
||||||
|
|
||||||
cppc = meson.get_compiler('cpp')
|
|
||||||
cc = meson.get_compiler('c')
|
|
||||||
|
|
||||||
|
|
||||||
if cppc.get_id() == 'clang'
|
|
||||||
message('disabling bitwise-instead-of-logical warnings for clang')
|
|
||||||
add_project_arguments('-Wno-bitwise-instead-of-logical', language: 'cpp')
|
|
||||||
endif
|
|
||||||
|
|
||||||
if cppc.get_id() == 'gcc'
|
|
||||||
message('disabling psabi warnings for gcc')
|
|
||||||
add_project_arguments('-Wno-psabi', language: 'cpp')
|
|
||||||
|
|
||||||
if (cppc.version().version_compare('<14.0'))
|
|
||||||
error('g++ version must be at least 14.0, found ' + cppc.version())
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
build_fortran = get_option('build-fortran')
|
|
||||||
if (build_fortran)
|
|
||||||
add_languages('fortran', native: true)
|
|
||||||
message('Found FORTRAN compiler: ' + meson.get_compiler('fortran').get_id())
|
|
||||||
message('Fortran standard set to: ' + get_option('fortran_std'))
|
|
||||||
message('Building fortran module (gridfire_mod.mod)')
|
|
||||||
fc = meson.get_compiler('fortran')
|
|
||||||
if not get_option('unsafe-fortran')
|
|
||||||
if fc.get_id() != 'gcc'
|
|
||||||
error('The only supported fortran compiler for GridFire is gfortran (version >= 14.0), found ' + fc + '. GridFire has not been tested with any other compilers. You can disable this check with the -Dunsafe-fortran=true flag to try other compilers')
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if (fc.version().version_compare('<14.0'))
|
|
||||||
error('gfortran version must be at least 14.0, found ' + fc.version())
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
if not cppc.has_header('print')
|
|
||||||
error('C++ standard library header <print> not found. Please ensure your compiler and standard library supports C++23. We have already validated your compiler version so this is likely an issue with your standard library installation.')
|
|
||||||
endif
|
|
||||||
if not cppc.has_header('format')
|
|
||||||
error('C++ standard library header <format> not found. Please ensure your compiler and standard library supports C++23. We have already validated your compiler version so this is likely an issue with your standard library installation.')
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
ignore_unused_args = '-Wno-unused-command-line-argument'
|
|
||||||
|
|
||||||
add_global_arguments(ignore_unused_args, language: 'cpp')
|
|
||||||
add_global_arguments(ignore_unused_args, language: 'c')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# For Eigen
|
|
||||||
add_project_arguments('-Wno-deprecated-declarations', language: 'cpp')
|
|
||||||
|
|
||||||
llevel = get_option('log-level')
|
|
||||||
|
|
||||||
logbase='QUILL_COMPILE_ACTIVE_LOG_LEVEL_'
|
|
||||||
|
|
||||||
if (llevel == 'traceL3')
|
|
||||||
message('Setting log level to TRACE_L3')
|
|
||||||
log_argument = logbase + 'TRACE_L3'
|
|
||||||
elif (llevel == 'traceL2')
|
|
||||||
message('Setting log level to TRACE_L2')
|
|
||||||
log_argument = logbase + 'TRACE_L2'
|
|
||||||
elif (llevel == 'traceL1')
|
|
||||||
message('Setting log level to TRACE_L1')
|
|
||||||
log_argument = logbase + 'TRACE_L1'
|
|
||||||
elif (llevel == 'debug')
|
|
||||||
message('Setting log level to DEBUG')
|
|
||||||
log_argument = logbase + 'DEBUG'
|
|
||||||
elif (llevel == 'info')
|
|
||||||
message('Setting log level to INFO')
|
|
||||||
log_argument = logbase + 'INFO'
|
|
||||||
elif (llevel == 'warning')
|
|
||||||
message('Setting log level to WARNING')
|
|
||||||
log_argument = logbase + 'WARNING'
|
|
||||||
elif (llevel == 'error')
|
|
||||||
message('Setting log level to ERROR')
|
|
||||||
log_argument = logbase + 'ERROR'
|
|
||||||
elif (llevel == 'critical')
|
|
||||||
message('Setting log level to CRITICAL')
|
|
||||||
log_argument = logbase + 'CRITICAL'
|
|
||||||
endif
|
|
||||||
|
|
||||||
log_argument = '-DQUILL_COMPILE_ACTIVE_LOG_LEVEL=' + log_argument
|
|
||||||
add_project_arguments(log_argument, language: 'cpp')
|
|
||||||
|
|
||||||
cpp = meson.get_compiler('cpp')
|
|
||||||
|
|
||||||
|
# Then build the external dependencies
|
||||||
subdir('build-config')
|
subdir('build-config')
|
||||||
|
|
||||||
|
# Build the main source code
|
||||||
subdir('src')
|
subdir('src')
|
||||||
|
|
||||||
if get_option('build-python')
|
# Build the Python bindings
|
||||||
message('Configuring Python bindings...')
|
subdir('build-python')
|
||||||
subdir('build-python')
|
|
||||||
else
|
|
||||||
message('Skipping Python bindings...')
|
|
||||||
endif
|
|
||||||
|
|
||||||
if get_option('build-tests')
|
# Buil the test suite
|
||||||
message('Setting up tests for GridFire...')
|
subdir('tests')
|
||||||
subdir('tests')
|
|
||||||
else
|
subdir('tools')
|
||||||
message('Skipping tests for GridFire...')
|
|
||||||
endif
|
# Build the pkg-config file
|
||||||
|
subdir('build-extra/pkg-config')
|
||||||
|
|
||||||
if get_option('pkg-config')
|
|
||||||
message('Generating pkg-config file for GridFire...')
|
|
||||||
pkg = import('pkgconfig')
|
|
||||||
pkg.generate(
|
|
||||||
name: 'gridfire',
|
|
||||||
description: 'GridFire nuclear reaction network solver',
|
|
||||||
version: meson.project_version(),
|
|
||||||
libraries: [
|
|
||||||
libgridfire,
|
|
||||||
libcomposition,
|
|
||||||
libconfig,
|
|
||||||
libconst,
|
|
||||||
liblogging
|
|
||||||
],
|
|
||||||
subdirs: ['gridfire'],
|
|
||||||
filebase: 'gridfire',
|
|
||||||
install_dir: join_paths(get_option('libdir'), 'pkgconfig')
|
|
||||||
)
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
option('log-level', type: 'combo', choices: ['traceL3', 'traceL2', 'traceL1', 'debug', 'info', 'warning', 'error', 'critial'], value: 'info', description: 'Set the log level for the GridFire library')
|
option('log_level', type: 'combo', choices: ['traceL3', 'traceL2', 'traceL1', 'debug', 'info', 'warning', 'error', 'critial'], value: 'info', description: 'Set the log level for the GridFire library')
|
||||||
option('pkg-config', type: 'boolean', value: true, description: 'generate pkg-config file for GridFire (gridfire.pc)')
|
option('pkg_config', type: 'boolean', value: true, description: 'generate pkg-config file for GridFire (gridfire.pc)')
|
||||||
option('build-python', type: 'boolean', value: false, description: 'build the python bindings so you can use GridFire from python')
|
option('build_python', type: 'boolean', value: false, description: 'build the python bindings so you can use GridFire from python')
|
||||||
option('build-tests', type: 'boolean', value: true, description: 'build the test suite')
|
option('build_tests', type: 'boolean', value: true, description: 'build the test suite')
|
||||||
option('build-fortran', type: 'boolean', value: false, description: 'build fortran module support')
|
option('build_examples', type: 'boolean', value: true, description: 'build example code')
|
||||||
option('unsafe-fortran', type: 'boolean', value: false, description: 'Allow untested fortran compilers (compilers other than gfortran)')
|
option('build_fortran', type: 'boolean', value: false, description: 'build fortran module support')
|
||||||
option('unity-safe', type: 'boolean', value: false, description: 'Enable safe unity builds for better compatibility across different compilers and platforms')
|
option('unsafe_fortran', type: 'boolean', value: false, description: 'Allow untested fortran compilers (compilers other than gfortran)')
|
||||||
option('python-target-version', type: 'string', value: '3.13', description: 'Target version for python compilation, only used for cross compilation')
|
option('plugin_support', type: 'boolean', value: false, description: 'Enable support for libplugin plugins')
|
||||||
|
option('python_target_version', type: 'string', value: '3.13', description: 'Target version for python compilation, only used for cross compilation')
|
||||||
|
option('build_c_api', type: 'boolean', value: true, description: 'compile the C API')
|
||||||
|
option('build_tools', type: 'boolean', value: true, description: 'build the GridFire command line tools')
|
||||||
|
|||||||
2
src/extern/meson.build
vendored
2
src/extern/meson.build
vendored
@@ -23,7 +23,7 @@ gridfire_extern_dep = declare_dependency(
|
|||||||
|
|
||||||
install_subdir('include/gridfire', install_dir: get_option('includedir'))
|
install_subdir('include/gridfire', install_dir: get_option('includedir'))
|
||||||
|
|
||||||
if get_option('build-fortran')
|
if get_option('build_fortran')
|
||||||
message('Configuring Fortran bindings...')
|
message('Configuring Fortran bindings...')
|
||||||
subdir('fortran')
|
subdir('fortran')
|
||||||
endif
|
endif
|
||||||
|
|||||||
35
src/include/gridfire/config/config.h
Normal file
35
src/include/gridfire/config/config.h
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "fourdst/config/config.h"
|
||||||
|
|
||||||
|
namespace gridfire::config {
|
||||||
|
struct CVODESolverConfig {
|
||||||
|
double absTol = 1.0e-8;
|
||||||
|
double relTol = 1.0e-5;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SolverConfig {
|
||||||
|
CVODESolverConfig cvode;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AdaptiveEngineViewConfig {
|
||||||
|
double relativeCullingThreshold = 1.0e-75;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EngineViewConfig {
|
||||||
|
AdaptiveEngineViewConfig adaptiveEngineView;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EngineConfig {
|
||||||
|
EngineViewConfig views;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GridFireConfig {
|
||||||
|
SolverConfig solver;
|
||||||
|
EngineConfig engine;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -53,7 +53,7 @@ namespace gridfire::engine {
|
|||||||
struct StepDerivatives {
|
struct StepDerivatives {
|
||||||
std::map<fourdst::atomic::Species, T> dydt{}; ///< Derivatives of abundances (dY/dt for each species).
|
std::map<fourdst::atomic::Species, T> dydt{}; ///< Derivatives of abundances (dY/dt for each species).
|
||||||
T nuclearEnergyGenerationRate = T(0.0); ///< Specific energy generation rate (e.g., erg/g/s).
|
T nuclearEnergyGenerationRate = T(0.0); ///< Specific energy generation rate (e.g., erg/g/s).
|
||||||
std::map<fourdst::atomic::Species, std::unordered_map<std::string, T>> reactionContributions{};
|
std::optional<std::map<fourdst::atomic::Species, std::unordered_map<std::string, T>>> reactionContributions = std::nullopt;
|
||||||
T neutrinoEnergyLossRate = T(0.0); // (erg/g/s)
|
T neutrinoEnergyLossRate = T(0.0); // (erg/g/s)
|
||||||
T totalNeutrinoFlux = T(0.0); // (neutrinos/g/s)
|
T totalNeutrinoFlux = T(0.0); // (neutrinos/g/s)
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "gridfire/screening/screening_types.h"
|
#include "gridfire/screening/screening_types.h"
|
||||||
#include "gridfire/partition/partition_abstract.h"
|
#include "gridfire/partition/partition_abstract.h"
|
||||||
#include "gridfire/engine/procedures/construction.h"
|
#include "gridfire/engine/procedures/construction.h"
|
||||||
|
#include "gridfire/config/config.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@@ -753,6 +754,14 @@ namespace gridfire::engine {
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
SpeciesStatus getSpeciesStatus(const fourdst::atomic::Species &species) const override;
|
SpeciesStatus getSpeciesStatus(const fourdst::atomic::Species &species) const override;
|
||||||
|
|
||||||
|
[[nodiscard]] bool get_store_intermediate_reaction_contributions() const {
|
||||||
|
return m_store_intermediate_reaction_contributions;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_store_intermediate_reaction_contributions(const bool value) {
|
||||||
|
m_store_intermediate_reaction_contributions = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PrecomputedReaction {
|
struct PrecomputedReaction {
|
||||||
@@ -847,7 +856,7 @@ namespace gridfire::engine {
|
|||||||
const GraphEngine& m_engine;
|
const GraphEngine& m_engine;
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
Config& m_config = Config::getInstance();
|
Config<config::GridFireConfig> m_config;
|
||||||
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
||||||
|
|
||||||
constants m_constants;
|
constants m_constants;
|
||||||
@@ -879,6 +888,7 @@ namespace gridfire::engine {
|
|||||||
|
|
||||||
bool m_usePrecomputation = true; ///< Flag to enable or disable using precomputed reactions for efficiency. Mathematically, this should not change the results. Generally end users should not need to change this.
|
bool m_usePrecomputation = true; ///< Flag to enable or disable using precomputed reactions for efficiency. Mathematically, this should not change the results. Generally end users should not need to change this.
|
||||||
bool m_useReverseReactions = true; ///< Flag to enable or disable reverse reactions. If false, only forward reactions are considered.
|
bool m_useReverseReactions = true; ///< Flag to enable or disable reverse reactions. If false, only forward reactions are considered.
|
||||||
|
bool m_store_intermediate_reaction_contributions = false; ///< Flag to enable or disable storing intermediate reaction contributions for debugging.
|
||||||
|
|
||||||
BuildDepthType m_depth;
|
BuildDepthType m_depth;
|
||||||
|
|
||||||
@@ -1207,7 +1217,10 @@ namespace gridfire::engine {
|
|||||||
const T nu_ij = static_cast<T>(reaction.stoichiometry(species));
|
const T nu_ij = static_cast<T>(reaction.stoichiometry(species));
|
||||||
const T dydt_increment = threshold_flag * molarReactionFlow * nu_ij;
|
const T dydt_increment = threshold_flag * molarReactionFlow * nu_ij;
|
||||||
dydt_vec[speciesIdx] += dydt_increment;
|
dydt_vec[speciesIdx] += dydt_increment;
|
||||||
result.reactionContributions[species][std::string(reaction.id())] = dydt_increment;
|
|
||||||
|
if (m_store_intermediate_reaction_contributions) {
|
||||||
|
result.reactionContributions.value()[species][std::string(reaction.id())] = dydt_increment;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "gridfire/screening/screening_abstract.h"
|
#include "gridfire/screening/screening_abstract.h"
|
||||||
#include "gridfire/screening/screening_types.h"
|
#include "gridfire/screening/screening_types.h"
|
||||||
#include "gridfire/types/types.h"
|
#include "gridfire/types/types.h"
|
||||||
|
#include "gridfire/config/config.h"
|
||||||
|
|
||||||
#include "fourdst/atomic/atomicSpecies.h"
|
#include "fourdst/atomic/atomicSpecies.h"
|
||||||
#include "fourdst/config/config.h"
|
#include "fourdst/config/config.h"
|
||||||
@@ -386,10 +387,10 @@ namespace gridfire::engine {
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] SpeciesStatus getSpeciesStatus(const fourdst::atomic::Species &species) const override;
|
[[nodiscard]] SpeciesStatus getSpeciesStatus(const fourdst::atomic::Species &species) const override;
|
||||||
private:
|
private:
|
||||||
using Config = fourdst::config::Config;
|
|
||||||
using LogManager = fourdst::logging::LogManager;
|
using LogManager = fourdst::logging::LogManager;
|
||||||
/** @brief A reference to the singleton Config instance, used for retrieving configuration parameters. */
|
|
||||||
Config& m_config = Config::getInstance();
|
fourdst::config::Config<config::GridFireConfig> m_config;
|
||||||
|
|
||||||
/** @brief A pointer to the logger instance, used for logging messages. */
|
/** @brief A pointer to the logger instance, used for logging messages. */
|
||||||
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include "gridfire/io/network_file.h"
|
#include "gridfire/io/network_file.h"
|
||||||
#include "gridfire/types/types.h"
|
#include "gridfire/types/types.h"
|
||||||
|
|
||||||
|
#include "gridfire/config/config.h"
|
||||||
|
|
||||||
#include "fourdst/config/config.h"
|
#include "fourdst/config/config.h"
|
||||||
#include "fourdst/logging/logging.h"
|
#include "fourdst/logging/logging.h"
|
||||||
|
|
||||||
@@ -365,9 +367,9 @@ namespace gridfire::engine {
|
|||||||
[[nodiscard]] std::string getNetworkFile() const { return m_fileName; }
|
[[nodiscard]] std::string getNetworkFile() const { return m_fileName; }
|
||||||
[[nodiscard]] const io::NetworkFileParser& getParser() const { return m_parser; }
|
[[nodiscard]] const io::NetworkFileParser& getParser() const { return m_parser; }
|
||||||
private:
|
private:
|
||||||
using Config = fourdst::config::Config;
|
using LogManager = LogManager;
|
||||||
using LogManager = fourdst::logging::LogManager;
|
Config<config::GridFireConfig> m_config;
|
||||||
Config& m_config = Config::getInstance();
|
|
||||||
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
||||||
std::string m_fileName;
|
std::string m_fileName;
|
||||||
///< Parser for the network file.
|
///< Parser for the network file.
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "fourdst/config/config.h"
|
#include "fourdst/config/config.h"
|
||||||
#include "fourdst/logging/logging.h"
|
#include "fourdst/logging/logging.h"
|
||||||
|
#include "gridfire/config/config.h"
|
||||||
|
|
||||||
#include "quill/Logger.h"
|
#include "quill/Logger.h"
|
||||||
|
|
||||||
@@ -101,9 +102,8 @@ namespace gridfire::io {
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] ParsedNetworkData parse(const std::string& filename) const override;
|
[[nodiscard]] ParsedNetworkData parse(const std::string& filename) const override;
|
||||||
private:
|
private:
|
||||||
using Config = fourdst::config::Config;
|
|
||||||
using LogManager = fourdst::logging::LogManager;
|
using LogManager = fourdst::logging::LogManager;
|
||||||
Config& m_config = Config::getInstance();
|
fourdst::config::Config<config::GridFireConfig> m_config;
|
||||||
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -141,9 +141,8 @@ namespace gridfire::io {
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] ParsedNetworkData parse(const std::string& filename) const override;
|
[[nodiscard]] ParsedNetworkData parse(const std::string& filename) const override;
|
||||||
private:
|
private:
|
||||||
using Config = fourdst::config::Config;
|
|
||||||
using LogManager = fourdst::logging::LogManager;
|
using LogManager = fourdst::logging::LogManager;
|
||||||
Config& m_config = Config::getInstance();
|
fourdst::config::Config<config::GridFireConfig> m_config;
|
||||||
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
||||||
|
|
||||||
std::string m_filename;
|
std::string m_filename;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "gridfire/engine/engine_abstract.h"
|
#include "gridfire/engine/engine_abstract.h"
|
||||||
#include "gridfire/types/types.h"
|
#include "gridfire/types/types.h"
|
||||||
#include "gridfire/exceptions/exceptions.h"
|
#include "gridfire/exceptions/exceptions.h"
|
||||||
|
#include "gridfire/config/config.h"
|
||||||
|
|
||||||
#include "fourdst/atomic/atomicSpecies.h"
|
#include "fourdst/atomic/atomicSpecies.h"
|
||||||
#include "fourdst/config/config.h"
|
#include "fourdst/config/config.h"
|
||||||
@@ -237,13 +238,13 @@ namespace gridfire::solver {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct CVODERHSOutputData {
|
struct CVODERHSOutputData {
|
||||||
std::map<fourdst::atomic::Species, std::unordered_map<std::string, double>> reaction_contribution_map;
|
std::optional<std::map<fourdst::atomic::Species, std::unordered_map<std::string, double>>> reaction_contribution_map;
|
||||||
double neutrino_energy_loss_rate;
|
double neutrino_energy_loss_rate;
|
||||||
double total_neutrino_flux;
|
double total_neutrino_flux;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
fourdst::config::Config& m_config = fourdst::config::Config::getInstance();
|
fourdst::config::Config<config::GridFireConfig> m_config;
|
||||||
quill::Logger* m_logger = fourdst::logging::LogManager::getInstance().getLogger("log");
|
quill::Logger* m_logger = fourdst::logging::LogManager::getInstance().getLogger("log");
|
||||||
/**
|
/**
|
||||||
* @brief CVODE RHS C-wrapper that delegates to calculate_rhs and captures exceptions.
|
* @brief CVODE RHS C-wrapper that delegates to calculate_rhs and captures exceptions.
|
||||||
|
|||||||
@@ -684,7 +684,7 @@ namespace gridfire::engine {
|
|||||||
// --- Efficient lookup of only the active reactions ---
|
// --- Efficient lookup of only the active reactions ---
|
||||||
uint64_t reactionHash = utils::hash_reaction(*reaction);
|
uint64_t reactionHash = utils::hash_reaction(*reaction);
|
||||||
const size_t reactionIndex = m_precomputedReactionIndexMap.at(reactionHash);
|
const size_t reactionIndex = m_precomputedReactionIndexMap.at(reactionHash);
|
||||||
PrecomputedReaction precomputedReaction = m_precomputedReactions[reactionIndex];
|
const PrecomputedReaction& precomputedReaction = m_precomputedReactions[reactionIndex];
|
||||||
|
|
||||||
// --- Forward abundance product ---
|
// --- Forward abundance product ---
|
||||||
double forwardAbundanceProduct = 1.0;
|
double forwardAbundanceProduct = 1.0;
|
||||||
@@ -697,12 +697,12 @@ namespace gridfire::engine {
|
|||||||
forwardAbundanceProduct = 0.0;
|
forwardAbundanceProduct = 0.0;
|
||||||
break; // No need to continue if one of the reactants has zero abundance
|
break; // No need to continue if one of the reactants has zero abundance
|
||||||
}
|
}
|
||||||
double factor = std::pow(comp.getMolarAbundance(reactant), power);
|
const double factor = std::pow(comp.getMolarAbundance(reactant), power);
|
||||||
if (!std::isfinite(factor)) {
|
if (!std::isfinite(factor)) {
|
||||||
LOG_CRITICAL(m_logger, "Non-finite factor encountered in forward abundance product for reaction '{}'. Check input abundances for validity.", reaction->id());
|
LOG_CRITICAL(m_logger, "Non-finite factor encountered in forward abundance product for reaction '{}'. Check input abundances for validity.", reaction->id());
|
||||||
throw exceptions::BadRHSEngineError("Non-finite factor encountered in forward abundance product.");
|
throw exceptions::BadRHSEngineError("Non-finite factor encountered in forward abundance product.");
|
||||||
}
|
}
|
||||||
forwardAbundanceProduct *= std::pow(comp.getMolarAbundance(reactant), power);
|
forwardAbundanceProduct *= factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const double bare_rate = bare_rates.at(reactionCounter);
|
const double bare_rate = bare_rates.at(reactionCounter);
|
||||||
@@ -764,8 +764,8 @@ namespace gridfire::engine {
|
|||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
|
|
||||||
double local_neutrino_loss = molarReactionFlows.back() * q_abs * neutrino_loss_fraction * m_constants.Na * m_constants.MeV_to_erg;
|
const double local_neutrino_loss = molarReactionFlows.back() * q_abs * neutrino_loss_fraction * m_constants.Na * m_constants.MeV_to_erg;
|
||||||
double local_neutrino_flux = molarReactionFlows.back() * m_constants.Na;
|
const double local_neutrino_flux = molarReactionFlows.back() * m_constants.Na;
|
||||||
|
|
||||||
result.totalNeutrinoFlux += local_neutrino_flux;
|
result.totalNeutrinoFlux += local_neutrino_flux;
|
||||||
result.neutrinoEnergyLossRate += local_neutrino_loss;
|
result.neutrinoEnergyLossRate += local_neutrino_loss;
|
||||||
@@ -782,7 +782,7 @@ namespace gridfire::engine {
|
|||||||
|
|
||||||
reactionCounter = 0;
|
reactionCounter = 0;
|
||||||
for (const auto& reaction: activeReactions) {
|
for (const auto& reaction: activeReactions) {
|
||||||
size_t j = m_precomputedReactionIndexMap.at(utils::hash_reaction(*reaction));
|
const size_t j = m_precomputedReactionIndexMap.at(utils::hash_reaction(*reaction));
|
||||||
const auto& precomp = m_precomputedReactions[j];
|
const auto& precomp = m_precomputedReactions[j];
|
||||||
const double R_j = molarReactionFlows[reactionCounter];
|
const double R_j = molarReactionFlows[reactionCounter];
|
||||||
|
|
||||||
@@ -793,9 +793,12 @@ namespace gridfire::engine {
|
|||||||
const int stoichiometricCoefficient = precomp.stoichiometric_coefficients[i];
|
const int stoichiometricCoefficient = precomp.stoichiometric_coefficients[i];
|
||||||
|
|
||||||
// Update the derivative for this species
|
// Update the derivative for this species
|
||||||
double dydt_increment = static_cast<double>(stoichiometricCoefficient) * R_j;
|
const double dydt_increment = static_cast<double>(stoichiometricCoefficient) * R_j;
|
||||||
result.dydt.at(species) += dydt_increment;
|
result.dydt.at(species) += dydt_increment;
|
||||||
result.reactionContributions[species][std::string(reaction->id())] = dydt_increment;
|
|
||||||
|
if (m_store_intermediate_reaction_contributions) {
|
||||||
|
result.reactionContributions.value()[species][std::string(reaction->id())] = dydt_increment;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reactionCounter++;
|
reactionCounter++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -394,7 +394,9 @@ namespace gridfire::engine {
|
|||||||
const double maxFlow
|
const double maxFlow
|
||||||
) const {
|
) const {
|
||||||
LOG_TRACE_L1(m_logger, "Culling reactions based on flow rates...");
|
LOG_TRACE_L1(m_logger, "Culling reactions based on flow rates...");
|
||||||
const auto relative_culling_threshold = m_config.get<double>("gridfire:AdaptiveEngineView:RelativeCullingThreshold", 1e-75);
|
|
||||||
|
const auto relative_culling_threshold = m_config->engine.views.adaptiveEngineView.relativeCullingThreshold;
|
||||||
|
|
||||||
double absoluteCullingThreshold = relative_culling_threshold * maxFlow;
|
double absoluteCullingThreshold = relative_culling_threshold * maxFlow;
|
||||||
LOG_DEBUG(m_logger, "Relative culling threshold: {:7.3E} ({:7.3E})", relative_culling_threshold, absoluteCullingThreshold);
|
LOG_DEBUG(m_logger, "Relative culling threshold: {:7.3E} ({:7.3E})", relative_culling_threshold, absoluteCullingThreshold);
|
||||||
std::vector<const reaction::Reaction*> culledReactions;
|
std::vector<const reaction::Reaction*> culledReactions;
|
||||||
|
|||||||
@@ -112,8 +112,8 @@ namespace gridfire::solver {
|
|||||||
// 2. If the user has set tolerances in code, those override the config
|
// 2. If the user has set tolerances in code, those override the config
|
||||||
// 3. If the user has not set tolerances in code and the config does not have them, use hardcoded defaults
|
// 3. If the user has not set tolerances in code and the config does not have them, use hardcoded defaults
|
||||||
|
|
||||||
auto absTol = m_config.get<double>("gridfire:solver:CVODESolverStrategy:absTol", 1.0e-8);
|
auto absTol = m_config->solver.cvode.absTol;
|
||||||
auto relTol = m_config.get<double>("gridfire:solver:CVODESolverStrategy:relTol", 1.0e-5);
|
auto relTol = m_config->solver.cvode.relTol;
|
||||||
|
|
||||||
if (m_absTol) {
|
if (m_absTol) {
|
||||||
absTol = *m_absTol;
|
absTol = *m_absTol;
|
||||||
@@ -935,8 +935,8 @@ namespace gridfire::solver {
|
|||||||
sunrealtype *y_data = N_VGetArrayPointer(m_Y);
|
sunrealtype *y_data = N_VGetArrayPointer(m_Y);
|
||||||
sunrealtype *y_err_data = N_VGetArrayPointer(m_YErr);
|
sunrealtype *y_err_data = N_VGetArrayPointer(m_YErr);
|
||||||
|
|
||||||
const auto absTol = m_config.get<double>("gridfire:solver:CVODESolverStrategy:absTol", 1.0e-8);
|
const auto absTol = m_config->solver.cvode.absTol;
|
||||||
const auto relTol = m_config.get<double>("gridfire:solver:CVODESolverStrategy:relTol", 1.0e-8);
|
const auto relTol = m_config->solver.cvode.relTol;
|
||||||
|
|
||||||
std::vector<double> err_ratios;
|
std::vector<double> err_ratios;
|
||||||
const size_t num_components = N_VGetLength(m_Y);
|
const size_t num_components = N_VGetLength(m_Y);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ gridfire_build_dependencies = [
|
|||||||
json_dep,
|
json_dep,
|
||||||
]
|
]
|
||||||
|
|
||||||
if not get_option('unity-safe')
|
if get_option('plugin_support')
|
||||||
gridfire_build_dependencies += [plugin_dep]
|
gridfire_build_dependencies += [plugin_dep]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -63,12 +63,11 @@ gridfire_dep = declare_dependency(
|
|||||||
|
|
||||||
install_subdir('include/gridfire', install_dir: get_option('includedir'))
|
install_subdir('include/gridfire', install_dir: get_option('includedir'))
|
||||||
|
|
||||||
message('Configuring C API...')
|
|
||||||
subdir('extern')
|
if not get_option('build_c_api') and get_option('build_fortran')
|
||||||
#
|
error('Cannot build fortran without C API. Set -Dbuild-c-api=true and -Dbuild-fortran=true')
|
||||||
#if get_option('build-python')
|
endif
|
||||||
# message('Configuring Python bindings...')
|
if get_option('build_c_api')
|
||||||
# subdir('python')
|
message('Configuring C API...')
|
||||||
#else
|
subdir('extern')
|
||||||
# message('Skipping Python bindings...')
|
endif
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[wrap-git]
|
[wrap-git]
|
||||||
url = https://github.com/4D-STAR/fourdst
|
url = https://github.com/4D-STAR/fourdst
|
||||||
revision = v0.9.11
|
revision = v0.9.14
|
||||||
depth = 1
|
depth = 1
|
||||||
|
|||||||
6
tests/extern/meson.build
vendored
6
tests/extern/meson.build
vendored
@@ -1,5 +1,7 @@
|
|||||||
subdir('C')
|
if get_option('build_c_api')
|
||||||
|
subdir('C')
|
||||||
|
endif
|
||||||
|
|
||||||
if get_option('build-fortran')
|
if get_option('build_fortran')
|
||||||
subdir('fortran')
|
subdir('fortran')
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
executable(
|
executable(
|
||||||
'graphnet_sandbox',
|
'graphnet_sandbox',
|
||||||
'main.cpp',
|
'main.cpp',
|
||||||
dependencies: [gridfire_dep, composition_dep, cli11_dep],
|
dependencies: [gridfire_dep, cli11_dep],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Google Test dependency
|
# Google Test dependency
|
||||||
gtest_dep = dependency('gtest', main: true, required : true)
|
#gtest_dep = dependency('gtest', main: true, required : true)
|
||||||
gtest_main = dependency('gtest_main', required: true)
|
#gtest_main = dependency('gtest_main', required: true)
|
||||||
gtest_nomain_dep = dependency('gtest', main: false, required : true)
|
#gtest_nomain_dep = dependency('gtest', main: false, required : true)
|
||||||
|
|
||||||
# Subdirectories for unit and integration tests
|
# Subdirectories for unit and integration tests
|
||||||
subdir('graphnet_sandbox')
|
subdir('graphnet_sandbox')
|
||||||
|
|||||||
48
tools/config/generate_config_files.cpp
Normal file
48
tools/config/generate_config_files.cpp
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#include "fourdst/config/config.h"
|
||||||
|
#include "gridfire/config/config.h"
|
||||||
|
#include <source_location>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
#include "CLI/CLI.hpp"
|
||||||
|
|
||||||
|
consteval std::string_view strip_namespaces(const std::string_view fullName) {
|
||||||
|
const size_t pos = fullName.rfind("::");
|
||||||
|
if (pos == std::string_view::npos) {
|
||||||
|
return fullName;
|
||||||
|
}
|
||||||
|
return fullName.substr(pos + 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
consteval std::string_view get_type_name() {
|
||||||
|
constexpr std::string_view name = std::source_location::current().function_name();
|
||||||
|
const auto pos = name.find("T = ");
|
||||||
|
if (pos == std::string_view::npos) return name;
|
||||||
|
const auto start = pos + 4;
|
||||||
|
const auto end = name.rfind(']');
|
||||||
|
return name.substr(start, end - start);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
CLI::App app{"GridFire Sandbox Application."};
|
||||||
|
|
||||||
|
std::string outputPath = ".";
|
||||||
|
|
||||||
|
app.add_option("-p,--path", outputPath, "path to save generated config files (default: current directory)");
|
||||||
|
|
||||||
|
CLI11_PARSE(app, argc, argv);
|
||||||
|
|
||||||
|
const std::filesystem::path outPath(outputPath);
|
||||||
|
if (!std::filesystem::exists(outPath)) {
|
||||||
|
std::cerr << "Error: The specified path does not exist: " << outputPath << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fourdst::config::Config<gridfire::config::GridFireConfig> configConfig;
|
||||||
|
const std::string_view name = strip_namespaces(get_type_name<gridfire::config::GridFireConfig>());
|
||||||
|
|
||||||
|
const std::string defaultConfigFilePath = (outPath / (std::string(name) + ".toml")).string();
|
||||||
|
const std::string schemaFilePath = (outPath / (std::string(name) + ".schema.json")).string();
|
||||||
|
configConfig.save(defaultConfigFilePath);
|
||||||
|
configConfig.save_schema(schemaFilePath);
|
||||||
|
}
|
||||||
1
tools/config/meson.build
Normal file
1
tools/config/meson.build
Normal file
@@ -0,0 +1 @@
|
|||||||
|
executable('gf_generate_config_file', 'generate_config_files.cpp', dependencies: [gridfire_dep, cli11_dep], install: true)
|
||||||
3
tools/meson.build
Normal file
3
tools/meson.build
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
if get_option('build_tools')
|
||||||
|
subdir('config')
|
||||||
|
endif
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# 1. Validation
|
||||||
if [[ $(uname -m) != "arm64" ]]; then
|
if [[ $(uname -m) != "arm64" ]]; then
|
||||||
echo "Error: This script is intended to run on an Apple Silicon (arm64) Mac."
|
echo "Error: This script is intended to run on an Apple Silicon (arm64) Mac."
|
||||||
exit 1
|
exit 1
|
||||||
@@ -11,11 +12,12 @@ if [[ $# -ne 1 ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- Initial Setup ---
|
# 2. Setup Directories
|
||||||
REPO_URL="$1"
|
REPO_URL="$1"
|
||||||
WORK_DIR="$(pwd)"
|
WORK_DIR="$(pwd)"
|
||||||
WHEEL_DIR="${WORK_DIR}/wheels_macos_aarch64_tmp"
|
WHEEL_DIR="${WORK_DIR}/wheels_macos_aarch64_tmp"
|
||||||
FINAL_WHEEL_DIR="${WORK_DIR}/wheels_macos_aarch64"
|
FINAL_WHEEL_DIR="${WORK_DIR}/wheels_macos_aarch64"
|
||||||
|
RPATH_SCRIPT="${WORK_DIR}/../../build-python/fix_rpaths.py" # Assumes script is in this location relative to execution
|
||||||
|
|
||||||
echo "➤ Creating wheel output directories"
|
echo "➤ Creating wheel output directories"
|
||||||
mkdir -p "${WHEEL_DIR}"
|
mkdir -p "${WHEEL_DIR}"
|
||||||
@@ -26,10 +28,22 @@ echo "➤ Cloning ${REPO_URL} → ${TMPDIR}/project"
|
|||||||
git clone --depth 1 "${REPO_URL}" "${TMPDIR}/project"
|
git clone --depth 1 "${REPO_URL}" "${TMPDIR}/project"
|
||||||
cd "${TMPDIR}/project"
|
cd "${TMPDIR}/project"
|
||||||
|
|
||||||
# --- macOS Build Configuration ---
|
# 3. Build Configuration
|
||||||
export MACOSX_DEPLOYMENT_TARGET=15.0
|
export MACOSX_DEPLOYMENT_TARGET=15.0
|
||||||
|
|
||||||
|
# Meson options passed to pip via config-settings
|
||||||
|
# Note: We use an array to keep the command clean
|
||||||
|
MESON_ARGS=(
|
||||||
|
"-Csetup-args=-Dunity=off"
|
||||||
|
"-Csetup-args=-Dbuild-python=true"
|
||||||
|
"-Csetup-args=-Dbuild-fortran=false"
|
||||||
|
"-Csetup-args=-Dbuild-tests=false"
|
||||||
|
"-Csetup-args=-Dpkg-config=false"
|
||||||
|
"-Csetup-args=-Dunity-safe=true"
|
||||||
|
)
|
||||||
|
|
||||||
PYTHON_VERSIONS=("3.8.20" "3.9.23" "3.10.18" "3.11.13" "3.12.11" "3.13.5" "3.13.5t" "3.14.0rc1" "3.14.0rc1t" 'pypy3.10-7.3.19' "pypy3.11-7.3.20")
|
PYTHON_VERSIONS=("3.8.20" "3.9.23" "3.10.18" "3.11.13" "3.12.11" "3.13.5" "3.13.5t" "3.14.0rc1" "3.14.0rc1t" 'pypy3.10-7.3.19' "pypy3.11-7.3.20")
|
||||||
|
PYTHON_VERSIONS=("3.9.23" "3.10.18" "3.11.13" "3.12.11" "3.13.5" "3.13.5t" "3.14.0rc1" "3.14.0rc1t" 'pypy3.10-7.3.19' "pypy3.11-7.3.20")
|
||||||
|
|
||||||
if ! command -v pyenv &> /dev/null; then
|
if ! command -v pyenv &> /dev/null; then
|
||||||
echo "Error: pyenv not found. Please install it to manage Python versions."
|
echo "Error: pyenv not found. Please install it to manage Python versions."
|
||||||
@@ -37,55 +51,48 @@ if ! command -v pyenv &> /dev/null; then
|
|||||||
fi
|
fi
|
||||||
eval "$(pyenv init -)"
|
eval "$(pyenv init -)"
|
||||||
|
|
||||||
|
# 4. Build Loop
|
||||||
for PY_VERSION in "${PYTHON_VERSIONS[@]}"; do
|
for PY_VERSION in "${PYTHON_VERSIONS[@]}"; do
|
||||||
(
|
(
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if ! pyenv versions --bare --filter="${PY_VERSION}." &>/dev/null; then
|
# Check if version exists in pyenv
|
||||||
echo "⚠️ Python version matching '${PY_VERSION}.*' not found by pyenv. Skipping."
|
if ! pyenv versions --bare --filter="${PY_VERSION}" &>/dev/null; then
|
||||||
|
echo "⚠️ Python version matching '${PY_VERSION}' not found by pyenv. Skipping."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pyenv shell "${PY_VERSION}"
|
pyenv shell "${PY_VERSION}"
|
||||||
|
|
||||||
PY="$(pyenv which python)"
|
PY="$(pyenv which python)"
|
||||||
echo "➤ Building for $($PY --version) on macOS arm64 (target: ${MACOSX_DEPLOYMENT_TARGET})"
|
|
||||||
|
|
||||||
|
echo "----------------------------------------------------------------"
|
||||||
|
echo "➤ Building for $($PY --version) on macOS arm64"
|
||||||
|
echo "----------------------------------------------------------------"
|
||||||
|
|
||||||
|
# Install build deps explicitly so we can skip build isolation
|
||||||
"$PY" -m pip install --upgrade pip setuptools wheel meson meson-python delocate
|
"$PY" -m pip install --upgrade pip setuptools wheel meson meson-python delocate
|
||||||
|
|
||||||
CC=clang CXX=clang++ "$PY" -m pip wheel . \
|
# PERF: --no-build-isolation prevents creating a fresh venv and reinstalling meson/ninja
|
||||||
|
# for every single build, saving significant I/O and network time.
|
||||||
|
CC="ccache clang" CXX="ccache clang++" "$PY" -m pip wheel . \
|
||||||
|
--no-build-isolation \
|
||||||
|
"${MESON_ARGS[@]}" \
|
||||||
-w "${WHEEL_DIR}" -vv
|
-w "${WHEEL_DIR}" -vv
|
||||||
|
|
||||||
echo "➤ Sanitizing RPATHs before delocation..."
|
# We expect exactly one new wheel in the tmp dir per iteration
|
||||||
|
|
||||||
CURRENT_WHEEL=$(find "${WHEEL_DIR}" -name "*.whl" | head -n 1)
|
CURRENT_WHEEL=$(find "${WHEEL_DIR}" -name "*.whl" | head -n 1)
|
||||||
|
|
||||||
if [ -f "$CURRENT_WHEEL" ]; then
|
echo "➤ Repairing wheel with delocate"
|
||||||
"$PY" -m wheel unpack "$CURRENT_WHEEL" -d "${WHEEL_DIR}/unpacked"
|
# Delocate moves the repaired wheel to FINAL_WHEEL_DIR
|
||||||
|
delocate-wheel -w "${FINAL_WHEEL_DIR}" "$CURRENT_WHEEL"
|
||||||
UNPACKED_ROOT=$(find "${WHEEL_DIR}/unpacked" -mindepth 1 -maxdepth 1 -type d)
|
|
||||||
|
|
||||||
find "$UNPACKED_ROOT" -name "*.so" | while read -r SO_FILE; do
|
|
||||||
echo " Processing: $SO_FILE"
|
|
||||||
"$PY" "../../build-python/fix_rpaths.py" "$SO_FILE"
|
|
||||||
done
|
|
||||||
|
|
||||||
"$PY" -m wheel pack "$UNPACKED_ROOT" -d "${WHEEL_DIR}"
|
|
||||||
|
|
||||||
rm -rf "${WHEEL_DIR}/unpacked"
|
|
||||||
else
|
|
||||||
echo "Error: No wheel found to sanitize!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "➤ Repairing wheel(s) with delocate"
|
|
||||||
delocate-wheel -w "${FINAL_WHEEL_DIR}" "${WHEEL_DIR}"/*.whl
|
|
||||||
|
|
||||||
rm "${WHEEL_DIR}"/*.whl
|
|
||||||
|
|
||||||
|
# Clean up the intermediate wheel from this iteration so it doesn't confuse the next
|
||||||
|
rm "$CURRENT_WHEEL"
|
||||||
)
|
)
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
rm -rf "${TMPDIR}"
|
rm -rf "${TMPDIR}"
|
||||||
rm -rf "${WHEEL_DIR}"
|
rm -rf "${WHEEL_DIR}"
|
||||||
|
|
||||||
|
echo "✅ All builds complete. Artifacts in ${FINAL_WHEEL_DIR}"
|
||||||
|
|||||||
90
utils/wheels/repair_wheel_macos.sh
Executable file
90
utils/wheels/repair_wheel_macos.sh
Executable file
@@ -0,0 +1,90 @@
|
|||||||
|
#!/bin/zsh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
# Color codes for output
|
||||||
|
RED='\033[0;31m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
function fix_file_rpaths() {
|
||||||
|
local file_path="$1"
|
||||||
|
echo -e "${YELLOW}Fixing RPATHs in file: $file_path...${NC}"
|
||||||
|
python3 "$FIX_RPATH_SCRIPT" "$file_path"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo -e "${RED}Error: RPATH fix script failed for file: $file_path${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo -e "${GREEN}RPATHs fixed for file: $file_path${NC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
export -f fix_file_rpaths
|
||||||
|
|
||||||
|
echo -e "${YELLOW}"
|
||||||
|
echo "========================================================================="
|
||||||
|
echo " TEMPORARY WHEEL REPAIR WORKAROUND"
|
||||||
|
echo "========================================================================="
|
||||||
|
echo -e "${NC}"
|
||||||
|
echo ""
|
||||||
|
echo -e "${YELLOW}WARNING:${NC} This script applies a temporary patch to fix"
|
||||||
|
echo "a known issue with meson-python that causes duplicate RPATH entries in"
|
||||||
|
echo "built Python wheels on macOS, preventing module imports."
|
||||||
|
echo ""
|
||||||
|
echo "This workaround will:"
|
||||||
|
echo " 1. Unzip the wheel file"
|
||||||
|
echo " 2. Locate the extension modules"
|
||||||
|
echo " 3. Remove duplicate RPATH entries using install_name_tool"
|
||||||
|
echo " 4. Resign the wheel if necessary"
|
||||||
|
echo " 5. Repackage the wheel file"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
FIX_RPATH_SCRIPT="../../build-python/fix_rpaths.py"
|
||||||
|
|
||||||
|
# get the wheel directory to scan through
|
||||||
|
WHEEL_DIR="$1"
|
||||||
|
if [ -z "$WHEEL_DIR" ]; then
|
||||||
|
echo -e "${RED}Error: No wheel directory specified.${NC}"
|
||||||
|
echo "Usage: $0 /path/to/wheel_directory"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
REPAIRED_WHEELS_DIR="repaired_wheels"
|
||||||
|
mkdir -p "$REPAIRED_WHEELS_DIR"
|
||||||
|
|
||||||
|
REPAIRED_DELOCATED_WHEELS_DIR="${REPAIRED_WHEELS_DIR}/delocated"
|
||||||
|
|
||||||
|
# Scal all files ending in .whl and not starting with a dot
|
||||||
|
for WHEEL_PATH in "$WHEEL_DIR"/*.whl; do
|
||||||
|
if [ ! -f "$WHEEL_PATH" ]; then
|
||||||
|
echo -e "${YELLOW}No wheel files found in directory: $WHEEL_DIR${NC}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
echo -e "${GREEN}Processing wheel: $WHEEL_PATH${NC}"
|
||||||
|
|
||||||
|
WHEEL_NAME=$(basename "$WHEEL_PATH")
|
||||||
|
TEMP_DIR=$(mktemp -d)
|
||||||
|
|
||||||
|
echo -e "${GREEN}Step 1: Unzipping wheel...${NC}"
|
||||||
|
python -m wheel unpack "$WHEEL_PATH" -d "$TEMP_DIR"
|
||||||
|
|
||||||
|
echo -e "${GREEN}Step 2: Locating extension modules...${NC}"
|
||||||
|
while IFS= read -r -d '' so_file; do
|
||||||
|
echo "Found library: $so_file"
|
||||||
|
fix_file_rpaths "$so_file"
|
||||||
|
done < <(find "$TEMP_DIR" -name "*.so" -print0)
|
||||||
|
|
||||||
|
echo -e "${GREEN}Step 4: Repackaging wheel...${NC}"
|
||||||
|
python -m wheel pack "$TEMP_DIR/gridfire-0.7.4rc2" -d "$REPAIRED_WHEELS_DIR"
|
||||||
|
|
||||||
|
REPAIRED_WHEEL_PATH="${REPAIRED_WHEELS_DIR}/${WHEEL_NAME}"
|
||||||
|
|
||||||
|
echo -e "${GREEN}Step 5: Delocating wheel...${NC}"
|
||||||
|
# Ensure delocate is installed
|
||||||
|
pip install delocate
|
||||||
|
delocate-wheel -w "$REPAIRED_DELOCATED_WHEELS_DIR" "$REPAIRED_WHEEL_PATH"
|
||||||
|
|
||||||
|
echo -e "${GREEN}Repaired wheel saved to: ${REPAIRED_DELOCATED_WHEELS_DIR}/${WHEEL_NAME}${NC}"
|
||||||
|
# Clean up temporary directory
|
||||||
|
rm -rf "$TEMP_DIR"
|
||||||
|
done
|
||||||
Reference in New Issue
Block a user