Loading...
Searching...
No Matches
gpr::neb::EonRelaxClient Class Reference

#include <gpr/neb/EonRelaxClient.h>

Public Member Functions

 EonRelaxClient ()=default
 ~EonRelaxClient ()
 EonRelaxClient (const EonRelaxClient &)=delete
EonRelaxClient & operator= (const EonRelaxClient &)=delete
bool load (const std::string &path={})
bool loaded () const noexcept
bool create (const void *config=nullptr, std::size_t config_len=0)
bool created () const noexcept
int run (eon_relax_band_t &band, eon_relax_surface_fn surface, void *user, eon_relax_outcome_t &outcome)
int step (eon_relax_band_t &band, eon_relax_surface_fn surface, void *user, eon_relax_outcome_t &outcome)
int reset ()
int setSurfaceEpoch (std::uint64_t epoch)
int lastError () const
void destroy ()
const std::string & lastMessage () const noexcept
eon_relax_version_t stamp () const noexcept

Detailed Description

dlopen client for the eOn tier-2 relaxation engine: the host hands a band and a surface callback to eOn, which owns NudgedElasticBand / MinModeSaddleSearch. The GP stays the surface; the saddle mechanics leave the tree.

Discovery: an explicit path, else the GPR_EON_RELAX_ENGINE environment variable. The ABI stamp is checked on load: a major or layout mismatch refuses the library (closed contract, no silent fallback).

Definition at line 29 of file EonRelaxClient.h.

Constructor & Destructor Documentation

◆ EonRelaxClient() [1/2]

gpr::neb::EonRelaxClient::EonRelaxClient ( )
default

◆ ~EonRelaxClient()

gpr::neb::EonRelaxClient::~EonRelaxClient ( )

Definition at line 18 of file EonRelaxClient.cpp.

19{
20 destroy();
21 if (lib_ != nullptr) {
22 dlclose(lib_);
23 lib_ = nullptr;
24 }
25}

◆ EonRelaxClient() [2/2]

gpr::neb::EonRelaxClient::EonRelaxClient ( const EonRelaxClient & )
delete

Member Function Documentation

◆ create()

bool gpr::neb::EonRelaxClient::create ( const void * config = nullptr,
std::size_t config_len = 0 )

Create the engine instance from a Cap'n Proto RelaxEngineParams flat-array message; NULL/empty config selects the engine's documented defaults (kind=NEB).

Definition at line 98 of file EonRelaxClient.cpp.

99{
100 if (!loaded()) {
101 message_ = "engine library not loaded";
102 return false;
103 }
104 destroy();
105 char errbuf[1024] = {0};
106 engine_ = create_(config, config_len, errbuf, sizeof errbuf);
107 if (engine_ == nullptr) {
108 message_ = errbuf[0] != '\0' ? errbuf : "eon_relax_create failed";
109 return false;
110 }
111 message_.clear();
112 return true;
113}
bool loaded() const noexcept
size_t char * errbuf
size_t config_len

◆ created()

bool gpr::neb::EonRelaxClient::created ( ) const
inlinenodiscardnoexcept

Definition at line 49 of file EonRelaxClient.h.

50 {
51 return engine_ != nullptr;
52 }

◆ destroy()

void gpr::neb::EonRelaxClient::destroy ( )

Definition at line 159 of file EonRelaxClient.cpp.

160{
161 if (engine_ != nullptr && destroy_ != nullptr) {
162 destroy_(engine_);
163 }
164 engine_ = nullptr;
165}

◆ lastError()

int gpr::neb::EonRelaxClient::lastError ( ) const
nodiscard

Definition at line 153 of file EonRelaxClient.cpp.

154{
155 if (!created() || last_error_ == nullptr) return EON_RELAX_NULL_ENGINE;
156 return last_error_(engine_);
157}
bool created() const noexcept
@ EON_RELAX_NULL_ENGINE

◆ lastMessage()

const std::string & gpr::neb::EonRelaxClient::lastMessage ( ) const
inlinenodiscardnoexcept

Definition at line 71 of file EonRelaxClient.h.

72 {
73 return message_;
74 }

◆ load()

bool gpr::neb::EonRelaxClient::load ( const std::string & path = {})

Load the engine library. Empty path consults GPR_EON_RELAX_ENGINE. Returns false with a reason in lastMessage() on failure.

Definition at line 27 of file EonRelaxClient.cpp.

28{
29 std::string resolved = path;
30 if (resolved.empty()) {
31 const char* env = std::getenv("GPR_EON_RELAX_ENGINE");
32 if (env != nullptr) resolved = env;
33 }
34 if (resolved.empty()) {
35 message_ = "no engine path: pass one or set GPR_EON_RELAX_ENGINE";
36 return false;
37 }
38 destroy();
39 if (lib_ != nullptr) {
40 dlclose(lib_);
41 lib_ = nullptr;
42 }
43 run_ = nullptr;
44 step_ = nullptr;
45 reset_ = nullptr;
46 set_epoch_ = nullptr;
47 last_error_ = nullptr;
48 destroy_ = nullptr;
49 create_ = nullptr;
50 lib_ = dlopen(resolved.c_str(), RTLD_NOW | RTLD_LOCAL);
51 if (lib_ == nullptr) {
52 const char* err = dlerror();
53 message_ = err != nullptr ? err : "dlopen failed";
54 return false;
55 }
56 auto* stamp =
57 reinterpret_cast<abi_stamp_fn>(dlsym(lib_, "eon_relax_abi_stamp"));
58 auto* available =
59 reinterpret_cast<available_fn>(dlsym(lib_, "eon_relax_available"));
60 create_ = reinterpret_cast<create_fn>(dlsym(lib_, "eon_relax_create"));
61 run_ = reinterpret_cast<run_fn>(dlsym(lib_, "eon_relax_run"));
62 step_ = reinterpret_cast<step_fn>(dlsym(lib_, "eon_relax_step"));
63 reset_ = reinterpret_cast<reset_fn>(dlsym(lib_, "eon_relax_reset"));
64 set_epoch_ = reinterpret_cast<set_epoch_fn>(
65 dlsym(lib_, "eon_relax_set_surface_epoch"));
66 last_error_ =
67 reinterpret_cast<last_error_fn>(dlsym(lib_, "eon_relax_last_error"));
68 destroy_ = reinterpret_cast<destroy_fn>(dlsym(lib_, "eon_relax_destroy"));
69 if (stamp == nullptr || available == nullptr || create_ == nullptr ||
70 run_ == nullptr || step_ == nullptr || reset_ == nullptr ||
71 set_epoch_ == nullptr || last_error_ == nullptr ||
72 destroy_ == nullptr) {
73 message_ = "mandatory eon_relax symbols missing";
74 dlclose(lib_);
75 lib_ = nullptr;
76 run_ = nullptr;
77 return false;
78 }
79 if (stamp(&stamp_) != 0 || stamp_.major != EON_RELAX_ABI_MAJOR ||
80 stamp_.minor < EON_RELAX_ABI_MINOR) {
81 message_ = "eon_relax ABI stamp mismatch";
82 dlclose(lib_);
83 lib_ = nullptr;
84 run_ = nullptr;
85 return false;
86 }
87 if (available() == 0) {
88 message_ = "eon_relax reports unavailable";
89 dlclose(lib_);
90 lib_ = nullptr;
91 run_ = nullptr;
92 return false;
93 }
94 message_.clear();
95 return true;
96}
eon_relax_version_t stamp() const noexcept
#define EON_RELAX_ABI_MAJOR
#define EON_RELAX_ABI_MINOR
bool available() noexcept
Definition CutlassGemm.h:43
bool resolved(Dual value, Dual error, const BridgeResidualOptions &options)

◆ loaded()

bool gpr::neb::EonRelaxClient::loaded ( ) const
inlinenodiscardnoexcept

Definition at line 40 of file EonRelaxClient.h.

41 {
42 return run_ != nullptr;
43 }

◆ operator=()

EonRelaxClient & gpr::neb::EonRelaxClient::operator= ( const EonRelaxClient & )
delete

◆ reset()

int gpr::neb::EonRelaxClient::reset ( )

Definition at line 135 of file EonRelaxClient.cpp.

136{
137 if (!created()) {
138 message_ = "engine instance not created";
140 }
141 return reset_(engine_);
142}

◆ run()

int gpr::neb::EonRelaxClient::run ( eon_relax_band_t & band,
eon_relax_surface_fn surface,
void * user,
eon_relax_outcome_t & outcome )

Run the bound engine over a caller-owned band. Returns the raw eon_relax_rc_t; on 0 the outcome is filled and band positions are updated in place.

Definition at line 115 of file EonRelaxClient.cpp.

117{
118 if (!created()) {
119 message_ = "engine instance not created";
121 }
122 return run_(engine_, &band, surface, user, &outcome);
123}
eon_relax_band_t eon_relax_surface_fn surface
eon_relax_band_t * band
eon_relax_band_t eon_relax_surface_fn void * user

◆ setSurfaceEpoch()

int gpr::neb::EonRelaxClient::setSurfaceEpoch ( std::uint64_t epoch)

Definition at line 144 of file EonRelaxClient.cpp.

145{
146 if (!created()) {
147 message_ = "engine instance not created";
149 }
150 return set_epoch_(engine_, epoch);
151}
uint64_t epoch

◆ stamp()

eon_relax_version_t gpr::neb::EonRelaxClient::stamp ( ) const
inlinenodiscardnoexcept

Definition at line 75 of file EonRelaxClient.h.

76 {
77 return stamp_;
78 }

◆ step()

int gpr::neb::EonRelaxClient::step ( eon_relax_band_t & band,
eon_relax_surface_fn surface,
void * user,
eon_relax_outcome_t & outcome )

One eOn NEB optimizer step. Surface and user must stay the same across steps until reset().

Definition at line 125 of file EonRelaxClient.cpp.

127{
128 if (!created()) {
129 message_ = "engine instance not created";
131 }
132 return step_(engine_, &band, surface, user, &outcome);
133}

The documentation for this class was generated from the following files: