HEBench
|
Namespaces | |
WorkloadParamType | |
Classes | |
struct | WorkloadParam |
Defines a single workload parameter. More... | |
struct | WorkloadParams |
Specifies the parameters for a workload. More... | |
struct | CategoryParams |
Specifies parameters for a category. More... | |
struct | BenchmarkDescriptor |
Defines a benchmark test. More... | |
struct | _FlexibleData |
Structure to contain flexible data. More... | |
struct | DataPack |
Defines a data package for an operation. More... | |
struct | DataPackCollection |
Defines a collection of data packs. More... | |
struct | ParameterIndexer |
Indexes a DataPack . More... | |
union | WorkloadParam.__unnamed5__ |
union | CategoryParams.__unnamed7__ |
struct | CategoryParams.__unnamed7__.latency |
struct | CategoryParams.__unnamed7__.offline |
Typedefs | |
typedef std::int32_t | ErrorCode |
Return value for API bridge functions. More... | |
typedef std::int32_t | Scheme |
Open-ended homomorphic encryption scheme ID. More... | |
typedef std::int32_t | Security |
Open-ended homomorphic encryption scheme security ID. More... | |
typedef _FlexibleData | NativeDataBuffer |
Represents a native data buffer maintained by the Test Harness. More... | |
typedef _FlexibleData | Handle |
Encapsulates an opaque handle to backend data. More... | |
Enumerations | |
enum | Workload { MatrixMultiply = 1 , EltwiseAdd , EltwiseMultiply , DotProduct , LogisticRegression , LogisticRegression_PolyD3 , LogisticRegression_PolyD5 , LogisticRegression_PolyD7 , SimpleSetIntersection , Generic } |
Defines all possible workloads. More... | |
enum | DataType { Int32 = 1 , Int64 , Float32 , Float64 } |
Defines data types for a workload. More... | |
enum | Category { Latency = 1 , Offline } |
Defines all possible categories for each workload. More... | |
Functions | |
ErrorCode | destroyHandle (Handle h) |
Releases resources held by the specified handle. More... | |
ErrorCode | initEngine (Handle *h_engine, const int8_t *p_buffer, uint64_t size) |
Initializes the backend engine. More... | |
ErrorCode | subscribeBenchmarksCount (Handle h_engine, std::uint64_t *p_count) |
Retrieves the number of benchmarks for which the backend is registering to perform. More... | |
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. More... | |
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. More... | |
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. More... | |
ErrorCode | createBenchmark (Handle h_engine, Handle h_bench_desc, const WorkloadParams *p_params, Handle *h_benchmark) |
Instantiates a benchmark on the backend. More... | |
ErrorCode | initBenchmark (Handle h_benchmark, const BenchmarkDescriptor *p_concrete_desc) |
Allows the benchmark to perform initialization steps based on the finalized, concrete description. More... | |
ErrorCode | encode (Handle h_benchmark, const DataPackCollection *p_parameters, Handle *h_plaintext) |
Given a pack of parameters in raw, native data format, encodes them into plain text suitable for backend encryption or operation. More... | |
ErrorCode | decode (Handle h_benchmark, Handle h_plaintext, DataPackCollection *p_native) |
Decodes plaintext data into the appropriate raw, native format. More... | |
ErrorCode | encrypt (Handle h_benchmark, Handle h_plaintext, Handle *h_ciphertext) |
Encrypts a plain text into a cipher text. More... | |
ErrorCode | decrypt (Handle h_benchmark, Handle h_ciphertext, Handle *h_plaintext) |
Decrypts a cipher text into corresponding plain text. More... | |
ErrorCode | load (Handle h_benchmark, const Handle *h_local_packed_params, std::uint64_t local_count, Handle *h_remote) |
Loads the specified data from the local host into the remote backend to use as parameter during a call to operate(). More... | |
ErrorCode | store (Handle h_benchmark, Handle h_remote, Handle *h_local_packed_params, std::uint64_t local_count) |
Retrieves the specified data from the backend. More... | |
ErrorCode | operate (Handle h_benchmark, Handle h_remote_packed_params, const ParameterIndexer *p_param_indexers, uint64_t indexers_count, Handle *h_remote_output) |
Performs the workload operation of the benchmark. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
struct hebench::APIBridge::WorkloadParam |
Defines a single workload parameter.
This struct holds the value and meta data for a workload parameter. The correct type is workload specific and specified per workload.
Class Members | ||
---|---|---|
union WorkloadParam | __unnamed__ | |
WorkloadParamType | data_type | Type of the parameter data. |
char | name[HEBENCH_MAX_BUFFER_SIZE] |
Null-terminated string containing the name for the parameter. This name if for description purposes only and should not be used as identifier or any other specific purpose. |
struct hebench::APIBridge::WorkloadParams |
Specifies the parameters for a workload.
A workload can have 0
or more flexible parameters that can be specified during benchmark initialization; for example, vector element-wise operations have the number of elements in a vector as a parameter.
The number of parameters is workload specific.
Class Members | ||
---|---|---|
uint64_t | count | Number of workload parameters. |
WorkloadParam * | params | Parameters for the workload. |
struct hebench::APIBridge::CategoryParams |
Specifies parameters for a category.
This type contains a union to accomodate parameters for all categories. Clients must be mindful that writing data to parameters for a category will overwrite data for all other categories in the same union, thus, separate instaces of this type should be used for different categories.
Class Members | ||
---|---|---|
union CategoryParams | __unnamed__ | |
uint64_t | min_test_time_ms |
Specifies the minimum time, in milliseconds, to run the test. Latency benchmark will submit an operation with the same set of inputs as many times as needed until the time elapsed during the test is, at least, the number of milliseconds specified. Offline benchmark will submit the complete dataset for the test in a single operation. Test Harness will continue to submit operation requests on the whole dataset until the time elapsed during the test is, at least, the number of milliseconds specified. A value of Regardless of the time specified, for latency category, Test Harness will submit, at least, two iterations; and for offline category, Test Harness will submit, at least, one iteration. It is clear that the full test will take, at least, as much time as specified by this field, since the last operation request that satisfies the elapsed time will not be interrupted until it completes. |
struct hebench::APIBridge::BenchmarkDescriptor |
Defines a benchmark test.
A benchmark test is defined by a Workload, a Category for said workload, a scheme for such Category, which inputs are plain text of cipher text, the security level for the scheme, and an extra parameter that is backend specific.
cipher_param_mask
is a bit mask that defines which operation parameters are cipher or plain text. If bit i
is set, then parameter i
is cipher text, otherwise, it is plain text. Only the least significant n
bits of this field will be used for an operation that supports n
operands. The rest are ignored.
Test Harness will request the list of BenchmarkDescriptor objects for which a backend is subscribing. When Test Harness is about to execute a benchmark, the BenchmarkDescriptor is passed down to the backend with the same values used during subscription.
Fields workload
, data_type
, category
, cat_params
and cypher_param_mask
specify the actual operation for the benchmark that Test Harness will execute. Different combination of values specified by scheme
, security
, and other
fields do not affect the type of benchmark, but further describe it.
A benchmark is defined by the combination of the values for all these fields, thus, two benchmarks are considered the same if all fields have the same value. So, if we are running two benchmark with workload matrix multiplication, latency category, CKKS scheme with 128 bits security and BFV scheme with 128 bits security, then scheme field for both benchmarks must be different. Note that two benchmarks with the same descriptor can differ in the workload parameters, effectively performing the same benchmark on a workload with different parameter sets.
Class Members | ||
---|---|---|
CategoryParams | cat_params | Parameters for the category. |
Category | category | Category for the benchmark. |
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. |
int64_t | other | Backend specific extra parameter. |
Scheme | scheme | Scheme for the benchmark. |
Security | security | Security for the scheme. |
Workload | workload | Workload for the benchmark. |
struct hebench::APIBridge::_FlexibleData |
Structure to contain flexible data.
What all of this structure's fields actually represent, is custom-defined by the structure user. Field names are just provided as a guideline. It is the client's responsibility to define the meaning of each field based on where is this structure used and to adhere to this definition.
struct hebench::APIBridge::DataPack |
Defines a data package for an operation.
This data pack contains a list of samples (one sample per NativeDataBuffer
) for the same component.
Field param_position
specifies the zero-based position of the data as a parameter in the call order for the operation to execute, or the zero-based componenet in the result. For example, in (R0, R1) = op(A, B, C)
, based on the input components: A
is at position 0
, B
is at position 1
, and C
is at 2
; and for the output components: R0
is at position 0
, and R1
is at position 1
.
Class Members | ||
---|---|---|
uint64_t | buffer_count |
Number of data buffers in p_buffers . |
NativeDataBuffer * | p_buffers | Array of data buffers for parameter. |
uint64_t | param_position | The 0-based position of this parameter in the corresponding function call. |
struct hebench::APIBridge::DataPackCollection |
Defines a collection of data packs.
This struct is used to encode/decode a collection of data packs, in a single call instead of encoding each data pack at a time. This is useful for backends to optimize large amounts of data.
Class Members | ||
---|---|---|
DataPack * | p_data_packs | Collection of data packs. |
uint64_t | pack_count | Number of data packs in the collection. |
struct hebench::APIBridge::ParameterIndexer |
Indexes a DataPack
.
In a call to operate(), a list of ParameterIndexer
is passed, where each element of that list corresponds to an input parameter position in the call order. For that call to operate()
, the i
-th ParameterIndexer
specifies the index for the first component sample to use from the corresponding DataPack
and how many values in the batch to use for the operation.
Typically, for a latency benchmark, the indexer for each input component will be value_index = 0
and batch_size = 1
, indicating the first element of the dataset for that component.
For an offline benchmark, unless otherwise specified, each input component will be value_index = 0
and batch_size = all_samples_for_component
, indicating the complete dataset.
For details on the ordering of results based on the operation parameter sample index see Ordering of Results Based on Input Batch Sizes .
Class Members | ||
---|---|---|
uint64_t | batch_size | Number of values to use, starting from index. |
uint64_t | value_index | Index of parameter value inside the data pack. |
union hebench::APIBridge::WorkloadParam.__unnamed5__ |
union hebench::APIBridge::CategoryParams.__unnamed7__ |
Class Members | ||
---|---|---|
__unnamed7__ | latency | Specifies the parameters for the latency category. |
__unnamed7__ | offline | Specifies the parameters for the offline category. |
uint64_t | reserved[HEBENCH_MAX_CATEGORY_PARAMS] |
Generic placeholder for categories. This field is used to allocate memory for the whole union. It is advised to access the parameters through the respective category field instead. |
struct hebench::APIBridge::CategoryParams.__unnamed7__.latency |
struct hebench::APIBridge::CategoryParams.__unnamed7__.offline |
Class Members | ||
---|---|---|
uint64_t | data_count[HEBENCH_MAX_OP_PARAMS] |
Specifies the number of data samples for each parameter for Category::Offline. This specifies the the number of samples submitted by Test Harness for each parameter for the offline operation. A value larger than available input samples will see the whole dataset of inputs be used for that parameter in a single operation. Note that in case that there is not enough data samples for a parameter, the number of samples will be lower than requested. A value of Regardless of the sample sizes (specified or default), the actual number of samples may be limited by the dataset for the workload, if any. |
typedef std::int32_t hebench::APIBridge::ErrorCode |
Return value for API bridge functions.
A value of HEBENCH_ECODE_SUCCESS
means success.
An error value of ECODE_CRITICAL_ERROR
will prompt the Test Harness to terminate. This usually indicates an unrecoverable error that indicates that the backend engine encounter an unstable state and it affects the backend engine capacity to recover, cleanup and/or create new benchmarks. On this error, Test Harness will stop benchmarking and attempt to clean up any open handles before exiting. Any further errors are ignored.
Backend should custom-define and return appropriate error codes for all required operations through the API bridge. Custom error codes values must be different than those pre-defined in the API bridge.
Represents a native data buffer maintained by the Test Harness.
This structure is created and maintained by the Test Harness and is passed to the backend through the API bridge.
The buffer pointed to by the p
field is formatted to contain data in the format expected for the respective parameter for which the buffer is used, and thus, it is safe to cast to the propper data type pointer.
Note that the size
field contains the size in bytes of the buffer, not the number of items of the corresponding data type.
The tag
field should not be modified outside of the Test Harness.
typedef std::int32_t hebench::APIBridge::Scheme |
typedef std::int32_t hebench::APIBridge::Security |
Defines all possible categories for each workload.
Note that some workloads may not support certain categories.
Enumerator | |
---|---|
Latency | Test Harness sends the same single data sample repeatedly to backend. |
Offline | Test Harness loads the whole dataset to backend before requesting all the results in a single operation. |
Defines all possible workloads.
See extended documentation for detailed definition, description, data layout, parameters, results, etc.
Enumerator | |
---|---|
MatrixMultiply | Matrix Multiplication workload. Workload Params:
Operation Params:
Result:
For details see Matrix Multiplication Workload . |
EltwiseAdd | Vector Element-wise Addition workload. Workload Params:
Operation Params:
Result:
For details see Vector Element-wise Addition Workload . |
EltwiseMultiply | Vector Element-wise Multiplication workload. Workload Params:
Operation Params:
Result:
For details see Vector Element-wise Multiplication Workload . |
DotProduct | Vector Dot Product workload. Workload Params:
Operation Params:
Result:
For details see Vector Dot Product Workload . |
LogisticRegression | Logistic Regression Inference workload. Workload Params:
Operation Params:
Result:
For details see Logistic Regression Inference Workload . |
LogisticRegression_PolyD3 | Logistic Regression Inference workload with polynomial approximation. Workload Params:
Operation Params:
Result:
For details see Logistic Regression Inference Workload . |
LogisticRegression_PolyD5 | Logistic Regression Inference workload with polynomial approximation. Workload Params:
Operation Params:
Result:
For details see Logistic Regression Inference Workload . |
LogisticRegression_PolyD7 | Logistic Regression Inference workload with polynomial approximation. Workload Params:
Operation Params:
Result:
For details see Logistic Regression Inference Workload . |
SimpleSetIntersection | Simple Set Intersection workload. Workload Params:
Operation Params:
Result:
For details see Simple Set Intersection Workload . |
Generic | Generic workload. Workload Params:
Operation Params:
Result:
(ResultComponent[0], ResultComponent[1], ..., ResultComponent[m - 1])
= op(InputParam[0], InputParam[1], ..., InputParam[n - 1])
where For details see Generic Workload . |
ErrorCode hebench::APIBridge::createBenchmark | ( | Handle | h_engine, |
Handle | h_bench_desc, | ||
const WorkloadParams * | p_params, | ||
Handle * | h_benchmark | ||
) |
Instantiates a benchmark on the backend.
[in] | h_engine | Handle to the backend engine to perform the benchmark. |
[in] | h_bench_desc | Handle to the description of the benchmark to instantiate. |
[in] | p_params | A set of parameters for the benchmark to be instantiated. It is ignored if workload does not support parameters. |
[out] | h_benchmark | Points to a handle to be filled with the initialized benchmark. |
HEBENCH_ECODE_SUCCESS
on success, or any other error code if an error occurred during operation, including, unsupported workload parameters.The returned benchmark handle will be used to reference this benchmark while executing the benchmark operations by the Test Harness. Destroying or modifying h_bench_desc
or p_params
must not affect the benchmark instantiation.
Backend can assume that only a single benchmark handle will be initialized at all times for the specified backend engine.
Parameter h_bench_desc
is a handle to a description previously registered by the backend during the call to subscribeBenchmarks() of the benchmark to be performed.
If workload for the benchmark supports parameters p_params
cannot be null; otherwise, it is ignored and can be set to null.
ErrorCode hebench::APIBridge::decode | ( | Handle | h_benchmark, |
Handle | h_plaintext, | ||
DataPackCollection * | p_native | ||
) |
Decodes plaintext data into the appropriate raw, native format.
[in] | h_benchmark | Handle to the initialized benchmark to perform. |
[in] | h_plaintext | Handle to encoded data. |
[out] | p_native | Pre-allocated buffers to contain the decoded output. |
The data buffers in p_native
will be passed into this function pre-allocated. The param_position
field will be already set to the required component for each data pack. The buffer sizes are determined by the Test harness based on the expected shape for each component of the data pack (representing either operation parameter or result of the operation performed). These shapes are operation-dependent and are documented for each operation. It is the responsibility of the backend to keep track of these shapes (through the opaque handle) so that they can be retrieved appropriately.
Backend must decode the data from h_plaintext
handle and fill out as much as it can into each data buffer. If some data buffer's size if smaller than needed for that data entry, the rest of the encoded data entry must be discarded.
This function is the inverse of encode(), so, decoding the result of encode(), must produce the exact same bits in p_native
's data buffers.
ErrorCode hebench::APIBridge::decrypt | ( | Handle | h_benchmark, |
Handle | h_ciphertext, | ||
Handle * | h_plaintext | ||
) |
Decrypts a cipher text into corresponding plain text.
[in] | h_benchmark | Handle to the initialized benchmark to perform. |
[in] | h_ciphertext | Handle to the encrypted data to decrypt. |
[out] | h_plaintext | Opaque handle to the decrypted data. |
The resulting plain text handle represents the encoded plain text. This may be passed to a call to decode() in order to obtain the raw native data.
Destroying or re-utilizing handle h_ciphertext
after this call completes shall not affect the resulting plain text.
ErrorCode hebench::APIBridge::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.
[in] | h_engine | Handle to the backend engine to perform the benchmark. |
[in] | h_bench_desc | Handle to the benchmark description to query for information. |
[out] | p_bench_desc | Points to the benchmark descriptor to receive the description of the benchmark. |
[out] | p_default_params | Array of WorkloadParams that will receive the sets of default parameters supported by this workload. It can be null if caller does not need this information. |
[in] | default_count | Number of elements available in the array pointed by p_default_params . This is will be as many default flexible parameter sets as returned by getWorkloadParamsDetails() , or ignored if p_default_params is null. |
The array p_default_params
is null if caller does not need the information regarding default arguments for workload, otherwise, it must have enough capacity to hold, at least, as many default sets as specified by default_count
. The number of default sets in default_count
should be the same as returned by getWorkloadParamsDetails()
. If workload does not support parameters, p_default_params
is ignored.
Releases resources held by the specified handle.
[in] | h | Handle to destroy. |
The specified handle is no longer valid for any calls requiring a handle after this function is called. This function releases resources held by the handle in the backend and destroys the handle.
Test Harness will call this method to clean up a handle it no longer needs. Test Harness will take care to destroy handles in reverse order in which it obtained them.
ErrorCode hebench::APIBridge::encode | ( | Handle | h_benchmark, |
const DataPackCollection * | p_parameters, | ||
Handle * | h_plaintext | ||
) |
Given a pack of parameters in raw, native data format, encodes them into plain text suitable for backend encryption or operation.
[in] | h_benchmark | Handle to the initialized benchmark to perform. |
[in] | p_parameters | Points to a DataPackCollection instance containing the information for the pack of parameters to encode. |
[out] | h_plaintext | Opaque handle representing the resulting encoded data by the backend. |
The size and shape of each parameter are determined by the Test Harness based on expected input shapes of the operation performed. These shapes are operation-dependent and are documented for each operation. It is the responsibility of the backend to keep track of these shapes (through the opaque handle) so that they can be retrieved appropriately when needed.
Unless otherwise specified by a workload or category, in general, Test Harness will encode all parameters that ought to be encrypted first in a single call to encode, and all the plain text in another call.
Destroying and cleaning up p_parameters
after this call completes shall not affect the resulting encoding.
This function is the inverse of decode(), and thus, decoding the resulting h_plaintext
should result in the exact same raw, native data passed during encode.
ErrorCode hebench::APIBridge::encrypt | ( | Handle | h_benchmark, |
Handle | h_plaintext, | ||
Handle * | h_ciphertext | ||
) |
Encrypts a plain text into a cipher text.
[in] | h_benchmark | Handle to the initialized benchmark to perform. |
[in] | h_plaintext | Handle to the plain text to encrypt. |
[out] | h_ciphertext | Opaque handle to the encrypted data. |
The resulting cipher text handle is commonly used in a call to the load() function to load the cipher text into the backend for execution of the operation to benchmark.
Destroying or re-utilizing handle h_plaintext
after this call completes shall not affect the resulting cipher text.
std::uint64_t hebench::APIBridge::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.
[in] | h_engine | Handle to the backend engine. |
[in] | h_bench_desc | Handle to benchmark description for which to obtain the text description. |
[in] | p_w_params | Workload parameters for this benchmark. May be null if no workload parameters are needed or their description is not required. |
[out] | p_description | Buffer to store C-string description of the benchmark. |
[in] | size | Size in bytes of p_description buffer. |
If p_description
is null, this function performs no copy. Use this behavior to obtain the size, in bytes, required to store the complete description, including the C-string null terminator.
If p_description
is not null, this function copies as many bytes as specified in size
from the benchmark text description into the buffer pointed to by p_description
, including the C-string null terminator.
This description is used along with other text descriptions about the workload, data types, encryption schemes, etc, to produce the benchmark report. It is intended to supply any extra description that is specific to the general-purpose fields in BenchmarkDescriptor
structure (such as other
) that is not specified by getSchemeName(), getSchemeSecurityName() and other similar functions.
std::uint64_t hebench::APIBridge::getErrorDescription | ( | Handle | h_engine, |
ErrorCode | code, | ||
char * | p_description, | ||
std::uint64_t | size | ||
) |
Retrieves the general error description of an error code.
[in] | h_engine | Handle to the backend engine. Can be a null handle (especially if there is no engine when the error occurred). |
[in] | code | Error code to describe. |
[out] | p_description | Buffer to store C-string description of the error. |
[in] | size | Size in bytes of p_description buffer. |
If p_description
is null, this function performs no copy. Use this behavior to obtain the size, in bytes, required to store the full description of the error, including the C-string null terminator.
If p_description
is not null, this function copies as many bytes as specified in size
from the error description into the buffer pointed to by p_description
, including the C-string null terminator.
std::uint64_t hebench::APIBridge::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.
[in] | h_engine | Handle to the backend engine. |
[out] | p_description | Buffer to store C-string description of the error. |
[in] | size | Size in bytes of p_description buffer. |
If p_description
is null, this function performs no copy. Use this behavior to obtain the size, in bytes, required to store the full detailed description of the error, including the C-string null terminator.
If p_description
is not null, this function copies as many bytes as specified in size
from the error description into the buffer pointed to by p_description
, including the C-string null terminator.
Detailed description is backend implementation defined. If no detailed implementation, returning the general error description is suggested. If no error has occurred, some "no error" message is suggested.
std::uint64_t hebench::APIBridge::getSchemeName | ( | Handle | h_engine, |
Scheme | s, | ||
char * | p_name, | ||
std::uint64_t | size | ||
) |
Retrieves the name of a specified scheme ID from the backend.
[in] | h_engine | Handle to the backend engine. |
[in] | s | Scheme ID. |
[out] | p_name | Buffer to store C-string name of the scheme. |
[in] | size | Size in bytes of p_name buffer. |
If p_name
is null, this function performs no copy. Use this behavior to obtain the size, in bytes, required to store the complete name of the scheme, including the C-string null terminator.
If p_name
is not null, this function copies as many bytes as specified in size
from the scheme's full name into the buffer pointed to by p_name
, including the C-string null terminator.
This function is used for report purposes.
std::uint64_t hebench::APIBridge::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.
[in] | h_engine | Handle to the backend engine. |
[in] | s | Scheme ID. |
[in] | sec | Security ID for scheme. |
[out] | p_name | Buffer to store C-string name of the security. |
[in] | size | Size in bytes of p_name buffer. |
If p_name
is null, this function performs no copy. Use this behavior to obtain the size, in bytes, required to store the complete name of the security scheme, including the C-string null terminator.
If p_name
is not null, this function copies as many bytes as specified in size
from the security scheme's full name into the buffer pointed to by p_name
, including the C-string null terminator.
This function is used for report purposes.
ErrorCode hebench::APIBridge::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.
[in] | h_engine | Handle to the backend engine to perform the benchmark. |
[in] | h_bench_desc | Handle to the benchmark description to query for information. |
[out] | p_param_count | Points to variable to receive the number of workload parameters required by the backend. |
[out] | p_default_count | Points to variable to receive the number of sets of default workload parameters supported by the backend. |
Value returned in p_param_count
is 0 if and only if p_default_count
is also 0.
ErrorCode hebench::APIBridge::initBenchmark | ( | Handle | h_benchmark, |
const BenchmarkDescriptor * | p_concrete_desc | ||
) |
Allows the benchmark to perform initialization steps based on the finalized, concrete description.
[in] | h_benchmark | Handle to a benchmark created from createBenchmark() . |
[in] | p_concrete_desc | Benchmark descriptor filled out with all the concrete information about the requests for the benchmark to run. |
HEBENCH_ECODE_SUCCESS
on success, or any other error code if an error occurred during operation, including, unsupported description values.A subscribed benchmark description may include fields that accept user-specified values, such as sample sizes in an offline test, for example. Test Harness calls this function to indicate the concrete user-specified values for all fileds in the benchmark description.
During benchmark creation, a backend only has access to the workload parameters and its own version of the description. A backend may use this function to perform extra initialization steps using the actual values for the user-specified fields in the benchmark description, if any.
ErrorCode hebench::APIBridge::initEngine | ( | Handle * | h_engine, |
const int8_t * | p_buffer, | ||
uint64_t | size | ||
) |
Initializes the backend engine.
[out] | h_engine | Points to a handle to fill with the initialized backend engine handle descriptor. Must not be null. |
[in] | p_buffer | Input buffer of bytes with extra information for engine initialization. May be null . |
[in] | size | Number of bytes pointed by p_buffer . |
Use this method to initialize backend engine, such as drivers, hardware, etc. required to perform operations.
Data stored in p_buffer
is specified by frontend user through benchmark configuration files. Test Harness will forward this information to backend using this buffer.
ErrorCode hebench::APIBridge::load | ( | Handle | h_benchmark, |
const Handle * | h_local_packed_params, | ||
std::uint64_t | local_count, | ||
Handle * | h_remote | ||
) |
Loads the specified data from the local host into the remote backend to use as parameter during a call to operate().
[in] | h_benchmark | Handle to the initialized benchmark to perform. |
[in] | h_local_packed_params | Collection of handles to the data of packed parameters to load into backend remote. |
[in] | local_count | Number of handles in array h_local_packed_params . |
[out] | h_remote | Handle representing the loaded data into the backend. |
This function exists to allow backends to transfer the data from the host into the actual device (accelerator, remote server, etc.) that will perform the operations.
Each handle in h_local_packed_params
represents an encoded/encrypted DataPackCollection object in the local host.
In general, plain text parameters will be packed together under a single DataPackCollection during encoding, and encrypted parameters will be packed together under another single DataPackCollection. Handles for each DataPackCollection are generated during encode() and encrypt() calls, and thus, h_local_packed_params
collection allows for all of these handles to be loaded at the same time. If not specified in the workload description, the order for DataPackCollection handles is encrypted first, followed by plain text when both types of parameters, encrypted and plain text, are present; otherwise, Test harness will use a single DataPackCollection for all parameters as such:
All parameters encrypted, or all parameters plain text:
Mix of encrypted and plain text parameters:
Destroying or re-utilizing collection and/or handles in h_local_packed_params
after this call completes shall not affect the resulting h_remote
handle.
ErrorCode hebench::APIBridge::operate | ( | Handle | h_benchmark, |
Handle | h_remote_packed_params, | ||
const ParameterIndexer * | p_param_indexers, | ||
uint64_t | indexers_count, | ||
Handle * | h_remote_output | ||
) |
Performs the workload operation of the benchmark.
[in] | h_benchmark | Handle to the initialized benchmark to perform. |
[in] | h_remote_packed_params | Handle representing the parameters for the operation previously loaded into the backend remote by a call to load() to use for the operation. The data represented by this handle must not be changed since it may be reused in several calls to operate() . |
[in] | p_param_indexers | Indexers for the parameters of the operation. |
[in] | indexers_count | Number of indexrs in p_param_indexers . |
[out] | h_remote_output | Handle representing the result of the operation stored in the backend remote. |
This is the function that Test Harness will benchmark. Backend MUST ensure that the complete operation runs on all specified inputs and that the corresponding outputs are generated before this function returns.
Destroying or re-using handle or values in h_remote_packed_params
and p_param_indexers
after this call completes shall not affect the resulting h_remote_output
.
The actual collection of inputs to the operation that backend must use is loaded into the backend remote using a single call of the load() function. Parameter p_param_indexers
contains the indexers for the parameter packs, and thus the number of elements in array p_param_indexers
is, at least, the same as the number of parameters required for the operation. indexers_count
specifies the actual number of elements in p_param_indexers
. The actual configuration for the call to operate()
issued by Test Harness is defined for each workload.
Once decoded, the workload results generated by this function must be indexed starting at 0, regardless of starting input sample index specified by p_param_indexers
. Any offset in the input sample index will be taken into account by Test Harness when validating the results. For more information, see Ordering of Results Based on Input Batch Sizes .
The following example shows a typical flow followed by Test Harness when performing a benchmark. Here, Test Harness is benchmarking offline an operation of the form
where parameter A has a single sample, and B has 10 samples. There is a result for each pair of values. Both parameters are encrypted. The pseudo-code submits all 10 values for B. Benchmarking statements are omitted for clarity.
ErrorCode hebench::APIBridge::store | ( | Handle | h_benchmark, |
Handle | h_remote, | ||
Handle * | h_local_packed_params, | ||
std::uint64_t | local_count | ||
) |
Retrieves the specified data from the backend.
[in] | h_benchmark | Handle to the initialized benchmark to perform. |
[in] | h_remote | Handle to the data to retrieve from backend remote and store into h_local . |
[out] | h_local_packed_params | Collection of opaque handles to represent the data stored in the local host retrieved from the backend. |
[in] | local_count | Number of available handles to receive data. |
This function is the counterpart to load().
Function operate() receives an opaque handle that represents the result of the operation in the backend. Because this result may live in a device other than the host (accelerator, remote server, etc.), a call to store()
must be issued to retrieve the data from the backend remote and store it in the host.
Each handle in h_local_packed_params
will represent an encoded/encrypted DataPackCollection object after stored in the local host. If there are not enough handles in h_local_packed_params
to store all the data from h_remote
, extra remote data will be ignored. Any extra handles will be padded with zeroes.
Destroying or re-using handle h_remote
after this call completes shall not affect the resulting h_local_packed_params
handle.
ErrorCode hebench::APIBridge::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.
[in] | h_engine | Backend engine handle. |
[out] | p_h_bench_descs | Pointer to array where to store the handles to the benchmark descriptions. Array has capacity for count handles. Cannot be null. |
[in] | count | Number of handles available in array pointed by p_h_bench_descs . This is will be as many handles as returned by subscribeBenchmarksCount() . |
The handles in p_h_bench_descs
are pointed to the internal representation of the description of each benchmark that the backend is registering to perform. These benchmark description handles shall be used to query information about the registered benchmarks without having to instantiate the represented benchmark proper, and to instantiate the benchmark once it is time to execute it by calling the appropriate API bridge functions.
Retrieves the number of benchmarks for which the backend is registering to perform.
[in] | h_engine | Backend engine handle. |
[out] | p_count | Points to variable to receive the result. Cannot be null. |
The number of benchmarks returned in p_count
for which backend is subscribing must be greater than 0.