Supply model sizes through ABI for all provider paths#33
Open
Tsilimidos wants to merge 19 commits into
Open
Conversation
ModelDefaults: add nsca/nvec/nten/nsurf/nvqoi as static constexpr (default 0). ExasimDriverABI: add ncu/nco/ncw/nsca/nvec/nten/nsurf/nvqoi fields; bump version to 2. modelprovider.hpp + kokkoskernelprovider.hpp: populate ABI size fields from PdeModel.
PDE struct: change ncu default from 1 to 0 (unset). validateBuiltInAppMetadata: accept ncu >= 0 (allow 0 = not yet specified). Add applyBuiltInABIMetadata(PDE&, const ExasimDriverABI&) to fill sizes from ABI. ExasimSolver::ParseInputs(): query SelectExasimDriverABI() for missing dimension sizes; use programmatic CPreprocessing constructor so the ABI-filled PDE values flow into writeBinaryFiles.
ncu/ncv/ncw/nsca/nvec/nten/nsurf/nvqoi removed from pdeapp.txt — they are now provided at runtime by the compiled model's ABI. Add corresponding static constexpr to PdeModel struct so the ABI can supply them during preprocessing.
pdeapp.txt (53 files): remove ncu/ncv/ncw/nsca/nvec/nten/nsurf/nvqoi lines my_model.hpp (11 files): keep only non-zero nsca/nvec/nsurf/nvqoi decls (zero-valued inherit from ModelDefaults) ExasimSolver.cpp: add missing nsurf_/nvqoi_ propagation from pde text2code CodeGenerator.cpp: emit vis/QoI constexprs from parsed specs
…d by pdemodel.txt output_size(s)=4)
Backward-compatible size resolution: the KokkosKernel provider ABI populates size fields from PdeModel::ncu etc., while the BuiltInLibrary ABI cannot (it returns 0 for all model-dependent sizes). The >0 guard on all ABI fields prevents BuiltInLibrary's zeros from overwriting the defaults, while still allowing KokkosKernel's real values through.
Add nsca/nvec/nten/nsurf/nvqoi fields to ExasimDriverABI (version 3) with ModelSizes struct and GetModelSizes function pointer. KokkosKernel and BuiltInLibrary providers populate these from compile-time constexpr values; ExternalModel provider dispatches via per-model size TUs. Remove the 8 size parameters (ncu/ncv/ncw/nsca/nvec/nten/nsurf/nvqoi) from all 53 pdeapp.txt files — they are now sourced from the ABI when missing, with explicit pdeapp.txt values still taking precedence. BuiltInLibrary: auto-generate builtin_model_sizes.cpp at CMake time by parsing pdeapp*.txt + pdemodel*.txt; provides per-model dispatch via builtinGetModelSizes(int modelnumber). ExternalModel: Each model gets its own _model_sizes_.cpp TU via file(GENERATE) to avoid #pragma once collisions; extGetModelSizes dispatches via extern "C" per-model helpers. Fix shared library provider (builtinmodelID == 0): parse pdemodel.txt during programmatic preprocessing so applyParsedSpecMetadata extracts vis/QoI sizes from function output_size annotations. Fix struct_size checks: builtinlibprovider uses == (provider and consumer compiled together); sharedlibprovider/t2clibprovider use >= (cross-library compilation).
- Remove builtinmodelID guard in ExasimSolver.cpp:600 so ABI size query runs unconditionally for every provider. - UserDefined, Text2codeGenerated, SharedLibrary (libt2cmodel): set ABI size fields from PdeModel:: compile-time constants. - FrontendGenerated (frontendprovider.cpp, CMake template, example): read sizes from model_sizes.hpp via __has_include guard. - Frontend generators (Python, MATLAB, Julia): emit model_sizes.hpp into staging dir before sync, so FrontendGenerated provider has compile-time size constants at build time.
The modern frontend path (Python/Matlab/Julia -> cmakecompile.py ->
ExternalModelProvider.cpp.in) was not consuming model_sizes.hpp,
making the generated file dead code on the most common user path.
- Add __has_include("model_sizes.hpp") guard
- Populate kFrontendModelSizes constant and extGetModelSizes()
fallback for model IDs >= 100 (frontend-generated range)
- Set direct ABI size fields for redundancy
The check is placed inside the #else branch of @EXT_MODEL_HAS_MY_MODEL@
so it is never compiled for the text2code (PDEMODEL) path.
…(shared library models, sizes come from .so ABI)
…ibility" This reverts commit a31101e.
Replace fragile CMake-time regex parsing of pdeapp.txt for ncu/nco/ncw
and vis/QoI sizes. text2code now emits a namespaced model_sizes.hpp
per model with compile-time constants extracted from the full pdemodel
parser (vectors uhat, v, w and functions VisScalars, VisVectors, ...).
CMakeLists.txt changes:
- Removed ~90 lines of configure-time size parsing and fallback logic.
- builtin_model_sizes.cpp now wraps each per-model
#include "modelN/model_sizes.hpp" in namespace builtin_model_N {},
using the folder name to infer the namespace.
- Removed unused EXASIM_BM_SIZES property.
text2code changes:
- CodeGenerator::generateModelSizesHpp follows the same pattern as
generateEmpty*Cpp methods: writes a simple header from parsed spec
vectors and function output sizes.
- Called from text2code.cpp alongside the existing codegen call.
pdeapp{1..15}.txt: removed ncu=, ncw= lines (now sourced
from pdemodel.txt via text2code).
so text2code always generates a fresh file.
…e stamp
GCC 14.3.0 deduplicates #pragma once headers by content fingerprint, not
inode/path. Three groups of models (1/8, 2/3/15, 10/14) have identical
model_sizes.hpp content, causing GCC to silently skip the second include
and leave builtin_model_N::ncu etc. undefined for N in {3,8,14,15}.
Fix: drop #pragma once from generateModelSizesHpp output. Each file is
included exactly once inside a unique namespace block in
builtin_model_sizes.cpp, so no include guard is needed.
Also remove .text2code.stamp alongside model_sizes.hpp at configure time
so regeneration is triggered on the next build after a stale-file cleanup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Remove the requirement to specify model dimension sizes (
ncu,ncv,ncw,nsca,nvec,nten,nsurf,nvqoi) inpdeapp.txtby having every ABI provider path supply them at compile time.Changes
Core solver (
ExasimSolver.cpp)builtinmodelID > 0guard so the ABI size query runs unconditionally for every provider.Provider paths — all 6 now supply compile-time sizes
PdeModel::ncuetc. fromkokkoskernels.hppbuiltinGetModelSizes()callback (unchanged)PdeModel::ncuetc. frommy_model.hppPdeModel::ncuetc. from generatedmy_model.hppPdeModel::ncuetc. from generatedmy_model.hppmodel_sizes.hppvia__has_includeguardFrontend generators — emit
model_sizes.hppGencode.py): writesmodel_sizes.hppinto staging dir before synckkgencode.m): sameGencode.jl): sameThe file is synced alongside kernel
.cppfiles tokernels/and is picked up byfrontendprovider.cppvia__has_include("model_sizes.hpp"). When absent (e.g. exported bundles without re-running codegen), sizes default to 0 and the solver falls back topdeapp.txtvalues.Templates & examples
cmake/frontend-app/frontendprovider.cpp.in:__has_includeguardexamples/exasimfe/frontendprovider.cpp: sameVerification
ncu/ncwstripped frompdeapp.txt— solver gets sizes from the.soABI, correct QoIconsumer_builtin_cpualready tests the BuiltInLibrary path without sizes inpdeapp.txtRelevant files