10 #include "hebench/modules/general/include/error.h"
15 namespace TestHarness {
19 std::vector<char> ch_retval;
22 throw std::runtime_error(IL_LOG_MSG_CLASS(
"Unexpected error retrieving error message from backend."));
25 throw std::runtime_error(IL_LOG_MSG_CLASS(
"Unexpected error retrieving error message from backend."));
26 return ch_retval.data();
31 std::vector<char> ch_retval;
34 throw std::runtime_error(IL_LOG_MSG_CLASS(
"Unexpected error retrieving last error message from backend."));
37 throw std::runtime_error(IL_LOG_MSG_CLASS(
"Unexpected error retrieving last error message from backend."));
38 return ch_retval.data();
54 throw hebench::Common::ErrorException(ss.str(), err_code);
67 std::memset(&m_handle, 0,
sizeof(m_handle));
70 void Engine::init(
const std::vector<std::int8_t> &data)
85 ss = std::stringstream(s);
94 ss = std::stringstream(IL_LOG_MSG_CLASS(
"Error initializing backend engine."));
96 throw hebench::Common::ErrorException(ss.str(), err_code);
102 m_h_bench_desc.resize(count);
117 std::vector<char> ch_retval;
120 throw std::runtime_error(IL_LOG_MSG_CLASS(
"Unexpected error retrieving scheme name."));
123 ch_retval.data(), ch_retval.
size())
125 throw std::runtime_error(IL_LOG_MSG_CLASS(
"Unexpected error retrieving scheme name."));
126 return ch_retval.data();
132 std::vector<char> ch_retval;
138 throw std::runtime_error(IL_LOG_MSG_CLASS(
"Unexpected error retrieving security name."));
143 ch_retval.data(), ch_retval.
size())
145 throw std::runtime_error(IL_LOG_MSG_CLASS(
"Unexpected error retrieving security name."));
146 return ch_retval.data();
150 const std::vector<hebench::APIBridge::WorkloadParam> &w_params)
const
152 std::vector<char> ch_retval;
158 throw std::runtime_error(IL_LOG_MSG_CLASS(
"Unexpected error retrieving extra description."));
161 ch_retval.data(), ch_retval.size());
163 throw std::runtime_error(IL_LOG_MSG_CLASS(
"Unexpected error retrieving extra description."));
164 return ch_retval.data();
169 if (!m_last_benchmark.expired())
170 throw std::logic_error(IL_LOG_MSG_CLASS(
"A benchmark already exists. Cannot create more than one benchmark at a time."));
172 IBenchmark::Ptr p_retval = BenchmarkFactory::createBenchmark(this->shared_from_this(), p_token, out_report);
173 m_last_benchmark = p_retval;
180 if (index >= m_h_bench_desc.size())
181 throw std::out_of_range(IL_LOG_MSG_CLASS(
"Total benchmarks: " +
std::to_string(m_h_bench_desc.size()) +
". Invalid 'index' out of range: " +
std::to_string(index) +
"."));
186 backend_desc.m_backend_description.m_index = index;
187 backend_desc.m_backend_description.m_handle = m_h_bench_desc[index];
189 m_h_bench_desc[index],
190 &backend_desc.m_backend_description.m_descriptor,
208 || output.
other != completed_descriptor.
other)
209 throw std::runtime_error(IL_LOG_MSG_CLASS(
"Completed benchmark descriptor differs from backend specification."));
214 std::vector<std::vector<hebench::APIBridge::WorkloadParam>>
217 if (index >= m_h_bench_desc.size())
218 throw std::out_of_range(IL_LOG_MSG_CLASS(
"Total benchmarks: " +
std::to_string(m_h_bench_desc.size()) +
". Invalid 'index' out of range: " +
std::to_string(index) +
"."));
220 std::uint64_t param_count, default_count;
222 m_h_bench_desc[index],
225 std::vector<std::vector<hebench::APIBridge::WorkloadParam>> retval(default_count);
228 std::vector<hebench::APIBridge::WorkloadParams> wps(retval.size());
229 for (std::size_t i = 0; i < retval.size(); ++i)
231 retval[i].resize(param_count);
232 wps[i].count = retval[i].size();
233 wps[i].params = retval[i].data();
237 m_h_bench_desc[index],
Specifies a benchmark configuration.
static IBenchmarkDescriptor::DescriptionToken::Ptr matchBenchmarkDescriptor(const Engine &engine, const BenchmarkDescription::Backend &backend_desc, const BenchmarkDescription::Configuration &config)
Returns a token representing a benchmark that can perform the described workload with specified param...
static Engine::Ptr create(const std::vector< std::int8_t > &data)
Creates a new backend engine.
std::string getSecurityName(hebench::APIBridge::Scheme s, hebench::APIBridge::Security sec) const
IBenchmarkDescriptor::DescriptionToken::Ptr describeBenchmark(std::size_t index, const BenchmarkDescription::Configuration &config) const
Describes a benchmark workload that matches the specified description from the benchmarks registered ...
static void completeBenchmarkDescriptor(hebench::TestHarness::BenchmarkDescription::Backend &backend_description, const hebench::APIBridge::BenchmarkDescriptor &completed_descriptor)
Grants a guarded write access to hebench::TestHarness::BenchmarkDescription::Backend::m_descriptor::c...
std::shared_ptr< Engine > Ptr
std::vector< std::vector< hebench::APIBridge::WorkloadParam > > getDefaultWorkloadParams(std::size_t index) const
Retrieves the list of default parameters for a workload as specified by the backend.
const hebench::APIBridge::Handle & handle() const
std::string getExtraDescription(hebench::APIBridge::Handle h_bench_desc, const std::vector< hebench::APIBridge::WorkloadParam > &w_params) const
void validateRetCode(hebench::APIBridge::ErrorCode err_code, bool last_error=true) const
std::string getErrorDescription(hebench::APIBridge::ErrorCode err_code) const
std::string getLastErrorDescription() const
std::string getSchemeName(hebench::APIBridge::Scheme s) const
IBenchmark::Ptr createBenchmark(IBenchmarkDescriptor::DescriptionToken::Ptr p_token, hebench::Utilities::TimingReportEx &out_report)
Creates the the benchmark workload represented by the specified token.
std::shared_ptr< DescriptionToken > Ptr
std::shared_ptr< IBenchmark > Ptr
std::uint64_t getSchemeName(Handle h_engine, Scheme s, char *p_name, std::uint64_t size)
Retrieves the name of a specified scheme ID from the backend.
Security security
Security for the scheme.
std::uint64_t getSchemeSecurityName(Handle h_engine, Scheme s, Security sec, char *p_name, std::uint64_t size)
Retrieves the name of the specified security for the scheme ID from the backend.
std::uint64_t getErrorDescription(Handle h_engine, ErrorCode code, char *p_description, std::uint64_t size)
Retrieves the general error description of an error code.
ErrorCode destroyHandle(Handle h)
Releases resources held by the specified handle.
std::uint32_t cipher_param_mask
Input mask to define which operation parameters for the computation are plain text or cipher text.
DataType data_type
Data type for the workload.
CategoryParams cat_params
Parameters for the category.
std::int32_t Scheme
Open-ended homomorphic encryption scheme ID.
ErrorCode describeBenchmark(Handle h_engine, Handle h_bench_desc, BenchmarkDescriptor *p_bench_desc, WorkloadParams *p_default_params, std::uint64_t default_count)
Retrieves the concrete description for a benchmark registered by backend.
std::int32_t Security
Open-ended homomorphic encryption scheme security ID.
std::uint64_t size
Size of underlying data.
ErrorCode getWorkloadParamsDetails(Handle h_engine, Handle h_bench_desc, std::uint64_t *p_param_count, std::uint64_t *p_default_count)
Retrieves details about the flexible parameters supported by this workload.
std::int64_t other
Backend specific extra parameter.
Category category
Category for the benchmark.
std::int32_t ErrorCode
Return value for API bridge functions.
ErrorCode initEngine(Handle *h_engine, const int8_t *p_buffer, uint64_t size)
Initializes the backend engine.
Workload workload
Workload for the benchmark.
Scheme scheme
Scheme for the benchmark.
std::uint64_t getLastErrorDescription(Handle h_engine, char *p_description, std::uint64_t size)
Retrieves the detailed description of the last error that occurred during an operation on the engine.
std::uint64_t getBenchmarkDescriptionEx(Handle h_engine, Handle h_bench_desc, const hebench::APIBridge::WorkloadParams *p_w_params, char *p_description, std::uint64_t size)
Retrieves backend specific text description for a benchmark descriptor.
ErrorCode subscribeBenchmarksCount(Handle h_engine, std::uint64_t *p_count)
Retrieves the number of benchmarks for which the backend is registering to perform.
ErrorCode subscribeBenchmarks(Handle h_engine, Handle *p_h_bench_descs, std::uint64_t count)
Retrieves handles to the benchmark descriptions for which the backend is registering to perform.
Defines a benchmark test.
Defines a single workload parameter.
Specifies the parameters for a workload.
Structure to contain flexible data.
std::string to_string(const std::string_view &s)
#define HEBENCH_ECODE_SUCCESS
Function call succeeded without error.