Loading...
Searching...
No Matches
gpr::optim_abi Namespace Reference

Classes

struct  ResultLayoutStamp

Functions

ResultLayoutStamp libraryResultLayout ()
bool operator== (const ResultLayoutStamp &a, const ResultLayoutStamp &b) noexcept
ResultLayoutStamp compiledResultLayout () noexcept
 What this translation unit compiled against.
std::string describe (const ResultLayoutStamp &stamp)
std::string resultLayoutMismatch (const ResultLayoutStamp &driver, const ResultLayoutStamp &library)
 Empty when the stamps agree. Otherwise a message naming both.
void refuseMismatchedResultLayout (const ResultLayoutStamp &driver, const ResultLayoutStamp &library)
void requireResultLayout ()

Variables

constexpr std::uint32_t kResultLayoutVersion = 2

Function Documentation

◆ compiledResultLayout()

ResultLayoutStamp gpr::optim_abi::compiledResultLayout ( )
inlinenodiscardnoexcept

What this translation unit compiled against.

Definition at line 47 of file OptimAbi.h.

48{
50 static_cast<std::uint32_t>(sizeof(neb::GPNEBResult)),
51 static_cast<std::uint32_t>(sizeof(neb::OCINEBResult))};
52}
constexpr std::uint32_t kResultLayoutVersion
Definition OptimAbi.h:30

◆ describe()

std::string gpr::optim_abi::describe ( const ResultLayoutStamp & stamp)
inlinenodiscard

Definition at line 58 of file OptimAbi.h.

59{
60 return std::to_string(stamp.version) + "/" +
61 std::to_string(stamp.gpneb_result_bytes) + "/" +
62 std::to_string(stamp.ocineb_result_bytes);
63}

◆ libraryResultLayout()

ResultLayoutStamp gpr::optim_abi::libraryResultLayout ( )
nodiscard

What libgpridge was built with. Defined in the library, not inline, so a stale driver cannot satisfy the check with its own copy.

Definition at line 9 of file OptimAbi.cpp.

10{
11 // Compiled into libgpridge, so sizeof is the library's layout.
12 return compiledResultLayout();
13}
ResultLayoutStamp compiledResultLayout() noexcept
What this translation unit compiled against.
Definition OptimAbi.h:47

◆ operator==()

bool gpr::optim_abi::operator== ( const ResultLayoutStamp & a,
const ResultLayoutStamp & b )
inlinenodiscardnoexcept

Definition at line 38 of file OptimAbi.h.

40{
41 return a.version == b.version &&
44}

◆ refuseMismatchedResultLayout()

void gpr::optim_abi::refuseMismatchedResultLayout ( const ResultLayoutStamp & driver,
const ResultLayoutStamp & library )
inline

Definition at line 85 of file OptimAbi.h.

87{
88 const std::string message = resultLayoutMismatch(driver, library);
89 if (!message.empty()) throw std::runtime_error(message);
90}
std::string resultLayoutMismatch(const ResultLayoutStamp &driver, const ResultLayoutStamp &library)
Empty when the stamps agree. Otherwise a message naming both.
Definition OptimAbi.h:66

◆ requireResultLayout()

void gpr::optim_abi::requireResultLayout ( )
inline

Definition at line 92 of file OptimAbi.h.

93{
95}
void refuseMismatchedResultLayout(const ResultLayoutStamp &driver, const ResultLayoutStamp &library)
Definition OptimAbi.h:85
ResultLayoutStamp libraryResultLayout()
Definition OptimAbi.cpp:9

◆ resultLayoutMismatch()

std::string gpr::optim_abi::resultLayoutMismatch ( const ResultLayoutStamp & driver,
const ResultLayoutStamp & library )
inlinenodiscard

Empty when the stamps agree. Otherwise a message naming both.

Definition at line 66 of file OptimAbi.h.

68{
69 if (driver == library) return {};
70 return "libgpridge result layout mismatch: this program was built "
71 "against layout " +
72 std::to_string(driver.version) + " (GPNEBResult " +
73 std::to_string(driver.gpneb_result_bytes) + " bytes, OCINEBResult " +
74 std::to_string(driver.ocineb_result_bytes) +
75 " bytes) but the loaded library reports layout " +
76 std::to_string(library.version) + " (GPNEBResult " +
77 std::to_string(library.gpneb_result_bytes) +
78 " bytes, OCINEBResult " +
79 std::to_string(library.ocineb_result_bytes) +
80 " bytes). Rebuild gprn and gprd against this libgpridge; a "
81 "stale driver frees the wrong offsets in OCINEBResult's "
82 "destructor.";
83}

Variable Documentation

◆ kResultLayoutVersion

std::uint32_t gpr::optim_abi::kResultLayoutVersion = 2
inlineconstexpr

Bump when GPNEBResult or OCINEBResult changes layout. 2: GPNEBResult::prior_observations (OCINEBResult embeds that result).

Definition at line 30 of file OptimAbi.h.