5 #ifndef _HEBench_API_Bridge_Base_Engine_H_7e5fa8c2415240ea93eff148ed73539b
6 #define _HEBench_API_Bridge_Base_Engine_H_7e5fa8c2415240ea93eff148ed73539b
10 #include <unordered_map>
21 class BenchmarkDescription;
86 static constexpr std::int64_t
tag = 0x8000000000000000;
126 const std::string &err_desc);
140 const std::unordered_map<hebench::APIBridge::Scheme, std::string> &
147 const std::unordered_map<hebench::APIBridge::Security, std::string> &
175 std::uint64_t default_count)
const;
189 template <
class T,
typename... Args>
205 Args &&... args)
const;
247 template <
class T,
typename... Args>
268 template <
class T,
typename... Args>
280 template <
class T,
typename... Args>
293 std::shared_ptr<T>
createRAII(Args &&... args)
const;
294 template <
class T,
typename... Args>
368 static const std::string UnknownErrorMsg;
370 static std::string m_s_last_error_description;
371 static std::unordered_map<hebench::APIBridge::ErrorCode, std::string> m_map_error_desc;
373 std::vector<std::shared_ptr<BenchmarkDescription>> m_descriptors;
374 std::unordered_map<hebench::APIBridge::Scheme, std::string> m_map_scheme_name;
375 std::unordered_map<hebench::APIBridge::Security, std::string> m_map_security_name;
378 template <
class T,
typename... Args>
380 Args &&... args)
const
396 template <
class T,
typename... Args>
405 if ((h.
tag & extra_tags) != extra_tags)
415 return p_obj->
get<T>();
418 template <
class T,
typename... Args>
421 std::shared_ptr<T> raii = createRAII<T>(std::forward<Args>(args)...);
426 template <
class T,
typename... Args>
429 std::shared_ptr<T> retval = std::shared_ptr<T>(this->createObj<T>(std::forward<Args>(args)...),
431 this->destroyObj<T>(p);
436 template <
class T,
typename... Args>
439 return new T(std::forward<Args>(args)...);
Top level opaque benchmark class.
Base class that encapsulates common behavior of backend engines.
std::shared_ptr< BenchmarkDescription > matchBenchmark(hebench::APIBridge::Handle h_desc) const
Retrieves the BenchmarkDescription object pointed by the specified handle.
T & retrieveFromHandle(hebench::APIBridge::Handle h, std::int64_t extra_tags=0) const
Retrieves the object of type T encapsulated in an opaque HEBench handle by method createHandle().
hebench::APIBridge::Handle createHandle(std::uint64_t size, std::int64_t extra_tags, Args &&... args) const
Encapsulates an object of type T in an opaque HEBench handle.
static const std::string & getErrorDesc(hebench::APIBridge::ErrorCode err_code)
Retrieves the description of a specific error code.
std::shared_ptr< T > createRAII(Args &&... args) const
Creates a smart pointer of the specified template type.
std::uint64_t getWorkloadParamsCount(hebench::APIBridge::Handle h_bench_desc) const
Retrieves the number of workload parameters for the decribed benchmark.
const std::unordered_map< hebench::APIBridge::Security, std::string > & securityName() const
Retrieves a dictionary that maps security types known to this benchmark to their human readable names...
hebench::APIBridge::Handle createBenchmark(hebench::APIBridge::Handle h_bench_desc, const hebench::APIBridge::WorkloadParams *p_params)
Creates the benchmark specified by the descriptor.
BaseEngine & operator=(BaseEngine &&)=delete
void addBenchmarkDescription(std::shared_ptr< BenchmarkDescription > p_desc)
Adds a new benchmark to the list of benchmarks to register by this backend.
BaseEngine(const BaseEngine &)=delete
std::string getBenchmarkDescriptionEx(hebench::APIBridge::Handle h_bench_desc, const hebench::APIBridge::WorkloadParams *p_w_params) const
Retrieves backend specific text description for a benchmark descriptor.
void destroyObj(T *p) const
const std::unordered_map< hebench::APIBridge::Scheme, std::string > & schemeName() const
Retrieves a dictionary that maps schemes known to this benchmark to their human readable names.
BaseEngine(BaseEngine &&)=delete
void destroyBenchmark(hebench::APIBridge::Handle h_bench)
Destroys and cleans up a benchmark created by createBenchmark().
void subscribeBenchmarks(hebench::APIBridge::Handle *p_h_bench_descs, std::uint64_t count) const
Retrieves the benchmarks for which the backend is registering to perform.
static constexpr std::int64_t tag
Used to identify this class when returned as a handle to Test Harness.
std::int64_t classTag() const override
Retrieves the tag of the class to which this object belongs.
void addSchemeName(hebench::APIBridge::Scheme scheme, const std::string &name)
Adds a new supported scheme and name pair to the list of schemes supported by this backend.
EngineObject * createEngineObj(Args &&... args) const
Creates an EngineObject that wraps an object of type T.
hebench::APIBridge::Handle duplicateHandle(hebench::APIBridge::Handle h, std::int64_t new_tag, std::int64_t check_tags) const
Duplicates a handle created by createhandle().
T * createObj(Args &&... args) const
static hebench::APIBridge::ErrorCode getLastError()
Retrieves the last error that occurred as set by setLastError().
static void setLastError(hebench::APIBridge::ErrorCode value)
Sets the last error code that occurred.
virtual void init()=0
Initializes the backend engine and populates the backend description.
std::uint64_t getDefaultWorkloadParamsCount(hebench::APIBridge::Handle h_bench_desc) const
Retrieves the number of sets of default arguments supported by this benchmark's workload.
static void addErrorCode(hebench::APIBridge::ErrorCode code, const std::string &description)
Adds a new error code and the error description to the list of possible error codes that this backend...
static const std::string & getLastErrorDesc()
Retrieves the description of the last error that occurred as set by setLastError().
BaseEngine & operator=(const BaseEngine &)=delete
void describeBenchmark(hebench::APIBridge::Handle h_bench_desc, hebench::APIBridge::BenchmarkDescriptor *p_bench_desc, hebench::APIBridge::WorkloadParams *p_default_params, std::uint64_t default_count) const
std::uint64_t subscribeBenchmarkCount() const
Retrieves the number of benchmarks for which the backend is registering to perform.
void addSecurityName(hebench::APIBridge::Security security, const std::string &name)
Adds a new supported security and name pair to the list of securitty types supported by this backend.
Base class for objects representing a specific benchmark based on an HEBench benchmark descriptor.
Helper class to encapsulate objects that will cross the boundary of the API Bridge.
std::int64_t classTag() const override
Retrieves the tag of the class to which this object belongs.
static constexpr std::int64_t tag
Used to identify this class when returned as a handle to Test Harness.
Represents an object with a tag.
static constexpr std::int64_t MaskReservedBits
Mask representing all bits reserved by C++ wrapper.
#define HEBERROR_MSG_CLASS(message)
#define HEBERROR_DECLARE_CLASS_NAME(class_name)
std::int32_t Scheme
Open-ended homomorphic encryption scheme ID.
std::int32_t Security
Open-ended homomorphic encryption scheme security ID.
std::uint64_t size
Size of underlying data.
void * p
Pointer to underlying data.
std::int32_t ErrorCode
Return value for API bridge functions.
std::int64_t tag
Optional tag.
Defines a benchmark test.
Specifies the parameters for a workload.
Structure to contain flexible data.
std::string to_string(const std::string_view &s)
BaseEngine * createEngine(const std::int8_t *p_buffer, std::uint64_t size)
Creates a new BaseEngine object.
void destroyEngine(BaseEngine *p)
Destroys and cleans up resources from an engine created by createEngine().
BenchmarkDescription * p_bench_description
BaseBenchmark * p_benchmark
Bundles a benchmark and its description to cross the API Bridge as a handle.
#define HEBENCH_ECODE_CRITICAL_ERROR
Specifies a critical error.