Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1bcf6f3
Merge remote-tracking branch 'origin/chore/native-tooling' into refac…
jtravs Nov 12, 2026
d8d3af1
Build native refusal messages with one concatenation helper
jtravs Nov 12, 2026
9b6eec2
Name the build's facts as constants for if constexpr
jtravs Nov 12, 2026
41f53f3
Replace the width switch ladders with dispatch_width
jtravs Nov 12, 2026
f7f5ddc
Forward GeneralState's calls through one with_team
jtravs Nov 12, 2026
1916241
Return nothing from the void workspace forwarders
jtravs Nov 12, 2026
2da322d
Bind the native problem as nested structs filled by one lowering
jtravs Nov 12, 2026
ccf8d8d
Write the native problem's stub as plain attributes
jtravs Nov 12, 2026
ae3918f
Generate the problem's stub from nanobind.stubgen
jtravs Nov 12, 2026
bea5d7b
Split general.cpp into src/general/ translation units
jtravs Nov 12, 2026
6ed5a29
Format the shared helpers' scratch view alias
jtravs Nov 12, 2026
13aa7a6
Release the general workspace by destruction
jtravs Nov 12, 2026
ba70b22
Rewrap the band column's comment after its path changed
jtravs Nov 12, 2026
1fa5517
Release the workspace's parts by destruction too
jtravs Nov 12, 2026
bf84739
Count the memory ledger through bytes() and reserved()
jtravs Nov 12, 2026
ed00658
Expect a closed state to refuse its ledger
jtravs Nov 12, 2026
2ccc83b
Split the general workspace's long cold functions
jtravs Nov 12, 2026
6966802
Gate readability-function-size at 300 lines
jtravs Nov 12, 2026
4cc6908
Delete C++ that nothing calls in any build
jtravs Nov 12, 2026
464c2ad
Drop a blank line the deleted provider left
jtravs Nov 12, 2026
b9f8f9a
Hash src/general/'s headers in the coverage build
jtravs Nov 12, 2026
a7874a8
Hold the counted problem arrays to their shapes again
jtravs Nov 12, 2026
aefa7d0
Say in the problem stub that array fields are copies
jtravs Nov 12, 2026
bb3eca1
Point the open documents at src/general/
jtravs Nov 12, 2026
369c765
Merge remote-tracking branch 'origin/main' into refactor/native-struc…
jtravs Nov 12, 2026
26768d7
Restore the device builds' Adams block and switches
jtravs Nov 12, 2026
1f00b8f
Spell out the bound problem's dependent typenames for nvcc
jtravs Nov 12, 2026
7d058ba
Merge remote-tracking branch 'origin/main' into refactor/native-struc…
jtravs Nov 12, 2026
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
4 changes: 2 additions & 2 deletions docs/dev/backends.md
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ two-stage reductions, and moving the whole inner loop into compiled code: one na
executes a Runge–Kutta trial (§3.5). On a CPU build's trapezoid column the whole nonlinear
term at one node — the rate lookup, the plasma's two running sums, the loss-current guard,
the Kerr cubic and the Raman drive — is **one traversal of `t`**, the plasma's sums carried
in scalars across the loop (`response_plasma`, `native/src/general.cpp`); the band column
in scalars across the loop (`response_plasma`, `native/src/general/trial.cpp`); the band column
(§3.12) uses complete row passes instead. The solution and the embedded estimate are
running accumulators (ADR-009), which is also why there is no dense output by default. An
isolated step timing is not comparable with a whole-run average, which carries the
Expand All @@ -662,7 +662,7 @@ once-per-run FFTW planning and the output's planes.
### 3.1a What exists

The adapter `native/src/solprop_native/backend.py`, its session
`native/src/solprop_native/session.py` and the engine `native/src/general.cpp`. The public default is `"auto"`: the
`native/src/solprop_native/session.py` and the engine under `native/src/general/`. The public default is `"auto"`: the
native backend, with no fallback (§1, ADR-029).
`numpy_ref` stays selectable by name.

Expand Down
2 changes: 1 addition & 1 deletion docs/dev/benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,7 @@ grows as an attempt gets cheaper, and it is above 0.1 % on the two smallest grid

The exponential Adams trial's predict and correct passes on a host block of 32 elements
held as lanes (`include/solprop_native/adams_phi.hpp`, `adams_lanes_*` in
`src/general.cpp`) against the element-by-element form, at 740b24d. Before the change
`src/general/trial.cpp`) against the element-by-element form, at 740b24d. Before the change
the passes ran each element through latency-bound scalar strict code (the
phi-functions' series, Horner pass and squarings, the compensation and the defects),
GCC calling every strict helper out of line from the contracting kernels; per element
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/open-questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ comparison with a reference, a measurement — settles it.

**The on-axis spectrum's end bins on the native backend.** The `on_axis_spectrum`
statistic is computed natively on the native backend
(`GeneralWorkspace::spatial_statistics` in `native/src/general.cpp`) and in
(`GeneralWorkspace::spatial_statistics` in `native/src/general/statistics.cpp`) and in
Python on the others (`solprop/backends/spatial.py`, through
{func}`~solprop.fourier.spectral_density`). On a field grid the two agree at every
interior bin and differ at the zero-frequency and Nyquist bins: the native kernel does
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/seps/sep-0002-two-photon-absorption.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ The relevant current code is:
admits `MaterialKerr` and `SilicaTensorResponse`; those types do not already
provide arbitrary complex susceptibility or TPA.
- In `solprop-kokkos`, `src/solprop_kokkos/backend.py`,
`include/solprop_kokkos/core.hpp`, `src/core.cpp`, `src/general.cpp` and
`include/solprop_kokkos/core.hpp`, `src/core.cpp`, `src/general/` and
`include/solprop_kokkos/envelope_plasma.hpp`: admission, native data and resident
execution. A source cannot be added solely to the Python oracle.

Expand Down
2 changes: 1 addition & 1 deletion docs/dev/seps/sep-0009-propagation-statistics.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ product and must not reinterpret the existing statistic.
`backends.numpy_ref.backend`, `backends.numba_cpu.backend`, `backends.spatial` and
`backends.driver.StepDriver` own the reference, compiled and periodic evaluation.
In `solprop-kokkos`, `src/solprop_kokkos/backend.py` packs/unpacks native statistics;
`src/general.cpp` owns the modal statistics pass, and `src/general_modal.cpp` the
`src/general/statistics.cpp` owns the modal statistics pass, and `src/general_modal.cpp` the
general modal execution. The current Kokkos temporal FWHM path transfers a total
power trace for host crossing interpolation; a new family of per-mode/time-resolved
measurements must budget that transfer rather than assume all statistics are scalars.
Expand Down
2 changes: 1 addition & 1 deletion native/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ InsertNewlineAtEOF: true
CommentPragmas: '^ (IWYU pragma:|NOLINT)'
# No RemoveSemicolon: clang-format parses `const auto f = KOKKOS_LAMBDA(...) {...};` as a
# function definition and removes the semicolon the declaration needs. Declaring the
# macro (`Macros:`) fixes that but makes formatting general.cpp minutes slower.
# macro (`Macros:`) fixes that but makes formatting src/general/ minutes slower.
# Include blocks: this package's and the directory's own headers ("..."), then the
# third-party libraries, then the standard library, then platform headers (the operating
# system, the compiler and the device runtimes). An include under #if stays in its own
Expand Down
8 changes: 5 additions & 3 deletions native/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
# - readability-trailing-comma: style only, and clang-format owns layout.
# - readability-braces-around-statements: the LLVM convention leaves single
# statements unbraced, and adding braces around bodies with #if is unsafe.
# - readability-function-size, readability-function-cognitive-complexity: the long
# setup functions and hot kernels are split first (a later change), then gated.
# - readability-function-cognitive-complexity: numerical kernels branch on their
# problem's features by design. readability-function-size is on, at 300 lines;
# the hot kernels above it say why where they are defined.
# - readability-avoid-nested-conditional-operator: nested conditionals initialise
# const locals, in kernels too; an immediately invoked lambda reads worse.
# - readability-convert-member-functions-to-static: it sees the CPU build only, where
Expand Down Expand Up @@ -62,7 +63,6 @@ Checks: >
-readability-uppercase-literal-suffix,
-readability-trailing-comma,
-readability-braces-around-statements,
-readability-function-size,
-readability-function-cognitive-complexity,
-readability-avoid-nested-conditional-operator,
-readability-make-member-function-const,
Expand All @@ -79,6 +79,8 @@ WarningsAsErrors: '*'
HeaderFilterRegex: '.*/(include|src)/.*'
FormatStyle: file
CheckOptions:
# A function longer than this is split; its statements stay at the default 800.
readability-function-size.LineThreshold: 300
# `.value()` is a checked access: it throws std::bad_optional_access.
bugprone-unchecked-optional-access.IgnoreValueCalls: true
# A cast to void is an explicit discard (unique_ptr::release once a capsule owns it).
Expand Down
3 changes: 2 additions & 1 deletion native/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ the gate.
- Release the GIL around long native work and hold it while touching Python objects.
Never call Python from a Kokkos or OpenMP worker, or during teardown.
- Public Python has complete annotations, NumPy-style docstrings, `__all__`, `py.typed`
and a complete stub for the private extension. Install a `NullHandler`; never
and a complete stub for the private extension; its bound problem's part is generated
(`scripts/problem_stub.py`, checked in the lint stage). Install a `NullHandler`; never
configure the root logger or print diagnostics from library code.
- Thread settings are read once, at import. Never change process thread settings (or
a BLAS thread pool) after import.
Expand Down
21 changes: 15 additions & 6 deletions native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ if(SOLPROP_NATIVE_ENABLE_COVERAGE)
-O1 -g -fprofile-instr-generate -fcoverage-mapping -fprofile-update=atomic)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF)
# The source digest's set (cmake/SourceDigest.cmake), src/general/'s headers included.
file(GLOB_RECURSE _coverage_sources CONFIGURE_DEPENDS RELATIVE "${PROJECT_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}/src/*.cpp" "${PROJECT_SOURCE_DIR}/include/*.hpp")
"${PROJECT_SOURCE_DIR}/src/*.cpp" "${PROJECT_SOURCE_DIR}/src/*.hpp"
"${PROJECT_SOURCE_DIR}/src/*.h" "${PROJECT_SOURCE_DIR}/include/*.cpp"
"${PROJECT_SOURCE_DIR}/include/*.hpp" "${PROJECT_SOURCE_DIR}/include/*.h")
list(SORT _coverage_sources)
set(_coverage_source_record "")
foreach(_source IN LISTS _coverage_sources)
Expand Down Expand Up @@ -805,8 +808,9 @@ if(SOLPROP_NATIVE_ENABLE_COVERAGE)
install(TARGETS solprop_native_labels LIBRARY DESTINATION solprop_native)
endif()

add_library(solprop_native_core STATIC src/core.cpp src/crossing.cpp src/general.cpp
src/general_modal.cpp src/coupled_flow.cpp src/dispersive.cpp src/far_field.cpp
add_library(solprop_native_core STATIC src/core.cpp src/crossing.cpp
src/general/checks.cpp src/general/setup.cpp src/general/trial.cpp
src/general/statistics.cpp src/general/state.cpp src/general_modal.cpp src/coupled_flow.cpp src/dispersive.cpp src/far_field.cpp
src/adams_march.cpp src/watch.cpp src/rk_march.cpp src/engines.cpp src/session.cpp
src/session_statistics.cpp src/session_widths.cpp src/low_storage.cpp src/transverse.cpp
src/session_edge.cpp src/dense.cpp)
Expand All @@ -817,10 +821,15 @@ add_library(solprop_native_core STATIC src/core.cpp src/crossing.cpp src/general
# judgement round as solprop's Python does, so their
# translation units take no contraction on any build (the flag follows the global one,
# and the last wins). MSVC's /fp:precise does not contract by default.
# SOLPROP_NATIVE_STRICT_TU marks them, so that the general workspace's contracting
# headers (src/general/) refuse to be included there.
set(SOLPROP_NATIVE_STRICT_SOURCES src/adams_march.cpp src/watch.cpp src/rk_march.cpp
src/session.cpp src/session_statistics.cpp src/session_widths.cpp src/low_storage.cpp
src/transverse.cpp src/session_edge.cpp src/dense.cpp)
set_source_files_properties(${SOLPROP_NATIVE_STRICT_SOURCES}
PROPERTIES COMPILE_DEFINITIONS SOLPROP_NATIVE_STRICT_TU)
if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang|AMDClang)$")
set_source_files_properties(src/adams_march.cpp src/watch.cpp src/rk_march.cpp
src/session.cpp src/session_statistics.cpp src/session_widths.cpp src/low_storage.cpp
src/transverse.cpp src/session_edge.cpp src/dense.cpp
set_source_files_properties(${SOLPROP_NATIVE_STRICT_SOURCES}
PROPERTIES COMPILE_OPTIONS "-ffp-contract=off")
endif()
target_include_directories(solprop_native_core PUBLIC
Expand Down
38 changes: 38 additions & 0 deletions native/include/solprop_native/build.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-FileCopyrightText: 2026 John C. Travers and contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include <Kokkos_Macros.hpp>

/** The build's facts as constants, for `if constexpr` where both branches compile in
every build (CPU, CUDA and HIP); code that names a device or host-only facility
keeps its `#if`. */
namespace solprop_native::build {

#ifdef KOKKOS_ENABLE_CUDA
inline constexpr bool cuda = true;
#else
inline constexpr bool cuda = false;
#endif

#ifdef KOKKOS_ENABLE_HIP
inline constexpr bool hip = true;
#else
inline constexpr bool hip = false;
#endif

/** A CUDA or HIP build: the kernels' execution space is a device. */
inline constexpr bool device = cuda || hip;

/** A host build: the kernels run on the CPU. */
inline constexpr bool host = !device;

#ifdef KOKKOS_ENABLE_OPENMP
inline constexpr bool openmp = true;
#else
inline constexpr bool openmp = false;
#endif

} // namespace solprop_native::build
Loading
Loading