5#ifndef GPR_POTENTIALS_ENGINEPOTENTIAL_H_
6#define GPR_POTENTIALS_ENGINEPOTENTIAL_H_
28 [[nodiscard]]
int status() const noexcept
32 [[nodiscard]]
bool fatal() const noexcept
36 [[nodiscard]]
const std::string&
library() const noexcept
97 static std::unique_ptr<EnginePotential>
open(
98 const std::string&
library,
const std::vector<unsigned char>& config,
99 std::string& err,
bool torch_cuda =
false,
int oracle_threads = 1);
107 int force(
long n_atoms,
const double* positions,
const int* atomic_nrs,
108 const double* box,
double* forces,
double* energy,
114 return batch_ !=
nullptr;
119 int forceBatch(
long n_systems,
long n_atoms,
const double* positions,
120 const int* atomic_nrs,
const double* boxes,
double* forces,
121 double* energies,
double* variances);
126 return set_callbacks_ !=
nullptr;
130 int setCallbacks(
const RgpotEngineCallbacks& callbacks);
135 return hessian_checked_ !=
nullptr;
140 std::size_t positions_len,
const int* atomic_nrs,
141 double* hessian_out, std::size_t hessian_len,
147 return hessian_action_checked_ !=
nullptr;
153 std::size_t positions_len,
const int* atomic_nrs,
154 const double* direction, std::size_t direction_len,
155 double* hv_out, std::size_t hv_len,
156 const double* box,
unsigned long long* ops_out,
163 return prediction_supported_checked_ !=
nullptr;
168 std::size_t positions_len,
169 const int* atomic_nrs,
const double* box,
175 return gpr_stats_ !=
nullptr;
182 [[nodiscard]]
unsigned long long modelState()
const;
186 int hint(
const std::vector<unsigned char>& message, std::string& err);
201 int hvp(
long n_atoms,
const double* positions,
const int* atomic_nrs,
202 const double* direction,
double* hv_out,
const double* box,
211 int taylorJet(
long n_systems,
long n_atoms,
const double* positions,
212 const int* atomic_nrs,
const double* directions,
long order,
214 const double* boxes, std::string& err);
218 int setCache(
const char* path, std::string& err);
222 int cacheCounts(std::uint64_t& computed, std::uint64_t& served,
227 [[nodiscard]] std::string
lastError()
const;
240 return oracle_threads_;
243 [[nodiscard]]
const std::string&
library() const noexcept
250 return resolved_path_;
253 [[nodiscard]]
bool dead() const noexcept
268 int noteCall(
int status,
const char* operation, std::string& err);
270 void* handle_ =
nullptr;
271 void* pot_ =
nullptr;
272 void* force_ =
nullptr;
273 void* batch_ =
nullptr;
274 void* set_callbacks_ =
nullptr;
275 void* hessian_checked_ =
nullptr;
276 void* hessian_action_checked_ =
nullptr;
277 void* prediction_supported_checked_ =
nullptr;
278 void* gpr_stats_ =
nullptr;
280 void* torch_cuda_ =
nullptr;
281 void* destroy_ =
nullptr;
282 void* model_state_ =
nullptr;
283 void* hint_ =
nullptr;
284 void* set_num_threads_ =
nullptr;
285 void* caps_ =
nullptr;
286 void* hvp_ =
nullptr;
287 void* taylor_jet_ =
nullptr;
288 void* set_cache_ =
nullptr;
289 void* cache_counts_ =
nullptr;
290 void* unload_policy_ =
nullptr;
291 void* last_error_ =
nullptr;
293 int abi_version_ = 0;
294 int oracle_threads_ = 1;
296 std::string library_;
297 std::string resolved_path_;
EngineError(std::string library, int status, const std::string &what)
const std::string & library() const noexcept
bool fatal() const noexcept
int status() const noexcept
std::string lastError() const
int hessianChecked(long n_atoms, const double *positions, std::size_t positions_len, const int *atomic_nrs, double *hessian_out, std::size_t hessian_len, const double *box)
Extent-checked dense Hessian at one geometry.
const std::string & resolvedPath() const noexcept
Absolute path of the loaded object, from the dynamic loader.
int gprStats(RgpotEngineGprStats &stats_out) const
Read learning-engine operation counters.
void setThreadCount(int threads)
int setCache(const char *path, std::string &err)
EnginePotential & operator=(const EnginePotential &)=delete
bool hasBatch() const noexcept
True when the engine exports rgpot_engine_force_batch.
int force(long n_atoms, const double *positions, const int *atomic_nrs, const double *box, double *forces, double *energy, double *variance)
static PotentialWrapper wrap(std::shared_ptr< EnginePotential > engine)
int abiVersion() const noexcept
static std::unique_ptr< EnginePotential > open(const std::string &library, const std::vector< unsigned char > &config, std::string &err, bool torch_cuda=false, int oracle_threads=1)
int caps(EngineCaps &out, std::string &err)
bool hasHessianActionChecked() const noexcept
True when the engine exports rgpot_engine_hessian_action_checked.
bool hasGprStats() const noexcept
True when the engine exports rgpot_engine_gpr_stats.
int cacheCounts(std::uint64_t &computed, std::uint64_t &served, std::string &err)
int setCallbacks(const RgpotEngineCallbacks &callbacks)
Register host callbacks for a learning engine.
bool hasCallbacks() const noexcept
True when the engine exports rgpot_engine_set_callbacks.
int hessianActionChecked(long n_atoms, const double *positions, std::size_t positions_len, const int *atomic_nrs, const double *direction, std::size_t direction_len, double *hv_out, std::size_t hv_len, const double *box, unsigned long long *ops_out, double *scale_out)
const std::string & library() const noexcept
int hvp(long n_atoms, const double *positions, const int *atomic_nrs, const double *direction, double *hv_out, const double *box, std::string &err)
EngineAbiStamp abiStamp() const noexcept
The stamp the plugin reported, or {1, 0, 1} when it exports none.
int taylorJet(long n_systems, long n_atoms, const double *positions, const int *atomic_nrs, const double *directions, long order, double *jet_out, EngineDerivativeReport *report, const double *boxes, std::string &err)
EnginePotential(const EnginePotential &)=delete
int predictionSupportedChecked(long n_atoms, const double *positions, std::size_t positions_len, const int *atomic_nrs, const double *box, int *supported_out)
Extent-checked prediction-support query.
int hint(const std::vector< unsigned char > &message, std::string &err)
int threadCount() const noexcept
OpenMP team requested explicitly by the host for every engine call.
bool dead() const noexcept
True once a negative status was returned: the handle is unusable.
unsigned long long modelState() const
Monotone model-state counter; zero for an engine without one.
int forceBatch(long n_systems, long n_atoms, const double *positions, const int *atomic_nrs, const double *boxes, double *forces, double *energies, double *variances)
bool hasPredictionSupportedChecked() const noexcept
bool hasHessianChecked() const noexcept
True when the engine exports rgpot_engine_hessian_checked.
Type-erased wrapper around any potential that provides a force() interface.
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
Potential wrappers and the batched oracle interface.