HEBench
|
Base class that encapsulates common behavior of backend engines. More...
#include <engine.hpp>
Public Member Functions | |
BaseEngine (const BaseEngine &)=delete | |
BaseEngine & | operator= (const BaseEngine &)=delete |
BaseEngine (BaseEngine &&)=delete | |
BaseEngine & | operator= (BaseEngine &&)=delete |
~BaseEngine () override | |
std::int64_t | classTag () const override |
Retrieves the tag of the class to which this object belongs. More... | |
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. More... | |
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. More... | |
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. More... | |
std::uint64_t | subscribeBenchmarkCount () const |
Retrieves the number of benchmarks for which the backend is registering to perform. More... | |
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. More... | |
std::uint64_t | getWorkloadParamsCount (hebench::APIBridge::Handle h_bench_desc) const |
Retrieves the number of workload parameters for the decribed benchmark. More... | |
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. More... | |
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 |
hebench::APIBridge::Handle | createBenchmark (hebench::APIBridge::Handle h_bench_desc, const hebench::APIBridge::WorkloadParams *p_params) |
Creates the benchmark specified by the descriptor. More... | |
void | destroyBenchmark (hebench::APIBridge::Handle h_bench) |
Destroys and cleans up a benchmark created by createBenchmark(). More... | |
template<class T , typename... Args> | |
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. More... | |
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() . More... | |
hebench::APIBridge::Handle | duplicateHandle (hebench::APIBridge::Handle h, std::int64_t check_tags=0) const |
Duplicates a handle created by createhandle() . More... | |
template<class T , typename... Args> | |
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(). More... | |
template<class T , typename... Args> | |
EngineObject * | createEngineObj (Args &&... args) const |
Creates an EngineObject that wraps an object of type T . More... | |
template<class T , typename... Args> | |
std::shared_ptr< T > | createRAII (Args &&... args) const |
Creates a smart pointer of the specified template type. More... | |
template<class T , typename... Args> | |
T * | createObj (Args &&... args) const |
template<class T > | |
void | destroyObj (T *p) const |
Public Member Functions inherited from hebench::cpp::ITaggedObject | |
ITaggedObject () | |
virtual | ~ITaggedObject () |
Static Public Member Functions | |
static const std::string & | getErrorDesc (hebench::APIBridge::ErrorCode err_code) |
Retrieves the description of a specific error code. More... | |
static hebench::APIBridge::ErrorCode | getLastError () |
Retrieves the last error that occurred as set by setLastError(). More... | |
static const std::string & | getLastErrorDesc () |
Retrieves the description of the last error that occurred as set by setLastError(). More... | |
static void | setLastError (hebench::APIBridge::ErrorCode value) |
Sets the last error code that occurred. More... | |
static void | setLastError (hebench::APIBridge::ErrorCode value, const std::string &err_desc) |
Sets the last error code that occurred. More... | |
Static Public Attributes | |
static constexpr std::int64_t | tag = 0x8000000000000000 |
Used to identify this class when returned as a handle to Test Harness. More... | |
Static Public Attributes inherited from hebench::cpp::ITaggedObject | |
static constexpr std::int64_t | MaskByteSet = 0xFF |
static constexpr std::int64_t | MaskReservedBits = MaskByteSet << 56 |
Mask representing all bits reserved by C++ wrapper. More... | |
Protected Member Functions | |
BaseEngine () | |
virtual void | init ()=0 |
Initializes the backend engine and populates the backend description. More... | |
std::shared_ptr< BenchmarkDescription > | matchBenchmark (hebench::APIBridge::Handle h_desc) const |
Retrieves the BenchmarkDescription object pointed by the specified handle. More... | |
void | addBenchmarkDescription (std::shared_ptr< BenchmarkDescription > p_desc) |
Adds a new benchmark to the list of benchmarks to register by this backend. More... | |
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. More... | |
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. More... | |
Static Protected Member Functions | |
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 can generate. More... | |
Base class that encapsulates common behavior of backend engines.
Any backend engine must derive from this class in order to take advantage of the C++ wrapper boilerplate automation.
Definition at line 69 of file engine.hpp.
|
delete |
|
delete |
|
inlineoverride |
Definition at line 88 of file engine.hpp.
|
protected |
Definition at line 30 of file engine.cpp.
|
protected |
Adds a new benchmark to the list of benchmarks to register by this backend.
[in] | p_desc | Object describing the new benchmark. |
This method is to be called during engine initialization.
Definition at line 67 of file engine.cpp.
|
staticprotected |
Adds a new error code and the error description to the list of possible error codes that this backend can generate.
[in] | code | Error code. |
[in] | description | Description of the error as it will returned by hebench::APIBridge::getErrorDescription(). |
This method is to be called during engine initialization.
Definition at line 72 of file engine.cpp.
|
protected |
Adds a new supported scheme and name pair to the list of schemes supported by this backend.
[in] | scheme | Scheme ID. |
[in] | name | Corresponding name for the scheme. |
This method is to be called during engine initialization.
Definition at line 80 of file engine.cpp.
|
protected |
Adds a new supported security and name pair to the list of securitty types supported by this backend.
[in] | security | Security ID. |
[in] | name | Corresponding name for the new security type. |
This method is to be called during engine initialization.
Definition at line 88 of file engine.cpp.
|
inlineoverridevirtual |
Retrieves the tag of the class to which this object belongs.
Most significant 8 bits of the 64-bit tag are reserved by C++ wrapper. See ITaggedObject
for more details.
Implements hebench::cpp::ITaggedObject.
Definition at line 90 of file engine.hpp.
hebench::APIBridge::Handle hebench::cpp::BaseEngine::createBenchmark | ( | hebench::APIBridge::Handle | h_bench_desc, |
const hebench::APIBridge::WorkloadParams * | p_params | ||
) |
Creates the benchmark specified by the descriptor.
Definition at line 180 of file engine.cpp.
EngineObject * hebench::cpp::BaseEngine::createEngineObj | ( | Args &&... | args | ) | const |
Creates an EngineObject
that wraps an object of type T
.
args | Arguments for constructor of object of type T . |
EngineObject
instance that wraps the newly constructed object of type T
.Pointers to EngineObject
instances make easier to wrap backend internal objects that need to cross the boundary of the API bridge. For easier use, see method createHandle().
Definition at line 419 of file engine.hpp.
hebench::APIBridge::Handle hebench::cpp::BaseEngine::createHandle | ( | std::uint64_t | size, |
std::int64_t | extra_tags, | ||
Args &&... | args | ||
) | const |
Encapsulates an object of type T in an opaque HEBench handle.
[in] | size | Value to use as the size filed for the handle. |
[in] | extra_tags | Value to use as the tag filed for the handle. This value will be combined with the value for EngineObject::tag using binary OR operation. |
[in] | args | Constructor arguments to construct the object of type T. |
hebench::cpp::HEBenchError | if any of the most significant 8 bits of extra_tags is set, due to these being reserved by ITaggedObject . |
This method will construct the object using the arguments specified in args
.
Definition at line 379 of file engine.hpp.
T * hebench::cpp::BaseEngine::createObj | ( | Args &&... | args | ) | const |
Definition at line 437 of file engine.hpp.
std::shared_ptr< T > hebench::cpp::BaseEngine::createRAII | ( | Args &&... | args | ) | const |
Creates a smart pointer of the specified template type.
args | Arguments for constructor of object of specified type to be created. |
The RAII and reference counting properties of smart pointer ensure that the created object is properly destroyed when it goes out of scope and it is the last reference.
The allocation and deallocation mechanisms of the smart pointer use BaseEngine::createObj() and BaseEngine::destroyObj() methods in order to keep the BaseEngine as the allocation manager.
Definition at line 427 of file engine.hpp.
void hebench::cpp::BaseEngine::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 |
Definition at line 148 of file engine.cpp.
void hebench::cpp::BaseEngine::destroyBenchmark | ( | hebench::APIBridge::Handle | h_bench | ) |
Destroys and cleans up a benchmark created by createBenchmark().
[in] | h_bench | Handle to benchmark to destroy. |
HEBenchError | on invalid handle with error code HEBENCH_ECODE_CRITICAL_ERROR. |
Definition at line 199 of file engine.cpp.
|
inline |
Definition at line 297 of file engine.hpp.
hebench::APIBridge::Handle hebench::cpp::BaseEngine::duplicateHandle | ( | hebench::APIBridge::Handle | h, |
std::int64_t | check_tags = 0 |
||
) | const |
Duplicates a handle created by createhandle()
.
[in] | h | Handle to duplicate. |
[in] | check_tags | Tags to check for. If the input handle does not match this mask in a binary AND test, an exception is thrown. |
hebench::cpp::HEBenchError | if tag check fails, or arguments are invalid (invalid check_tags or handle is null). |
Handles created by createHandle()
point to internal representations that are reference counted. This method, returns a new handle that points to the same internal representation, but increases the reference count. Thus, both handles point to the same internal representation (shallow copy), but destroying each only decrements the reference count. The internal representation is actually destroyed when this reference count reaches 0.
Warning: destroyed handles must not be duplicated. Attempting to duplicate a handle that has been destroyed will cause undefined behavior.
Definition at line 240 of file engine.cpp.
hebench::APIBridge::Handle hebench::cpp::BaseEngine::duplicateHandle | ( | hebench::APIBridge::Handle | h, |
std::int64_t | new_tag, | ||
std::int64_t | check_tags | ||
) | const |
Duplicates a handle created by createhandle()
.
[in] | h | Handle to duplicate. |
[in] | new_tag | New tag to set in the duplicated handle. |
[in] | check_tags | Tags to check for. If the input handle does not match this mask in a binary AND test, an exception is thrown. |
hebench::cpp::HEBenchError | if tag check fails, or arguments are invalid (invalid check_tags or handle is null). |
Handles created by createHandle()
point to internal representations that are reference counted. This method, returns a new handle that points to the same internal representation, but increases the reference count. Thus, both handles point to the same internal representation (shallow copy), but destroying each only decrements the reference count. The internal representation is actually destroyed when this reference count reaches 0.
Warning: destroyed handles must not be duplicated. Attempting to duplicate a handle that has been destroyed will cause undefined behavior.
Definition at line 230 of file engine.cpp.
std::string hebench::cpp::BaseEngine::getBenchmarkDescriptionEx | ( | hebench::APIBridge::Handle | h_bench_desc, |
const hebench::APIBridge::WorkloadParams * | p_w_params | ||
) | const |
Retrieves backend specific text description for a benchmark descriptor.
Definition at line 56 of file engine.cpp.
std::uint64_t hebench::cpp::BaseEngine::getDefaultWorkloadParamsCount | ( | hebench::APIBridge::Handle | h_bench_desc | ) | const |
Retrieves the number of sets of default arguments supported by this benchmark's workload.
[in] | h_bench_desc | Handle to benchmark description to query for information. |
Definition at line 139 of file engine.cpp.
|
static |
Retrieves the description of a specific error code.
The error code must a standard error code defined in the API bridge or a custom code added through a call to addErrorCode() during this object's initialization.
Definition at line 35 of file engine.cpp.
|
inlinestatic |
Retrieves the last error that occurred as set by setLastError().
Definition at line 105 of file engine.hpp.
|
inlinestatic |
Retrieves the description of the last error that occurred as set by setLastError().
Definition at line 110 of file engine.hpp.
std::uint64_t hebench::cpp::BaseEngine::getWorkloadParamsCount | ( | hebench::APIBridge::Handle | h_bench_desc | ) | const |
Retrieves the number of workload parameters for the decribed benchmark.
[in] | h_bench_desc | Handle to benchmark description to query for information. |
Definition at line 130 of file engine.cpp.
|
protectedpure virtual |
Initializes the backend engine and populates the backend description.
This method is called automatically during engine initialization.
Derived classes should use this method to initialize this class and populate the descriptions for the benchmarks that this backend will perform; and add error descriptions, scheme and security names for this backend.
|
protected |
Retrieves the BenchmarkDescription
object pointed by the specified handle.
[in] | h_desc | Handle to descriptor as returned by subscribeBenchmarks(). |
BenchmarkDescription
object that is pointed by the specified handle or a null pointer if no match was found. Definition at line 96 of file engine.cpp.
|
delete |
|
delete |
T & hebench::cpp::BaseEngine::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().
[in] | h | Handle containing the object. |
[in] | extra_tags | Value to check against the tag for the handle. |
hebench::cpp::HEBenchError | if any of the most significant 8 bits of extra_tags is set, or handle.tag & EngineObject::tag != EngineObject::tag
|| handle.tag & extra_tags != extra_tags
static constexpr std::int64_t tag Used to identify this class when returned as a handle to Test Harness. Definition: engine_object.hpp:112 |
Note that once extracted, the object will be statically casted to type T. Due to the nature of the opaque handles, this cast is unsafe, and thus, it is user's responsibility to make sure that the encapsulated object is of the right type (such as using the tag
field in the handle for extra information).
Definition at line 397 of file engine.hpp.
|
inline |
Retrieves a dictionary that maps schemes known to this benchmark to their human readable names.
Definition at line 141 of file engine.hpp.
|
inline |
Retrieves a dictionary that maps security types known to this benchmark to their human readable names.
Definition at line 148 of file engine.hpp.
|
static |
Sets the last error code that occurred.
[in] | value | Error code. |
This method is automatically called by C++ wrapper when an exception of type HEBenchError is caught.
Definition at line 44 of file engine.cpp.
|
static |
Sets the last error code that occurred.
[in] | value | Error code. |
[in] | err_desc | Description of the error. |
This method is automatically called by C++ wrapper when an exception of type HEBenchError is caught.
Definition at line 49 of file engine.cpp.
|
inline |
Retrieves the number of benchmarks for which the backend is registering to perform.
Definition at line 155 of file engine.hpp.
void hebench::cpp::BaseEngine::subscribeBenchmarks | ( | hebench::APIBridge::Handle * | p_h_bench_descs, |
std::uint64_t | count | ||
) | const |
Retrieves the benchmarks for which the backend is registering to perform.
Definition at line 106 of file engine.cpp.
|
staticconstexpr |
Used to identify this class when returned as a handle to Test Harness.
Definition at line 86 of file engine.hpp.