Native library ABI checks¶
GPRidge calls several native libraries through C interfaces and is itself called through one. Each interface carries a version stamp, and GPRidge compares stamps at configure time, at compile time and at run time. This page lists the checks, the start-up lines that report them, and the messages a mismatch produces. It describes the source files named in each row; the version numbers live in those files and are not repeated here.
The checks¶
A stamp is a major version, a minor version and a layout revision. The major changes when an existing declaration breaks a compiled caller. The minor counts additions. The layout revision changes when a struct layout changes.
Library or interface |
Build-time check |
Run-time check |
Floor defined in |
|---|---|---|---|
rgmin |
Meson reads |
|
|
readcon-core |
|
|
|
readcon-db |
|
|
|
rgpot-core |
Meson reads |
|
|
rgpot engine plugin |
none; the header is a copy of |
|
|
rgsaddle |
|
|
|
|
none; byte counts are compiled into the driver |
the driver’s |
|
|
the caller’s copy of |
|
|
rgmin¶
GPRidge calls the rgmin C ABI of one major version and needs a minimum minor.
Minor 43 declares rgmin_lbfgs_pairs_push_rho, which gpr/optimization/LBFGS.cpp calls to preserve the caller-computed reciprocal curvature.
Meson also checks the header for the BFGS and SR1 update exports.
The bundled rgmin supplies both.
A skipped update returns RGMIN_HESSIAN_UPDATE_SKIPPED.
BFGS skips when y·s or |sᵀ B s| is at most 1e-12. SR1 skips
when an entry of s or y is non-finite, when δ·s is non-finite, when
|δᵀs| is at most 1e-12, or when |δᵀs| is below 1e-8 ‖δ‖ ‖s‖. δ·s is
the ndarray dot. A repeated BFGS
relation can still be accepted when a pair is already stored, the residual
is inside the relative resolution, and y·s is positive, without calling
the library. The revision pinned in
subprojects/rgmin.wrap declares its own minor and layout revision in
subprojects/rgmin/include/rgmin.h, which Meson fetches with the wrap. That
header is the one source of both numbers, so this page does not copy them;
the start-up report below prints them for the build at hand.
The Meson check stops configuration with the required and the found version
when the major differs or the minor is lower. It runs on every build:
-Duse_rgmin=disabled is a configure error. No fallback exists once a run
has started: a mismatch raises an error that names the header stamp and
the library stamp.
rgpot-core¶
The rgpot-core stamp covers the C interface that librgpot carries. It does
not cover the layout of rgpot’s header-only C++ classes that GPRidge compiles
into itself (Potential, the force structures, the potential frontends). Those
follow the revision pinned in subprojects/rgpot.wrap, and a library from
another revision with the same C stamp would not be detected. The engine plugins
(libuma_engine.so and the other rgpot_engine_* objects) are covered by the
engine ABI version, which must match exactly, and by the engine ABI stamp
described in the next section.
A build of rgpot without the Rust core ships no rgpot.h and no stamp. Meson
then warns that the rgpot ABI is unverified, and the run-time report lists the
library as UNVERIFIED. A default build of this tree is in that state, as the
output below shows.
rgpot engine plugins¶
An engine plugin exports rgpot_engine_abi_version, rgpot_engine_create,
rgpot_engine_destroy and rgpot_engine_force, and a fifth symbol,
rgpot_engine_abi_stamp, that returns the major, the minor and the layout
revision of the header it was compiled against (RGPOT_ENGINE_ABI_VERSION,
RGPOT_ENGINE_ABI_MINOR and RGPOT_ENGINE_ABI_LAYOUT_REVISION). The header
treats the stamp as optional and reads a plugin without it as minor 0,
layout 1.
GPRidge loads a plugin through gpr/potentials/EnginePotential.cpp. The loader
resolves rgpot_engine_abi_version, rgpot_engine_create,
rgpot_engine_destroy and rgpot_engine_force, and requires
rgpot_engine_abi_version() to equal RGPOT_ENGINE_ABI_VERSION. It reads
rgpot_engine_abi_stamp() and accepts the plugin when the major and the layout
revision equal the header and the plugin minor is at most the header minor. A
library without the symbol is served as 1.0, layout revision 1, without the
later optional symbols. A newer minor, for example “engine ABI stamp 1.12
(layout 1) cannot serve host stamp 1.11 (layout 1)”, or a different major or
layout, is refused. The engine loader of the pinned rgpot-core
(EnginePotential::load) applies that same rule. When the library exports
rgpot_engine_available, the loader calls it before rgpot_engine_create and
refuses a zero result; a missing symbol means the engine is available.
The caps struct is size-prefixed. The loader passes sizeof(RgpotEngineCaps)
and reads a field only when the size the plugin writes covers that field, so
jet_order is zero when the plugin’s struct ends before it.
rgpot_engine_hvp is called only when the symbol is present and
analytic_hvp is set. rgpot_engine_taylor_jet is called only for an order
the plugin’s jet_order serves, and a non-finite position, direction or cell,
or a negative report scale, is rejected. Inputs and output must not overlap.
rgpot_engine_set_cache and
rgpot_engine_cache_counts are used when the plugin exports them.
rgpot_engine_unload_policy is honoured only when the stamp minor is 7 or
later and the symbol returns RGPOT_ENGINE_UNLOAD_SAFE.
Every plugin built here (libgpr_engine.so, libcpmd_engine.so,
libcp2k_engine.so, liblammps_engine.so) links
gpr/potentials/RgpotEngineAbiStamp.cc and exports the stamp of the pinned
header. The test test_engine_abi_stamp loads each of them and compares
the stamp with that header. test_all_engine_abi_stamps checks the stamp of
every engine plugin in the build tree, including rgpot’s. A Cap’n Proto
build also runs test_cpmd_rgpot_host_loader, which loads
libcpmd_engine.so through the rgpot-core loader and fails unless exactly
that one Cargo test ran and passed.
The start-up report¶
gprn and gprd print one line per library when they start, on rank 0 in an
MPI build. gprn --dump-cli-args prints the lines after the argument list and
exits before it enforces any check, so it works on a build that would refuse to
run. The Python function
gpridge.abi_report() returns the same lines as a list of strings.
Each line has the form
[startup] abi library=NAME header=STAMP loaded=STAMP status=verified|UNVERIFIED.
headeris the stamp of the header GPRidge was built against.loadedis the stamp of the library in the process.A stamp of a native library reads
<major>.<minor>/<layout>.The
gpridgeline reads<layout version>/<GPNEBResult bytes>/<OCINEBResult bytes>for the driver (header) and the library (loaded).A library that is not part of the build is listed as
not builtandnot loaded. A library that ships no stamp in this configuration is listed with the reason. Spaces in a reason become underscores. Neither is skipped silently, and both areUNVERIFIED.
The report covers rgmin, readcon-core, readcon-db, rgpot-core and the
libgpridge result layout, in that order. It does not list the rgpot engine
plugin or rgsaddle, which are checked when their libraries load.
This command prints the lines for the drivers in the build tree:
gprn --reactant reactant.con --product product.con --dump-cli-args | grep '^\[startup\] abi'
The next block prints the same lines from Python and then runs the check that the drivers run at start:
import gpridge
for line in gpridge.abi_report():
print(line)
gpridge.check_abi()
The default wrapped build reports the versions from subprojects/*.wrap and the result layout from gpr/OptimAbi.h.
An installed dependency can report a different compatible version.
[startup] abi library=rgmin header=1.77/7 loaded=1.77/7 status=verified
[startup] abi library=readcon-core header=1.1/1 loaded=1.1/1 status=verified
[startup] abi library=readcon-db header=1.3/1 loaded=1.3/1 status=verified
[startup] abi library=rgpot-core header=no_rgpot.h_(rgpot_built_without_the_Rust_core) loaded=no_stamp status=UNVERIFIED
[startup] abi library=gpridge header=2/920/1064 loaded=2/920/1064 status=verified
Mismatch messages¶
A mismatch ends the run before any search starts. gprn and gprd call the
check on every rank before the first collective call. They write
[startup] abi-error MESSAGE to standard error and exit with status 2. A
build with ScaLAPACK calls MPI_Abort first, so that no rank waits for one that
stopped. The Python function gpridge.check_abi() raises ABIError, a
RuntimeError, with the same message.
Message begins |
Raised when |
Fix |
|---|---|---|
|
The loaded rgmin library reports another major or layout revision, or rejects the header’s stamp |
Run against the rgmin library built with the same tree (check |
|
|
Rebuild the drivers and the library together |
|
|
Rebuild the caller against the installed header, or load a newer library |
|
A plugin reports another |
Rebuild the plugin with the same tree |
|
The linked rgsaddle stamp is older than minor 71 |
Rebuild against the pinned rgsaddle wrap |
The first, second and fourth messages come from gpr/ml/RgminAbi.h,
gpr/OptimAbi.h and gpr/potentials/EnginePotential.cpp. The third comes from
gpr_abi_check in gpr/capi/gpridge_c.cpp, and the last from
gpr/neb/RgsaddleClient.cpp. None was provoked for this page.
The C API contract¶
gpr/capi/gpridge_c.h defines GPR_C_ABI_MAJOR and GPR_C_ABI_MINOR. The
major changes only when an existing declaration changes in a way that breaks a
compiled caller (a struct layout, a signature, a removed symbol). The minor
counts additions. gpr_abi_check(header_major, header_minor) returns
GPR_SUCCESS when the majors are equal and the caller’s minor is at most the
library’s. abi/gpridge_c.symbols lists every exported function, and
scripts/check_c_abi.py compares that list, the version numbers and the built
library. Native packages and downstream bindings shows a
consumer that calls GPR_ABI_CHECK().