Loading...
Searching...
No Matches
Version and error handling

Macros

#define GPR_C_ABI_MAJOR   1
 ABI version of this header. See the ABI paragraph above.
#define GPR_C_ABI_MINOR   26
#define GPR_ABI_CHECK()
 Check the loaded library against the header in use. Call once at start.

Enumerations

enum  {
  GPR_SUCCESS = 0 , GPR_ERR_NULL_HANDLE = -1 , GPR_ERR_INVALID_ARG = -2 , GPR_ERR_NOT_TRAINED = -3 ,
  GPR_ERR_ALLOC = -4 , GPR_ERR_CHOLESKY = -5 , GPR_ERR_OPTIMIZER = -6 , GPR_ERR_NOT_CONVERGED = -7 ,
  GPR_ERR_SIZE_LIMIT = -8 , GPR_ERR_ORACLE = -9 , GPR_ERR_UNSUPPORTED = -10 , GPR_ERR_ABI = -11 ,
  GPR_ERR_OUT_OF_SUPPORT = -12 , GPR_ERR_UNIT_MISMATCH = -13 , GPR_ERR_INTERNAL = -99
}
 Status codes returned by the functions whose int result is a status. More...

Functions

const char * gpr_version (void)
 Library version string ("major.minor.patch"). Never NULL.
void gpr_version_components (int *major, int *minor, int *patch)
 Version components. Any pointer may be NULL.
void gpr_abi_version (int *major, int *minor)
 ABI version of the loaded library. Any pointer may be NULL.
int gpr_abi_check (int header_major, int header_minor)
 GPR_SUCCESS when the loaded library implements the ABI a caller was compiled against (same major, library minor at least header_minor); GPR_ERR_ABI with both versions in gpr_last_error() otherwise.
const char * gpr_last_error (void)
 Thread-local error message from last failing call. Never NULL.
const char * gpr_last_error_message (void)
 The same string as gpr_last_error (ABI 1.6). Never NULL. Fortran and the other bindings call this name.
size_t gpr_last_error_copy (char *buf, size_t capacity)
 Copy the thread-local error message into buf (capacity bytes, always terminated when capacity > 0). Returns the message length without the terminator, so a return value >= capacity means the copy was truncated. buf may be NULL when capacity is 0.
const char * gpr_status_name (int status)
 Short static name of a status code ("GPR_ERR_ORACLE"). Never NULL.
int gpr_last_status (void)
 Status of the last call on this thread that failed (ABI 1.1), like errno: a constructor that returns NULL leaves its reason here. Status-returning calls, constructors, NULL-handle accessors, and non-oracle destroy calls reset it to GPR_SUCCESS; successful live-handle and parameterless accessors preserve it, and all destroy calls preserve a pending GPR_ERR_ORACLE during cleanup.

Detailed Description

Macro Definition Documentation

◆ GPR_ABI_CHECK

#define GPR_ABI_CHECK ( )
Value:
#define GPR_C_ABI_MAJOR
ABI version of this header. See the ABI paragraph above.
Definition gpridge_c.h:78
#define GPR_C_ABI_MINOR
Definition gpridge_c.h:79
int gpr_abi_check(int header_major, int header_minor)
GPR_SUCCESS when the loaded library implements the ABI a caller was compiled against (same major,...

Check the loaded library against the header in use. Call once at start.

Definition at line 99 of file gpridge_c.h.

◆ GPR_C_ABI_MAJOR

#define GPR_C_ABI_MAJOR   1

ABI version of this header. See the ABI paragraph above.

Definition at line 78 of file gpridge_c.h.

◆ GPR_C_ABI_MINOR

#define GPR_C_ABI_MINOR   26

Definition at line 79 of file gpridge_c.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Status codes returned by the functions whose int result is a status.

Functions that return a count, a flag or a rank (gpr_backend_requires_mpi, gpr_mpi_world_rank, gpr_omp_max_threads, gpr_atoms_n_moving, gpr_model_n_observations, gpr_neb_result_converged, gpr_neb_result_n_images and similar) do not return these codes; their comments say what they return. GPR_ERR_NOT_CONVERGED comes back only from gpr_fes_rate_path_checked, when the saddle search fails. GPR_ERR_CHOLESKY comes back from gpr_model_predict_energy_variance_interval, gpr_model_predict_energy_variance_interval_checked and gpr_model_get_noise_floor_report when the factor or Schur certificate cannot be built. gpr_model_train_marginal_likelihood_checked returns GPR_ERR_OPTIMIZER when the fit throws std::runtime_error (or a class derived from it), or returns a non-finite objective or a wrong number of length scales.

The gpr_bq_* functions that build a posterior (gpr_bq_train_checked, gpr_bq_train_bounded_checked, gpr_bq_append_checked and gpr_bq_fit_hyperparameters_checked, and on a trained model gpr_bq_set_lengthscales_checked, gpr_bq_set_magn_sigma2, gpr_bq_set_extra_sigma2 and gpr_bq_set_basis) return GPR_ERR_CHOLESKY when the covariance does not factor (gpr::bo::BayesianQuadratureCholeskyError) and GPR_ERR_OPTIMIZER for any other gpr::bo::BayesianQuadratureInferenceError, including a numerical eigensolver failure or failed hyperparameter inference. The common handler below maps both, and the model keeps its previous state.

gpr_fes_train_checked returns GPR_ERR_CHOLESKY when the training covariance does not factor at the fitted hyperparameters (gpr::bo::FreeEnergyCholeskyError) and GPR_ERR_OPTIMIZER when the fit diverges (gpr::bo::FreeEnergyInferenceError). gpr_fes_rate_path_checked returns GPR_ERR_NOT_CONVERGED when it finds no index-one saddle of the posterior mean on the path (gpr::bo::FreeEnergySaddleNotFoundError) and GPR_ERR_UNSUPPORTED when the barrier at that saddle is not positive or too few posterior draws are accepted (gpr::bo::FreeEnergyRateUnsupportedError). The common handler maps all four, and the surrogate keeps its previous state.

Nine functions catch before the common handler below. gpr_model_predict_energy_variance_interval maps std::domain_error to GPR_ERR_CHOLESKY and any other std::exception to GPR_ERR_INTERNAL. gpr_model_get_noise_floor_report maps std::runtime_error to GPR_ERR_CHOLESKY. gpr_model_train_marginal_likelihood_checked maps std::runtime_error to GPR_ERR_OPTIMIZER. gpr_bq_create, gpr_bq_reset, gpr_bq_integrate_measure_checked and gpr_bq_integrate_uncertainty_checked map std::domain_error to GPR_ERR_UNSUPPORTED. gpr_set_training_product maps any std::exception to GPR_ERR_UNSUPPORTED except std::invalid_argument, std::length_error and std::bad_alloc, which it passes to the handler. gpr_check_model_package does the same except that it passes only std::bad_alloc. No exception other than these and gpr::bo::FreeEnergyRateUnsupportedError maps to GPR_ERR_UNSUPPORTED, and none maps to GPR_ERR_NULL_HANDLE, GPR_ERR_NOT_TRAINED or GPR_ERR_ABI.

GPR_ERR_NULL_HANDLE is not "a pointer argument was NULL". guard_model returns it for a NULL model and for a model that is not live. The two exceptions are gpr_model_predict_energy_variance_interval and gpr_model_get_noise_floor_report, which return it for a NULL model and do not test liveness. guard_neb returns it for a NULL NEB result and for one that is not live (gpr_neb_result_report and the three image readers). Those readers also return it when the live result has no path. gpr_potential_force and gpr_potential_force_with_uncertainty return it for a NULL potential and for one that is not live. reject_dead_atoms and reject_dead_potential return it only for a non-null handle that is not live; a NULL atoms or potential argument of a search is then GPR_ERR_INVALID_ARG, except where a local or periodic band allows a NULL atoms handle. gpr_model_init returns it for an atoms handle that is not live, and GPR_ERR_INVALID_ARG for a NULL atoms handle. usable_or_null clears the thread-local status and error to GPR_SUCCESS for NULL, preserves any prior error state for a live handle, and sets GPR_ERR_NULL_HANDLE for a handle that is not live; the accessor then returns its sentinel. Destroying NULL or a live handle clears non-oracle status and error to GPR_SUCCESS, while preserving a pending GPR_ERR_ORACLE during cleanup. Destroying a handle that is not live sets GPR_ERR_INVALID_ARG.

Any other C++ exception that reaches the boundary of a status function becomes: std::bad_alloc -> GPR_ERR_ALLOC; std::length_error -> GPR_ERR_SIZE_LIMIT; std::invalid_argument and std::domain_error -> GPR_ERR_INVALID_ARG; gpr::bo::BayesianQuadratureCholeskyError -> GPR_ERR_CHOLESKY; any other gpr::bo::BayesianQuadratureInferenceError -> GPR_ERR_OPTIMIZER; gpr::bo::FreeEnergyCholeskyError -> GPR_ERR_CHOLESKY; gpr::bo::FreeEnergyInferenceError -> GPR_ERR_OPTIMIZER; gpr::bo::FreeEnergyRateUnsupportedError -> GPR_ERR_UNSUPPORTED; gpr::bo::FreeEnergySaddleNotFoundError -> GPR_ERR_NOT_CONVERGED; any other std::exception -> GPR_ERR_ORACLE after an oracle callback failed in the call, else GPR_ERR_INTERNAL; anything else -> GPR_ERR_INTERNAL.

Enumerator
GPR_SUCCESS 
GPR_ERR_NULL_HANDLE 
GPR_ERR_INVALID_ARG 
GPR_ERR_NOT_TRAINED 
GPR_ERR_ALLOC 

Memory allocation failed

GPR_ERR_CHOLESKY 
GPR_ERR_OPTIMIZER 
GPR_ERR_NOT_CONVERGED 
GPR_ERR_SIZE_LIMIT 

ABI 1.1: problem exceeds an index limit (LP64 ScaLAPACK, MKL)

GPR_ERR_ORACLE 

ABI 1.1: the oracle failed past the bound the search tolerates

GPR_ERR_UNSUPPORTED 

ABI 1.1: feature absent from this build, or a library or host it needs is missing

GPR_ERR_ABI 

ABI 1.1: header and library disagree

GPR_ERR_OUT_OF_SUPPORT 

ABI 1.20: a query's posterior energy std exceeds the caller's threshold

GPR_ERR_UNIT_MISMATCH 

ABI 1.20: inputs that must share a unit were computed in different ones

GPR_ERR_INTERNAL 

Definition at line 207 of file gpridge_c.h.

207 {
208 GPR_SUCCESS = 0,
212 GPR_ERR_ALLOC = -4,
213 GPR_ERR_CHOLESKY = -5,
216 GPR_ERR_SIZE_LIMIT = -8,
218 GPR_ERR_ORACLE = -9,
220 GPR_ERR_UNSUPPORTED = -10,
222 GPR_ERR_ABI = -11,
227 GPR_ERR_INTERNAL = -99
228};
@ GPR_ERR_INVALID_ARG
Definition gpridge_c.h:210
@ GPR_ERR_NULL_HANDLE
Definition gpridge_c.h:209
@ GPR_SUCCESS
Definition gpridge_c.h:208
@ GPR_ERR_UNSUPPORTED
Definition gpridge_c.h:220
@ GPR_ERR_NOT_CONVERGED
Definition gpridge_c.h:215
@ GPR_ERR_OPTIMIZER
Definition gpridge_c.h:214
@ GPR_ERR_NOT_TRAINED
Definition gpridge_c.h:211
@ GPR_ERR_OUT_OF_SUPPORT
Definition gpridge_c.h:223
@ GPR_ERR_UNIT_MISMATCH
Definition gpridge_c.h:225
@ GPR_ERR_CHOLESKY
Definition gpridge_c.h:213
@ GPR_ERR_ABI
Definition gpridge_c.h:222
@ GPR_ERR_ORACLE
Definition gpridge_c.h:218
@ GPR_ERR_INTERNAL
Definition gpridge_c.h:227
@ GPR_ERR_SIZE_LIMIT
Definition gpridge_c.h:216
@ GPR_ERR_ALLOC
Definition gpridge_c.h:212

Function Documentation

◆ gpr_abi_check()

int gpr_abi_check ( int header_major,
int header_minor )

GPR_SUCCESS when the loaded library implements the ABI a caller was compiled against (same major, library minor at least header_minor); GPR_ERR_ABI with both versions in gpr_last_error() otherwise.

◆ gpr_abi_version()

void gpr_abi_version ( int * major,
int * minor )

ABI version of the loaded library. Any pointer may be NULL.

◆ gpr_last_error()

const char * gpr_last_error ( void )

Thread-local error message from last failing call. Never NULL.

◆ gpr_last_error_copy()

size_t gpr_last_error_copy ( char * buf,
size_t capacity )

Copy the thread-local error message into buf (capacity bytes, always terminated when capacity > 0). Returns the message length without the terminator, so a return value >= capacity means the copy was truncated. buf may be NULL when capacity is 0.

◆ gpr_last_error_message()

const char * gpr_last_error_message ( void )

The same string as gpr_last_error (ABI 1.6). Never NULL. Fortran and the other bindings call this name.

◆ gpr_last_status()

int gpr_last_status ( void )

Status of the last call on this thread that failed (ABI 1.1), like errno: a constructor that returns NULL leaves its reason here. Status-returning calls, constructors, NULL-handle accessors, and non-oracle destroy calls reset it to GPR_SUCCESS; successful live-handle and parameterless accessors preserve it, and all destroy calls preserve a pending GPR_ERR_ORACLE during cleanup.

◆ gpr_status_name()

const char * gpr_status_name ( int status)

Short static name of a status code ("GPR_ERR_ORACLE"). Never NULL.

◆ gpr_version()

const char * gpr_version ( void )

Library version string ("major.minor.patch"). Never NULL.

◆ gpr_version_components()

void gpr_version_components ( int * major,
int * minor,
int * patch )

Version components. Any pointer may be NULL.