HEBench
hebench::TestHarness::IDataLoader Class Referenceabstract

#include <hebench_idata_loader.h>

Inheritance diagram for hebench::TestHarness::IDataLoader:

Classes

struct  ResultData
 

Public Types

template<typename T >
using unique_ptr_custom_deleter = hebench::TestHarness::unique_ptr_custom_deleter< T >
 
typedef std::shared_ptr< ResultDataResultDataPtr
 
typedef std::shared_ptr< IDataLoaderPtr
 

Public Member Functions

virtual ~IDataLoader ()
 
virtual std::uint64_t getParameterCount () const =0
 Number of parameter components (operands) for the represented operation. More...
 
virtual const hebench::APIBridge::DataPackgetParameterData (std::uint64_t param_position) const =0
 Data pack for specified operation parameter (operand). More...
 
virtual std::uint64_t getResultCount () const =0
 Number of components in a result for the represented operation. More...
 
virtual const hebench::APIBridge::DataPackgetResultData (std::uint64_t param_position) const =0
 Data pack corresponding to the specified component of the result. More...
 
virtual ResultDataPtr getResultFor (const std::uint64_t *param_data_pack_indices)=0
 getResultFor More...
 
virtual std::uint64_t getResultIndex (const std::uint64_t *param_data_pack_indices) const =0
 Computes the index of the result NativeDataBuffer given the indices of the input data. More...
 
virtual std::uint64_t getTotalDataLoaded () const =0
 Total data loaded by this loader in bytes. More...
 

Static Public Member Functions

static std::size_t sizeOf (hebench::APIBridge::DataType data_type)
 
static unique_ptr_custom_deleter< hebench::APIBridge::DataPackCollectioncreateDataPackCollection (std::uint64_t data_pack_count)
 Creates shallow packed data that self cleans up. More...
 
static unique_ptr_custom_deleter< hebench::APIBridge::DataPackcreateDataPack (std::uint64_t buffer_count, std::uint64_t param_position)
 Creates shallow data pack that self cleans up. More...
 
static unique_ptr_custom_deleter< hebench::APIBridge::NativeDataBuffercreateDataBuffer (std::uint64_t size, std::int64_t tag)
 

Protected Member Functions

 IDataLoader ()
 

Detailed Description

Definition at line 21 of file hebench_idata_loader.h.


Class Documentation

◆ hebench::TestHarness::IDataLoader::ResultData

struct hebench::TestHarness::IDataLoader::ResultData

Definition at line 33 of file hebench_idata_loader.h.

Collaboration diagram for hebench::TestHarness::IDataLoader::ResultData:
Class Members
shared_ptr< void > reserved0
vector< const NativeDataBuffer * > result Points to the NativeDataBuffer s containing the result sample for an input sample.
uint64_t sample_index Index of the result sample.

Member Typedef Documentation

◆ Ptr

Definition at line 48 of file hebench_idata_loader.h.

◆ ResultDataPtr

Definition at line 46 of file hebench_idata_loader.h.

◆ unique_ptr_custom_deleter

Constructor & Destructor Documentation

◆ ~IDataLoader()

virtual hebench::TestHarness::IDataLoader::~IDataLoader ( )
inlinevirtual

Definition at line 50 of file hebench_idata_loader.h.

◆ IDataLoader()

hebench::TestHarness::IDataLoader::IDataLoader ( )
inlineprotected

Definition at line 213 of file hebench_idata_loader.h.

Member Function Documentation

◆ createDataBuffer()

IDataLoader::unique_ptr_custom_deleter< hebench::APIBridge::NativeDataBuffer > hebench::TestHarness::IDataLoader::createDataBuffer ( std::uint64_t  size,
std::int64_t  tag 
)
static

Definition at line 121 of file hebench_idata_loader.cpp.

◆ createDataPack()

IDataLoader::unique_ptr_custom_deleter< hebench::APIBridge::DataPack > hebench::TestHarness::IDataLoader::createDataPack ( std::uint64_t  buffer_count,
std::uint64_t  param_position 
)
static

Creates shallow data pack that self cleans up.

Parameters
[in]buffer_countNumber of NativeDataBuffer objects pointed to by this DataPack.
[in]param_positionParameter position of this DataPack.
Returns
A smart pointer to a DataPack structure.

The returned DataPack will self clean up its p_buffers field when it goes out of scope.

Clients can use the created DataPack by pointing to their NativeDataBuffer objects in the pre-allocated p_buffers field array.

Definition at line 87 of file hebench_idata_loader.cpp.

◆ createDataPackCollection()

IDataLoader::unique_ptr_custom_deleter< hebench::APIBridge::DataPackCollection > hebench::TestHarness::IDataLoader::createDataPackCollection ( std::uint64_t  data_pack_count)
static

Creates shallow packed data that self cleans up.

Parameters
[in]data_pack_countNumber of DataPack objects that will be pointed to by this DataPackCollection.
Returns
A smart pointer to a DataPackCollection structure.

The returned DataPackCollection will self clean up its p_data_packs field when it goes out of scope.

Clients can use the created DataPackCollection by pointing to their DataPack objects in the pre-allocated p_data_packs field array.

Definition at line 54 of file hebench_idata_loader.cpp.

◆ getParameterCount()

virtual std::uint64_t hebench::TestHarness::IDataLoader::getParameterCount ( ) const
pure virtual

Number of parameter components (operands) for the represented operation.

This is the number of operands for the operation. For example, a unary operation has 1 operand, binary has 2, n-ary has n.

Implemented in hebench::TestHarness::PartialDataLoader.

◆ getParameterData()

virtual const hebench::APIBridge::DataPack& hebench::TestHarness::IDataLoader::getParameterData ( std::uint64_t  param_position) const
pure virtual

Data pack for specified operation parameter (operand).

Parameters
[in]param_positionZero-based position of the parameter.
Returns
A data pack containing the collection of samples for the specified parameter.

The parameter position for an operation is zero-based starting from the leftmost parameter. i.e. For an operation such as:

R = op(A, B, C, ...)

R is the result, A is parameter 0, B, is parameter 1, C is parameter 2, etc.

Implemented in hebench::TestHarness::PartialDataLoader.

◆ getResultCount()

virtual std::uint64_t hebench::TestHarness::IDataLoader::getResultCount ( ) const
pure virtual

Number of components in a result for the represented operation.

Shape of result is always 2D: [getResultCount(), ?].

For example, if the represented operation has getParameterCount() = 3 input parameters and getResultCount() = 2 outputs, then, the shape of the result is

virtual const hebench::APIBridge::DataPack & getParameterData(std::uint64_t param_position) const =0
Data pack for specified operation parameter (operand).
std::uint64_t buffer_count
Number of data buffers in p_buffers.
Definition: types.h:613

Implemented in hebench::TestHarness::PartialDataLoader.

◆ getResultData()

virtual const hebench::APIBridge::DataPack& hebench::TestHarness::IDataLoader::getResultData ( std::uint64_t  param_position) const
pure virtual

Data pack corresponding to the specified component of the result.

Parameters
[in]param_positionZero-based position of the component to return.
Returns
The data pack containing the collection of samples for the specified component of the result.

Implemented in hebench::TestHarness::PartialDataLoader.

◆ getResultFor()

virtual ResultDataPtr hebench::TestHarness::IDataLoader::getResultFor ( const std::uint64_t *  param_data_pack_indices)
pure virtual

getResultFor

Parameters
[in]param_data_pack_indicesCollection of indices for data sample to use inside each parameter pack. Number of elements pointed must be, at least, getParameterCount().
Returns
Returns a non-null pointer ResultData containing the ground-truth result corresponding to the specified parameter indices.
Exceptions
std::out_of_rangeif any index is out of range.
std::invalid_argumentif param_data_pack_indices is null.
instanceof std::exception on any other error.

The shape of result is always 2D: [n = getResultCount(), ?], so, the result for an operation is

(result[0][r_i], result[1][r_i], ..., result[n-1][r_i])

where r_i is the index of the NativeDataBuffers for the result in the second dimension.

See also
getResultIndex()

Implemented in hebench::TestHarness::PartialDataLoader, and hebench::TestHarness::DataLoaderCompute.

◆ getResultIndex()

virtual std::uint64_t hebench::TestHarness::IDataLoader::getResultIndex ( const std::uint64_t *  param_data_pack_indices) const
pure virtual

Computes the index of the result NativeDataBuffer given the indices of the input data.

Parameters
[in]param_data_pack_indicesCollection of indices for data sample to use inside each parameter pack. Number of elements pointed must be, at least, parameterCount().
Returns
Returns the index for the ground-truth result corresponding to the specified parameter indices.
Exceptions
std::out_of_rangeif any index is out of range.
std::invalid_argumentif param_data_pack_indices is null.

The shape of result is always 2D: [n = resultCount(), ?], so, the result for an operation is

(result[0][r_i], result[1][r_i], ..., result[n-1][r_i])

where r_i is the index of the data buffer for the result in the second dimension.

By specification definition, the result index (r_i) is computed in a row-major fashion, where the most significant parameter moves faster.

In general:

r_i = param_data_pack_indices[0]
for i in [1..getParameterCount() - 1]
r_i = param_data_pack_indices[i] + getParameterData(i).buffer_count * r_i;

For example, given the operation op() that returns a result of the shape [1, ?]:

param_count[0] = 3;
param_count[1] = 10;
Param[0][param_count[0]]
Param[1][param_count[1]]
param_data_pack_indices[0] = 2
param_data_pack_indices[1] = 3
Result = op(param_data_pack_indices[0], param_data_pack_indices[1]);

Then, r_i, the index in the second dimension that corresponds to the NativeDataBuffer in getResultData(0) where the result of the operation using the specified indices will be placed, is computed in row-major order as:

r_i = param_data_pack_indices[0] * param_count[1] + param_data_pack_indices[1]
r_i = 2 * 10 + 3 = 23

then, Result is actually:

Result = [[ getResultData(0).p_buffers[r_i] ]]
or
Result = [[ getResultData(0).p_buffers[23] ]]
virtual const hebench::APIBridge::DataPack & getResultData(std::uint64_t param_position) const =0
Data pack corresponding to the specified component of the result.
NativeDataBuffer * p_buffers
Array of data buffers for parameter.
Definition: types.h:612

For complete details, see Ordering of Results Based on Input Batch Sizes .

See also
hebench::APIBridge::Category::Offline

Implemented in hebench::TestHarness::PartialDataLoader.

◆ getTotalDataLoaded()

virtual std::uint64_t hebench::TestHarness::IDataLoader::getTotalDataLoaded ( ) const
pure virtual

Total data loaded by this loader in bytes.

Implemented in hebench::TestHarness::PartialDataLoader.

◆ sizeOf()

std::size_t hebench::TestHarness::IDataLoader::sizeOf ( hebench::APIBridge::DataType  data_type)
static

Definition at line 23 of file hebench_idata_loader.cpp.


The documentation for this class was generated from the following files: