Tensorium_lib is a C++17 scientific computing library focused on high-performance CPU kernels and numerical relativity workflows.
- Core dense linear algebra and tensor containers (
Vector,Matrix,Tensor) with aligned storage and SIMD paths. - Numerical relativity stack centered on
BSSN_Grid(single-grid, vacuum BSSN/Z4c style evolution). - Test and visualization tooling for long moving-puncture runs.
- Optional R&D compiler plugins (LLVM/Clang/MLIR).
| Area | Status | Notes |
|---|---|---|
Core/Vector.hpp |
usable | SIMD + aligned storage, covered by Tests/core/VectorTests.cpp. |
Core/Matrix.hpp |
usable | Dense ops + GEMM path + inverse/solve utilities, covered by Tests/core/MatrixTests.cpp. |
Core/Tensor.hpp |
usable with caution | Generic rank support, contraction/product utilities; still evolving. |
Physics/DiffGeometry/BSSN_Grid |
active core | Main NR implementation used by current tests and runs. |
Physics/DiffGeometry/BSSN |
legacy/experimental | Historical pointwise layer, not the main runtime path. |
Backend/MPI |
foundational | Domain decomposition and halo exchange utilities exist, not yet integrated end-to-end in BSSN_Grid runtime. |
Backend/CUDA |
scaffold | CUDA structures exist; NR kernels are currently CPU/OpenMP. |
Plugins/ (LLVM/MLIR) |
R&D | Optional compiler tooling, not required for physics runs. |
includes/Tensorium/Core/ # Vector/Matrix/Tensor + solvers + derivatives
includes/Tensorium/Backend/SIMD/ # ISA traits (SSE/AVX/AVX2/AVX512/NEON)
includes/Tensorium/Backend/OpenMP/ # OpenMP compatibility helpers
includes/Tensorium/Backend/MPI/ # Cartesian decomposition + halo exchange building blocks
includes/Tensorium/Physics/DiffGeometry/BSSN_Grid/ # Main numerical relativity implementation
Tests/core/ # Core numerical tests
Tests/bssn/ # NR validation/stability tests and CSV exporters
Plugins/ # Optional LLVM/Clang/MLIR experiments
- CMake >= 3.22
- C++17 compiler (Clang recommended)
- OpenMP runtime
- Optional: MPI, CUDA toolkit, OpenBLAS/BLAS (or Accelerate on macOS), pybind11, NumPy
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTS=ON \
-DBUILD_PYBIND=OFF \
-DBUILD_PLUGINS=OFF
cmake --build build -jIf you need the Python extension from CMake:
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTS=OFF \
-DBUILD_PYBIND=ON \
-DBUILD_PLUGINS=OFF
cmake --build build -j --target tensorium| Option | Default | Description |
|---|---|---|
BUILD_TESTS |
ON |
Build test executables in Tests/. |
BUILD_PYBIND |
OFF |
Build Python bindings. |
BUILD_PLUGINS |
ON |
Build LLVM/Clang plugins. Disable if you only need runtime/library code. |
USE_MPI |
OFF |
Link MPI and enable MPI compile definitions. |
USE_CUDA |
OFF |
Enable CUDA language/backend pieces. |
AVX2 / AVX512 |
OFF |
Force stronger x86 codegen flags when desired. |
TENSORIUM_BSSN_PROFILE_KERNELS |
OFF |
BSSN kernel timers. |
TENSORIUM_BSSN_VALIDATE_TILDE_GAMMA_SYMBOLS |
OFF |
Extra BSSN consistency validation. |
ctest --test-dir build --output-on-failureCommon filters:
ctest --test-dir build -R core
ctest --test-dir build -R bssn
./build/Tests/TensoriumTests --listPython bindings expose core vector/matrix/tensor algebra and selected differential-geometry helpers.
python3python3 -m pip- Python packages:
setuptools,wheel,cmake,numpy,pybind11
Install prerequisites:
python3 -m pip install --upgrade pip setuptools wheel cmake numpy pybind11python3 -m pip install -e .python3 setup.py build_ext --inplacepython3 - <<'PY'
import tensorium
v = tensorium.Vectord([1.0, 2.0, 3.0])
print(v)
PYNumPy interop example:
python3 - <<'PY'
import numpy as np
import tensorium
A = tensorium.Matrixd.from_numpy(np.array([[1.0, 2.0], [3.0, 4.0]]))
print(tensorium.matrices.det(A))
PYCurrent scope of Python API:
Vector/Vectord,Matrix/Matrixd,Tensor2d,Tensor4dtns.*algebra helpers (add/sub/mul, norms, solvers, tensor contractions, etc.)- metric/curvature helpers (
Metric,compute_christoffel,compute_riemann_tensor, Ricci utilities) bssn.BSSNGridwith BSSN initial-data builders (minkowski,schwarzschild_isotropic,kerr_schild_single, Bowen-York puncture initializers)- explicit
TwoPuncturesCinit path viatensorium.bssn.binary_bowen_york_puncture_twopunctures_c_init(...)
bssn quick start:
python3 - <<'PY'
import tensorium
g = tensorium.bssn.BSSNGrid(24, 24, 24, 4, 0.25, 0.25, 0.25)
tensorium.bssn.minkowski(g)
alpha = g.alpha()
print(alpha.shape, alpha.min(), alpha.max())
PYField access examples:
g.alpha()interior valuesg.alpha(include_halo=True)including ghost zonesg.beta(0)forbeta^xg.gamma_tilde(tensorium.bssn.XX)for\\tilde{\\gamma}_{xx}
TwoPuncturesC availability check:
python3 - <<'PY'
import tensorium
print(tensorium.bssn.has_twopunctures_c())
PYNot yet exposed in Python:
- full
BSSN_Gridevolution runtime (RK stepper/gauge controls/diagnostics callbacks) - MPI/CUDA backends
- The active physics path is
includes/Tensorium/Physics/DiffGeometry/BSSN_Grid. - The moving puncture visualization/stability driver is in
Tests/bssn/bowen_york_boost_stability.cpp. - A standalone moving-puncture executable is available at:
./build/Tests/TensoriumMovingPuncture - It consumes the same environment variables as the test driver
(
TENSORIUM_MOVING_PUNCTURE_*+OMP_*) without--test. - Interpolated Two-Punctures initialization requires the external TwoPunctures codebase from:
https://github.com/GRTLCollaboration/TwoPunctures.git - In this repository, that external solver is expected through the local
../TwoPuncturesCintegration (with GSL) at build time.
Standalone run example:
OMP_NUM_THREADS=24 \
OMP_PROC_BIND=spread \
OMP_PLACES=cores \
OMP_DYNAMIC=FALSE \
TENSORIUM_MOVING_PUNCTURE_USE_INTERPOLATED_INIT=1 \
TENSORIUM_MOVING_PUNCTURE_GRID_N=212 \
TENSORIUM_MOVING_PUNCTURE_BOX_LENGTH=24.0 \
TENSORIUM_MOVING_PUNCTURE_SPATIAL_ORDER=6 \
TENSORIUM_MOVING_PUNCTURE_CFL=0.11 \
TENSORIUM_MOVING_PUNCTURE_STEPS=12000 \
./build/Tests/TensoriumMovingPunctureFor nested moving-puncture FMR runs, the most useful controls are:
TENSORIUM_MOVING_PUNCTURE_FMR_LEVELS: number of refined levels nested inside the root gridTENSORIUM_MOVING_PUNCTURE_FMR_REFINEMENT_RATIO: refinement ratio between successive levels;2is the intended production settingTENSORIUM_MOVING_PUNCTURE_FMR_OUTER_BOX_HALF_WIDTH: physical half-width of the outermost refined boxTENSORIUM_MOVING_PUNCTURE_FMR_FINEST_BOX_HALF_WIDTH: physical half-width of the finest box when sizing from the center outwardTENSORIUM_MOVING_PUNCTURE_FMR_FINE_LEVELS_USE_PARENT_INIT=1: initialize refined levels from parent prolongation instead of a second local TwoPunctures solveTENSORIUM_MOVING_PUNCTURE_FMR_MOVE_WITH_PUNCTURES=1: re-center the refined hierarchy on the tracked puncture midpoint during evolutionTENSORIUM_MOVING_PUNCTURE_FMR_REGRID_INTERVAL: root-step interval between regrid checks when moving boxes are enabledTENSORIUM_MOVING_PUNCTURE_FMR_REGRID_THRESHOLD_CELLS: minimum midpoint drift, in finest-grid cells, before rebuilding the hierarchyTENSORIUM_MOVING_PUNCTURE_TRACKER_RECENTER_ON_DRIFT=1: snap the shift-integrated puncture tracker back to the slice minima if it drifts too farTENSORIUM_MOVING_PUNCTURE_TRACKER_RECENTER_CELLS: tracker drift threshold, in finest-grid cells, for that recenter
When TENSORIUM_MOVING_PUNCTURE_FMR_OUTER_BOX_HALF_WIDTH is set, the refined hierarchy is built geometrically toward the center. For example, LEVELS=4, RATIO=2, OUTER_BOX_HALF_WIDTH=64 produces refined half-widths close to 64 -> 32 -> 16 -> 8.
Example multilevel run:
OMP_NUM_THREADS=24 \
OMP_DYNAMIC=FALSE \
TENSORIUM_MOVING_PUNCTURE_GRID_N=192 \
TENSORIUM_MOVING_PUNCTURE_BOX_LENGTH=256.0 \
TENSORIUM_MOVING_PUNCTURE_USE_INTERPOLATED_INIT=1 \
TENSORIUM_MOVING_PUNCTURE_ENABLE_FMR=1 \
TENSORIUM_MOVING_PUNCTURE_FMR_LEVELS=4 \
TENSORIUM_MOVING_PUNCTURE_FMR_REFINEMENT_RATIO=2 \
TENSORIUM_MOVING_PUNCTURE_FMR_OUTER_BOX_HALF_WIDTH=64.0 \
TENSORIUM_MOVING_PUNCTURE_FMR_FINE_LEVELS_USE_PARENT_INIT=1 \
./build/Tests/TensoriumMovingPunctureExample moving-box run:
OMP_NUM_THREADS=24 \
OMP_DYNAMIC=FALSE \
TENSORIUM_MOVING_PUNCTURE_GRID_N=160 \
TENSORIUM_MOVING_PUNCTURE_BOX_LENGTH=64.0 \
TENSORIUM_MOVING_PUNCTURE_USE_INTERPOLATED_INIT=1 \
TENSORIUM_MOVING_PUNCTURE_ENABLE_FMR=1 \
TENSORIUM_MOVING_PUNCTURE_FMR_LEVELS=2 \
TENSORIUM_MOVING_PUNCTURE_FMR_REFINEMENT_RATIO=2 \
TENSORIUM_MOVING_PUNCTURE_FMR_OUTER_BOX_HALF_WIDTH=20.0 \
TENSORIUM_MOVING_PUNCTURE_FMR_FINE_LEVELS_USE_PARENT_INIT=1 \
TENSORIUM_MOVING_PUNCTURE_FMR_MOVE_WITH_PUNCTURES=1 \
TENSORIUM_MOVING_PUNCTURE_FMR_REGRID_INTERVAL=16 \
TENSORIUM_MOVING_PUNCTURE_FMR_REGRID_THRESHOLD_CELLS=2.0 \
./build/Tests/TensoriumMovingPunctureThe moving-puncture slice exports now also write companion geometry metadata
(slice_boxes_*.csv plus per-cell bounds in slice_*.csv) for external
post-processing tools. The stock plot.py keeps its default full-slice view.
Plugins/ contains optional compiler-side tooling (diagnostic/alignment pass, Clang pragma plugin, MLIR conversion experiments).
These plugins are not required for:
Vector/Matrix/Tensorruntime usage- BSSN/Z4c simulations
- Standard test execution
If your goal is NR runs, keep BUILD_PLUGINS=OFF.
- Doxygen config:
Doxyfile - Generated docs:
docs/index.html - Python binding guide:
Pybind/README.md - BSSN_Grid technical guide: includes/Tensorium/Physics/DiffGeometry/BSSN_Grid/README.md
