HEBench
types.h File Reference
#include <cstdint>
#include "version.h"
Include dependency graph for types.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  hebench::APIBridge::WorkloadParam
 Defines a single workload parameter. More...
 
struct  hebench::APIBridge::WorkloadParams
 Specifies the parameters for a workload. More...
 
struct  hebench::APIBridge::CategoryParams
 Specifies parameters for a category. More...
 
struct  hebench::APIBridge::BenchmarkDescriptor
 Defines a benchmark test. More...
 
struct  hebench::APIBridge::_FlexibleData
 Structure to contain flexible data. More...
 
struct  hebench::APIBridge::DataPack
 Defines a data package for an operation. More...
 
struct  hebench::APIBridge::DataPackCollection
 Defines a collection of data packs. More...
 
struct  hebench::APIBridge::ParameterIndexer
 Indexes a DataPack. More...
 
union  hebench::APIBridge::WorkloadParam.__unnamed5__
 
union  hebench::APIBridge::CategoryParams.__unnamed7__
 
struct  hebench::APIBridge::CategoryParams.__unnamed7__.latency
 
struct  hebench::APIBridge::CategoryParams.__unnamed7__.offline
 

Namespaces

 hebench
 
 hebench::APIBridge
 
 hebench::APIBridge::WorkloadParamType
 

Macros

#define HEBENCH_ECODE_SUCCESS   0
 Function call succeeded without error. More...
 
#define HEBENCH_ECODE_INVALID_ARGS   0x7ffffffe
 Indicates invalid arguments to function call. More...
 
#define HEBENCH_ECODE_CRITICAL_ERROR   0x7fffffff
 Specifies a critical error. More...
 
#define HEBENCH_MAX_BUFFER_SIZE   256
 
#define HEBENCH_MAX_OP_PARAMS   32
 Maximum number of parameters supported by an operation. More...
 
#define HEBENCH_MAX_CATEGORY_PARAMS   HEBENCH_MAX_OP_PARAMS * 2
 Maximum number of parameters for Category benchmark descriptor. More...
 
#define HEBENCH_HE_SCHEME_CKKS   100
 
#define HEBENCH_HE_SCHEME_BFV   101
 
#define HEBENCH_HE_SCHEME_BGV   102
 
#define HEBENCH_HE_PARAM_FLAGS_ALL_CIPHER   0xffffffff
 
#define HEBENCH_HE_PARAM_FLAGS_ALL_PLAIN   0x0
 
#define NULL_HANDLE   hebench::APIBridge::_FlexibleData({ 0, 0, 0 })
 

Typedefs

typedef std::int32_t hebench::APIBridge::ErrorCode
 Return value for API bridge functions. More...
 
typedef std::int32_t hebench::APIBridge::Scheme
 Open-ended homomorphic encryption scheme ID. More...
 
typedef std::int32_t hebench::APIBridge::Security
 Open-ended homomorphic encryption scheme security ID. More...
 
typedef _FlexibleData hebench::APIBridge::NativeDataBuffer
 Represents a native data buffer maintained by the Test Harness. More...
 
typedef _FlexibleData hebench::APIBridge::Handle
 Encapsulates an opaque handle to backend data. More...
 

Enumerations

enum  hebench::APIBridge::Workload {
  hebench::APIBridge::MatrixMultiply = 1 , hebench::APIBridge::EltwiseAdd , hebench::APIBridge::EltwiseMultiply , hebench::APIBridge::DotProduct ,
  hebench::APIBridge::LogisticRegression , hebench::APIBridge::LogisticRegression_PolyD3 , hebench::APIBridge::LogisticRegression_PolyD5 , hebench::APIBridge::LogisticRegression_PolyD7 ,
  hebench::APIBridge::SimpleSetIntersection , hebench::APIBridge::Generic
}
 Defines all possible workloads. More...
 
enum  hebench::APIBridge::WorkloadParamType::WorkloadParamType { hebench::APIBridge::WorkloadParamType::Int64 = 1 , hebench::APIBridge::WorkloadParamType::UInt64 , hebench::APIBridge::WorkloadParamType::Float64 }
 Defines the possible data types for a workload flexible parameter. More...
 
enum  hebench::APIBridge::DataType { hebench::APIBridge::Int32 = 1 , hebench::APIBridge::Int64 , hebench::APIBridge::Float32 , hebench::APIBridge::Float64 }
 Defines data types for a workload. More...
 
enum  hebench::APIBridge::Category { hebench::APIBridge::Latency = 1 , hebench::APIBridge::Offline }
 Defines all possible categories for each workload. More...
 

Class Documentation

◆ hebench::APIBridge::WorkloadParam

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.

See also
WorkloadParams

Definition at line 317 of file types.h.

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.

◆ hebench::APIBridge::WorkloadParams

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.

Definition at line 362 of file types.h.

Collaboration diagram for hebench::APIBridge::WorkloadParams:
Class Members
uint64_t count Number of workload parameters.
WorkloadParam * params Parameters for the workload.

◆ hebench::APIBridge::CategoryParams

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.

Definition at line 421 of file types.h.

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 0, indicates that the minimum test time is user-specified at run-time via configuration files.

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.

◆ hebench::APIBridge::BenchmarkDescriptor

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.

See also
WorkloadParams

Definition at line 526 of file types.h.

Collaboration diagram for hebench::APIBridge::BenchmarkDescriptor:
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.

◆ hebench::APIBridge::_FlexibleData

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.

Definition at line 551 of file types.h.

Class Members
void * p Pointer to underlying data.

While this field does not necessarily need to point to any data (or contain a valid pointer value), it usually points to underlying data buffer(s).

uint64_t size Size of underlying data.

Usually specifies the size, in bytes, of the underlying data represented by this structure.

int64_t tag Optional tag.

Flexible extra field to allow further customization of this structure.

◆ hebench::APIBridge::DataPack

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.

Definition at line 610 of file types.h.

Collaboration diagram for hebench::APIBridge::DataPack:
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.

◆ hebench::APIBridge::DataPackCollection

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.

Definition at line 623 of file types.h.

Collaboration diagram for hebench::APIBridge::DataPackCollection:
Class Members
DataPack * p_data_packs Collection of data packs.
uint64_t pack_count Number of data packs in the collection.

◆ hebench::APIBridge::ParameterIndexer

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 .

See also
DataPack, operate(), Ordering of Results Based on Input Batch Sizes

Definition at line 649 of file types.h.

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.

◆ hebench::APIBridge::WorkloadParam.__unnamed5__

union hebench::APIBridge::WorkloadParam.__unnamed5__

Definition at line 329 of file types.h.

Class Members
double f_param 64 bits double precision floating point argument value for workload parameter.

Only one of i_param, u_param, f_param must be set for the workload parameter, based on data_type.

int64_t i_param 64 bits signed integer argument value for workload parameter.

Only one of i_param, u_param, f_param must be set for the workload parameter, based on data_type.

uint64_t u_param 64 bits unsigned integer argument value for workload parameter.

Only one of i_param, u_param, f_param must be set for the workload parameter, based on data_type.

◆ hebench::APIBridge::CategoryParams.__unnamed7__

union hebench::APIBridge::CategoryParams.__unnamed7__

Definition at line 448 of file types.h.

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.

◆ hebench::APIBridge::CategoryParams.__unnamed7__.latency

struct hebench::APIBridge::CategoryParams.__unnamed7__.latency

Definition at line 457 of file types.h.

Class Members
uint64_t warmup_iterations_count Specifies the number of warmup iterations to perform for latency test.

Latency benchmark will run the operation this many iterations with the same set of inputs before doing any actual measurement. The operation results and measured times for the operation during warmup are not counted under the actual operation timing, although may be reported under warmup.

◆ hebench::APIBridge::CategoryParams.__unnamed7__.offline

struct hebench::APIBridge::CategoryParams.__unnamed7__.offline

Definition at line 469 of file types.h.

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 0 indicates to Test Harness that number of samples for the corresponding operation parameter accepts any value. In this case, sample size is user-specified at run-time via configuration files. If value specified by Test user is also 0, the sample size for the operation parameter is defined in the workload specification.

Regardless of the sample sizes (specified or default), the actual number of samples may be limited by the dataset for the workload, if any.

Macro Definition Documentation

◆ HEBENCH_ECODE_CRITICAL_ERROR

#define HEBENCH_ECODE_CRITICAL_ERROR   0x7fffffff

Specifies a critical error.

Returning this on an API bridge call will prompt the Test Harness to terminate immediately. Test Harness will stop benchmarking and attempt to clean up any open handles before exiting. Any further errors are ignored.

Definition at line 50 of file types.h.

◆ HEBENCH_ECODE_INVALID_ARGS

#define HEBENCH_ECODE_INVALID_ARGS   0x7ffffffe

Indicates invalid arguments to function call.

Definition at line 42 of file types.h.

◆ HEBENCH_ECODE_SUCCESS

#define HEBENCH_ECODE_SUCCESS   0

Function call succeeded without error.

Definition at line 39 of file types.h.

◆ HEBENCH_HE_PARAM_FLAGS_ALL_CIPHER

#define HEBENCH_HE_PARAM_FLAGS_ALL_CIPHER   0xffffffff

Definition at line 74 of file types.h.

◆ HEBENCH_HE_PARAM_FLAGS_ALL_PLAIN

#define HEBENCH_HE_PARAM_FLAGS_ALL_PLAIN   0x0

Definition at line 75 of file types.h.

◆ HEBENCH_HE_SCHEME_BFV

#define HEBENCH_HE_SCHEME_BFV   101

Definition at line 69 of file types.h.

◆ HEBENCH_HE_SCHEME_BGV

#define HEBENCH_HE_SCHEME_BGV   102

Definition at line 70 of file types.h.

◆ HEBENCH_HE_SCHEME_CKKS

#define HEBENCH_HE_SCHEME_CKKS   100

Definition at line 68 of file types.h.

◆ HEBENCH_MAX_BUFFER_SIZE

#define HEBENCH_MAX_BUFFER_SIZE   256

Definition at line 56 of file types.h.

◆ HEBENCH_MAX_CATEGORY_PARAMS

#define HEBENCH_MAX_CATEGORY_PARAMS   HEBENCH_MAX_OP_PARAMS * 2

Maximum number of parameters for Category benchmark descriptor.

Definition at line 65 of file types.h.

◆ HEBENCH_MAX_OP_PARAMS

#define HEBENCH_MAX_OP_PARAMS   32

Maximum number of parameters supported by an operation.

Definition at line 63 of file types.h.

◆ NULL_HANDLE

#define NULL_HANDLE   hebench::APIBridge::_FlexibleData({ 0, 0, 0 })

Definition at line 572 of file types.h.