Loading...
Searching...
No Matches
GenericEngineLoader.h
Go to the documentation of this file.
1#pragma once
2/*
3** This file is part of eOn.
4**
5** SPDX-License-Identifier: BSD-3-Clause
6**
7** Copyright (c) 2010--present, eOn Development Team
8** All rights reserved.
9**
10** Repo:
11** https://github.com/TheochemUI/eOn
12*/
13/*
14** Thin loader for any rgpot engine plugin behind the generic C ABI
15** (engine_c_abi.h): one symbol set, backend selection by library name,
16** configuration as a Cap'n Proto message on the shared wire. New
17** backends need no new loader code.
18*/
19#include "engine_c_abi.h"
20#include <cstddef>
21#include <string>
22#include <vector>
23
26 std::string library;
28 std::string env_var;
30 std::string engine_path;
33 std::vector<unsigned char> config;
35 std::string tag;
36};
37
39public:
40 explicit GenericEngineLoader(const GenericEngineOptions &opt);
44
45 [[nodiscard]] bool available() const noexcept { return m_pot != nullptr; }
46 void force(long N, const double *R, const int *atomicNrs, double *F,
47 double *U, double *variance, const double *box) const;
48
49private:
50 void *m_lib{nullptr};
52 std::string m_tag;
53 using create_fn = RgpotEnginePot *(*)(const void *, size_t, char *, size_t);
54 using destroy_fn = void (*)(RgpotEnginePot *);
55 using force_fn = int (*)(RgpotEnginePot *, long, const double *, const int *,
56 double *, double *, double *, const double *,
60 force_fn m_force{nullptr};
61};
void(*)(RgpotEnginePot *) destroy_fn
GenericEngineLoader & operator=(const GenericEngineLoader &)=delete
GenericEngineLoader(const GenericEngineOptions &opt)
void force(long N, const double *R, const int *atomicNrs, double *F, double *U, double *variance, const double *box) const
int(*)(RgpotEnginePot *, long, const double *, const int *, double *, double *, double *, const double *, rgpot_engine_coord_transform, void *) force_fn
RgpotEnginePot *(*)(const void *, size_t, char *, size_t) create_fn
GenericEngineLoader(const GenericEngineLoader &)=delete
bool available() const noexcept
Generic C ABI for rgpot engine plugins.
struct RgpotEnginePot RgpotEnginePot
int(* rgpot_engine_coord_transform)(void *user, long nAtoms, double *positions, double *box)
Optional host-side transform applied by the engine to its scratch copy of (positions,...
std::string tag
Backend tag for error messages ("uma", ...).
std::string env_var
Optional env var naming an explicit .so path (checked first).
std::vector< unsigned char > config
Cap'n Proto flat-array message (the engine's params struct on the shared Potentials....
std::string engine_path
Optional explicit .so path from config.
std::string library
Library basename to search for, e.g. "libuma_engine.so".