21 const std::string BaseEngine::UnknownErrorMsg =
"Unknown Error";
23 std::string BaseEngine::m_s_last_error_description;
24 std::unordered_map<hebench::APIBridge::ErrorCode, std::string> BaseEngine::m_map_error_desc = {
37 auto it = m_map_error_desc.find(err_code);
38 if (it == m_map_error_desc.end())
39 return UnknownErrorMsg;
50 const std::string &err_desc)
53 m_s_last_error_description = err_desc;
59 std::shared_ptr<BenchmarkDescription> p_bd =
matchBenchmark(h_bench_desc);
64 return p_bd->getBenchmarkDescription(p_w_params);
69 m_descriptors.push_back(p_desc);
74 if (m_map_error_desc.count(code) > 0)
77 m_map_error_desc[code] = description;
82 if (m_map_scheme_name.count(scheme) > 0)
85 m_map_scheme_name[scheme] = name;
90 if (m_map_security_name.count(security) > 0)
93 m_map_security_name[security] = name;
98 std::shared_ptr<BenchmarkDescription> p_retval;
99 std::size_t index = (std::size_t)(h_desc.
p);
101 p_retval = m_descriptors.at(index);
108 if (!p_h_bench_descs)
111 if (count !=
static_cast<std::uint64_t
>(m_descriptors.size()))
113 std::stringstream ss;
114 ss <<
"Invalid size parameter: `count`. Expected " << m_descriptors.size()
115 <<
", but " << count <<
" received.";
120 std::uint64_t min_size = std::min(count,
static_cast<std::uint64_t
>(m_descriptors.size()));
121 assert(min_size ==
static_cast<std::uint64_t
>(m_descriptors.size()));
122 for (std::size_t i = 0; i < min_size; ++i)
124 p_h_bench_descs[i].
p = (
void *)(i);
126 p_h_bench_descs[i].
tag = m_descriptors[i]->classTag();
132 std::shared_ptr<BenchmarkDescription> p_bd =
matchBenchmark(h_bench_desc);
136 return p_bd->getWorkloadParameterCount();
141 std::shared_ptr<BenchmarkDescription> p_bd =
matchBenchmark(h_bench_desc);
145 return p_bd->getWorkloadDefaultParameters().size();
151 std::uint64_t default_count)
const
157 std::shared_ptr<BenchmarkDescription> p_bd =
matchBenchmark(h_bench_desc);
162 p_bd->getBenchmarkDescriptor(*p_bench_desc);
164 if (p_default_params)
167 const auto &default_params = p_bd->getWorkloadDefaultParameters();
168 std::uint64_t min_default_count = std::min<std::uint64_t>(default_count, default_params.size());
169 for (std::size_t i = 0; i < min_default_count; ++i)
172 if (p_default_params[i].count < default_params[i].size())
175 std::copy(default_params[i].begin(), default_params[i].end(), p_default_params[i].params);
183 std::shared_ptr<BenchmarkDescription> p_bd =
matchBenchmark(h_bench_desc);
188 BaseBenchmark *p_bench = p_bd->createBenchmark(*
this, p_params);
213 this->
template destroyObj<BenchmarkHandle>(p_bh);
225 if ((h.
tag & check_tags) != check_tags)
232 checkHandleTags(h, check_tags);
237 return duplicateHandleInternal(h, new_tags);
242 checkHandleTags(h, check_tags);
243 return duplicateHandleInternal(h, h.
tag);
255 if (
this != &p_obj->
engine())
Top level opaque benchmark class.
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.
std::shared_ptr< BenchmarkDescription > matchBenchmark(hebench::APIBridge::Handle h_desc) const
Retrieves the BenchmarkDescription object pointed by the specified handle.
static const std::string & getErrorDesc(hebench::APIBridge::ErrorCode err_code)
Retrieves the description of a specific error code.
std::uint64_t getWorkloadParamsCount(hebench::APIBridge::Handle h_bench_desc) const
Retrieves the number of workload parameters for the decribed benchmark.
hebench::APIBridge::Handle createBenchmark(hebench::APIBridge::Handle h_bench_desc, const hebench::APIBridge::WorkloadParams *p_params)
Creates the benchmark specified by the descriptor.
void addBenchmarkDescription(std::shared_ptr< BenchmarkDescription > p_desc)
Adds a new benchmark to the list of benchmarks to register by this backend.
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 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.
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.
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().
static void setLastError(hebench::APIBridge::ErrorCode value)
Sets the last error code that occurred.
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...
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
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.
virtual void destroyBenchmark(BaseBenchmark *p_bench)=0
Destroys and frees resources held by a BaseBenchmark (or derived) object previously created by create...
static constexpr std::int64_t tag
Used to identify this class when returned as a handle to Test Harness.
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.
const BaseEngine & engine() const
static constexpr std::int64_t MaskReservedBits
Mask representing all bits reserved by C++ wrapper.
#define HEBERROR_MSG_CLASS(message)
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)
BenchmarkDescription * p_bench_description
BaseBenchmark * p_benchmark
Bundles a benchmark and its description to cross the API Bridge as a handle.
#define HEBENCH_ECODE_SUCCESS
Function call succeeded without error.
#define HEBENCH_ECODE_INVALID_ARGS
Indicates invalid arguments to function call.
#define HEBENCH_ECODE_CRITICAL_ERROR
Specifies a critical error.