compiled_block Namespace ReferenceΒΆ

adc_cpp: pops::compiled_block Namespace Reference
adc_cpp 0.3.0
Model-free C++23 core for coupled hyperbolic-elliptic systems on adaptive (AMR) meshes, with MPI and GPU (Kokkos) backends
pops::compiled_block Namespace Reference

Classes

struct  HasRuntimeParams
 Detects (SFINAE) whether a brick B exposes a params member of type pops::RuntimeParams (DSL bricks carry one only if a formula reads a runtime parameter, P7-b). More...
 
struct  HasRuntimeParams< B, std::void_t< decltype(std::declval< B & >().params)> >
 
struct  LocalGrid
 Local single-grid mesh rebuilt inside the .so + aux filled from the System array. More...
 

Functions

LocalGrid make_grid (int n, double dx, double dy, bool periodic, const double *aux_in, int naux)
 naux = width of the aux channel the model READS (aux_comps<Model>(), >= 3).
 
void fill_interior (MultiFab &mf, const double *in, int n, int nv)
 Copies nv components of the component-major flat array in into the INTERIOR of fab(0) (without touching the ghosts).
 
void extract (const MultiFab &mf, double *out, int n, int nv)
 Copies the INTERIOR of fab(0) (nv components) into the component-major flat array out.
 
template<class B >
void apply_runtime_params (B &b, const RuntimeParams &rp)
 Writes rp into the params member of brick b if it has one (P7-b); otherwise no-op.
 
template<class Model >
Model make_model_with_params (const double *pvals, int npar)
 Builds a Model (CompositeModel<Hyp, Src, Ell>) and injects the npar runtime parameter values pvals into EACH brick that carries a params member (P7-b).
 
template<class B >
int brick_nparams (const B &b)
 Number of runtime parameters the params member of a brick b carries (0 if the brick has none).
 
template<class Model >
RuntimeParams model_params (const Model &model)
 params block (full RuntimeParams) of the model: the FIRST brick that carries one (all carry the same full block when the model has runtime params).
 
template<class Model >
int model_nparams ()
 Number of runtime parameters declared by Model (P7-b): max of the params.count of its 3 bricks (each carries the SAME full block when the model has runtime params; 0 everywhere otherwise).
 
template<class Model >
void model_param_defaults (double *out)
 Writes the DECLARATION values of Model's runtime parameters into out (at least model_nparams<Model>() doubles).
 
template<class Model >
void residual (const double *U, double *R, const double *aux_in, int n, double dx, double dy, bool periodic, const std::string &lim, const std::string &riem, bool recon_prim, const double *pvals=nullptr, int npar=0, double pos_floor=0)
 Residual -div F + S of the production path (assemble_rhs<Limiter, Flux>) on the generated model.
 
template<class Model >
void advance (double *U, const double *aux_in, int n, double dx, double dy, bool periodic, const std::string &lim, const std::string &riem, bool recon_prim, bool imex, double dt, int nsub, const double *pvals=nullptr, int npar=0, double pos_floor=0)
 Advances by nsub substeps (explicit SSPRK2, or ForwardEuler + implicit source if imex).
 
template<class Model >
double max_speed (const double *U, const double *aux_in, int n, double dx, double dy, bool periodic, const double *pvals=nullptr, int npar=0)
 Max wave speed of the block (for the CFL step on the System side) via make_max_speed on the generated model.
 
template<class Model >
void to_conservative (const double *P, double *U, int n, const double *pvals=nullptr, int npar=0)
 PRIMITIVE -> CONSERVATIVE conversion cell by cell (M.to_conservative) on component-major flat arrays ncomp*n*n.
 
template<class Model >
void to_primitive (const double *U, double *P, int n, const double *pvals=nullptr, int npar=0)
 CONSERVATIVE -> PRIMITIVE conversion cell by cell (M.to_primitive).
 
template<class Model >
void pointwise_project (double *U, const double *aux_in, int n, const double *pvals=nullptr, int npar=0)
 PROJECTION PONCTUELLE post-pas (ADC-177) : U(k) <- model.project(U(k), aux(k)) sur les n*n cellules, tableaux plats composante-majeur (meme disposition que to_conservative).
 
template<class Model >
void poisson_rhs (const double *U, double *rhs_out, int n, const double *pvals=nullptr, int npar=0)
 Elliptic right-hand side f(U) of the block (the System adds it to its Poisson sum).
 
std::string csv_to_json_array (const std::string &csv)
 A JSON array literal ["a","b",...] from a comma-separated CSV (empty CSV -> []).
 
template<class Model >
std::string model_cons_roles_csv ()
 The conservative-role CSV of Model, or an empty string if the model declares no roles.
 
std::string compiled_native_entrypoints_csv ()
 The native entrypoint symbols a POPS_DEFINE_COMPILED_BLOCK .so exports, as a CSV.
 
template<class Model >
std::string compiled_manifest_json ()
 The per-artifact NativeManifest of Model as a JSON string (Spec 5 sec.13.12, criterion #36).
 

Function Documentation

◆ advance()

template<class Model >
void pops::compiled_block::advance ( double *  U,
const double *  aux_in,
int  n,
double  dx,
double  dy,
bool  periodic,
const std::string &  lim,
const std::string &  riem,
bool  recon_prim,
bool  imex,
double  dt,
int  nsub,
const double *  pvals = nullptr,
int  npar = 0,
double  pos_floor = 0 
)

Advances by nsub substeps (explicit SSPRK2, or ForwardEuler + implicit source if imex).

+ Here is the call graph for this function:

◆ apply_runtime_params()

template<class B >
void pops::compiled_block::apply_runtime_params ( B &  b,
const RuntimeParams rp 
)
inline

Writes rp into the params member of brick b if it has one (P7-b); otherwise no-op.

The brick then behaves as if it had those parameter values in place of its declaration defaults.

+ Here is the caller graph for this function:

◆ brick_nparams()

template<class B >
int pops::compiled_block::brick_nparams ( const B &  b)
inline

Number of runtime parameters the params member of a brick b carries (0 if the brick has none).

Used by model_nparams to report to the loader the expected size of the parameter block.

+ Here is the caller graph for this function:

◆ compiled_manifest_json()

template<class Model >
std::string pops::compiled_block::compiled_manifest_json ( )

The per-artifact NativeManifest of Model as a JSON string (Spec 5 sec.13.12, criterion #36).

Computed at the .so's OWN compile time from the model traits, so the manifest is AUTHORITATIVE for that artifact (it cannot drift from the code that was compiled into it):

  • abi_version = pops::kAbiVersion (the capability-contract revision the .so was built with);
  • n_vars = Model::n_vars (conservative state width);
  • n_aux = aux_comps<Model>() (aux channel width the model reads);
  • n_params = model_nparams<Model>() (runtime parameters; 0 if none);
  • ghost_depth = block_n_ghost("weno5") (the MAX ghost depth the artifact may allocate; the actual depth is bound at run by the limiter the loader passes – this is the honest upper envelope, never an under-report);
  • supports_stride = false (the AOT flat-array path hardcodes stride=1, cf. make_grid);
  • supports_partial_imex_mask = false (NO C++ path backs it – reporting true would be a lie);
  • supports_named_fields = true (the named-aux transport exists, load_aux / aux_field);
  • roles = conservative-role names (empty array if the model declares none);
  • native_entrypoints = the extern "C" symbols this .so exports.
+ Here is the call graph for this function:

◆ compiled_native_entrypoints_csv()

std::string pops::compiled_block::compiled_native_entrypoints_csv ( )
inline

The native entrypoint symbols a POPS_DEFINE_COMPILED_BLOCK .so exports, as a CSV.

A FIXED list (the macro emits exactly these), surfaced in the manifest so a loader/inspector can name the ABI surface without dlsym-probing each symbol. The _p runtime-param variants and the optional projection / metadata symbols are included because the macro always emits them.

+ Here is the caller graph for this function:

◆ csv_to_json_array()

std::string pops::compiled_block::csv_to_json_array ( const std::string &  csv)
inline

A JSON array literal ["a","b",...] from a comma-separated CSV (empty CSV -> []).

The tokens are model role / entrypoint names (ASCII, no JSON-special characters), so a minimal quoter suffices; it keeps the manifest emitter free of the external-brick json_escape dependency.

+ Here is the caller graph for this function:

◆ extract()

void pops::compiled_block::extract ( const MultiFab mf,
double *  out,
int  n,
int  nv 
)
inline

Copies the INTERIOR of fab(0) (nv components) into the component-major flat array out.

Output side of fill_interior. PRIOR device_fence(): the assemble_rhs / advance kernels are ASYNC, we wait before reading the unified memory on the host (otherwise race -> partial result).

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fill_interior()

void pops::compiled_block::fill_interior ( MultiFab mf,
const double *  in,
int  n,
int  nv 
)
inline

Copies nv components of the component-major flat array in into the INTERIOR of fab(0) (without touching the ghosts).

Marshaling input side: layout c*n*n + j*n + i (cf. System::copy_state).

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_grid()

LocalGrid pops::compiled_block::make_grid ( int  n,
double  dx,
double  dy,
bool  periodic,
const double *  aux_in,
int  naux 
)
inline

naux = width of the aux channel the model READS (aux_comps<Model>(), >= 3).

The flat array aux_in carries EXACTLY naux components (marshaled by the System via copy_state); we copy them all into the internal aux so that assemble_rhs (load_aux<aux_comps<Model>()>) reads B_z/T_e. The ghosts (B_z/T_e included) are filled by the same BCs as the System.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_model_with_params()

template<class Model >
Model pops::compiled_block::make_model_with_params ( const double *  pvals,
int  npar 
)

Builds a Model (CompositeModel<Hyp, Src, Ell>) and injects the npar runtime parameter values pvals into EACH brick that carries a params member (P7-b).

pvals == nullptr or npar == 0 -> no injection: the Model keeps its declaration defaults (thus identical to a const param). Centralizes the single point of the AOT ABI that depends on the runtime params; native bricks / bricks without a runtime param are unchanged (apply_runtime_params is a no-op on them).

+ Here is the call graph for this function:

◆ max_speed()

template<class Model >
double pops::compiled_block::max_speed ( const double *  U,
const double *  aux_in,
int  n,
double  dx,
double  dy,
bool  periodic,
const double *  pvals = nullptr,
int  npar = 0 
)

Max wave speed of the block (for the CFL step on the System side) via make_max_speed on the generated model.

+ Here is the call graph for this function:

◆ model_cons_roles_csv()

template<class Model >
std::string pops::compiled_block::model_cons_roles_csv ( )

The conservative-role CSV of Model, or an empty string if the model declares no roles.

SFINAE so a model WITHOUT conservative_vars() (a bare scalar) yields "" rather than a hard compile error.

+ Here is the call graph for this function:

◆ model_nparams()

template<class Model >
int pops::compiled_block::model_nparams ( )
inline

Number of runtime parameters declared by Model (P7-b): max of the params.count of its 3 bricks (each carries the SAME full block when the model has runtime params; 0 everywhere otherwise).

Exposed by pops_compiled_nparams() so the loader sizes the value block it transmits.

+ Here is the call graph for this function:

◆ model_param_defaults()

template<class Model >
void pops::compiled_block::model_param_defaults ( double *  out)

Writes the DECLARATION values of Model's runtime parameters into out (at least model_nparams<Model>() doubles).

Used by the loader to SEED its value block: a later set_param overwrites only one entry, the others keep their declaration default (no reset to zero).

+ Here is the call graph for this function:

◆ model_params()

template<class Model >
RuntimeParams pops::compiled_block::model_params ( const Model &  model)
inline

params block (full RuntimeParams) of the model: the FIRST brick that carries one (all carry the same full block when the model has runtime params).

Empty RuntimeParams (count=0) if no brick has a runtime param.

+ Here is the caller graph for this function:

◆ pointwise_project()

template<class Model >
void pops::compiled_block::pointwise_project ( double *  U,
const double *  aux_in,
int  n,
const double *  pvals = nullptr,
int  npar = 0 
)

PROJECTION PONCTUELLE post-pas (ADC-177) : U(k) <- model.project(U(k), aux(k)) sur les n*n cellules, tableaux plats composante-majeur (meme disposition que to_conservative).

PONCTUELLE : aucun maillage ni ghost, simple boucle de cellules ; l'aux est marshale par cellule depuis le tableau plat (composantes canoniques via POPS_AUX_FIELDS + champs nommes, miroir de load_aux). Modele SANS trait HasPointwiseProjection -> no-op (le loader ne devrait jamais l'appeler : pops_compiled_has_projection() rend 0).

◆ poisson_rhs()

template<class Model >
void pops::compiled_block::poisson_rhs ( const double *  U,
double *  rhs_out,
int  n,
const double *  pvals = nullptr,
int  npar = 0 
)

Elliptic right-hand side f(U) of the block (the System adds it to its Poisson sum).

+ Here is the call graph for this function:

◆ residual()

template<class Model >
void pops::compiled_block::residual ( const double *  U,
double *  R,
const double *  aux_in,
int  n,
double  dx,
double  dy,
bool  periodic,
const std::string &  lim,
const std::string &  riem,
bool  recon_prim,
const double *  pvals = nullptr,
int  npar = 0,
double  pos_floor = 0 
)

Residual -div F + S of the production path (assemble_rhs<Limiter, Flux>) on the generated model.

GHOSTS: we allocate the local state with block_n_ghost(lim) (3 for weno5, its 5-point stencil, otherwise 2 MUSCL) – SAME mechanism as System::add_block (set_block_ghosts, PR #88). Without that width, assemble_rhs would read out of bounds of the .so local grid. none/minmod/vanleer (<=2 ghosts): allocation and result bit-identical to history (the surplus ghost is a no-op).

+ Here is the call graph for this function:

◆ to_conservative()

template<class Model >
void pops::compiled_block::to_conservative ( const double *  P,
double *  U,
int  n,
const double *  pvals = nullptr,
int  npar = 0 
)

PRIMITIVE -> CONSERVATIVE conversion cell by cell (M.to_conservative) on component-major flat arrays ncomp*n*n.

Used by System::set_primitive_state through the AOT block (init from the primitives). Model without conversion (scalar) -> identity (HasPrimitiveVars false). No mesh / ghosts: POINTWISE conversion, thus a simple loop over the n*n cells.

◆ to_primitive()

template<class Model >
void pops::compiled_block::to_primitive ( const double *  U,
double *  P,
int  n,
const double *  pvals = nullptr,
int  npar = 0 
)

CONSERVATIVE -> PRIMITIVE conversion cell by cell (M.to_primitive).

Diagnostic counterpart of to_conservative (System::get_primitive_state through the AOT block). Identity if the model exposes no conversion.