RLPack
 
Loading...
Searching...
No Matches
Offload< DType > Class Template Reference

Template Offload class for CPU with CPU optimized OpenMP routines. More...

Public Member Functions

template<class Container >
void arg_quantile_segment_indices (int64_t numSegments, const Container &inputContainer, int64_t parallelismSizeThreshold)
 
template<class Container >
DType cumulative_sum (const Container &inputContainer, int64_t parallelismSizeThreshold)
 
void generate_priority_seeds (DType cumulativeSum, int64_t parallelismSizeThreshold, uint64_t startPoint=0.0)
 
 Offload (int64_t bufferSize)
 
void reset ()
 
template<class Container >
void shuffle (const Container &inputContainer, int64_t parallelismSizeThreshold, size_t numElements=-1)
 
 ~Offload ()
 

Data Fields

std::vector< DType > result
 The vector to store final results. More...
 

Private Attributes

float_t * errorArray_
 Float pointer to an array to store random errors. More...
 
uint64_t * indexArray_
 Int64 pointer to an array to store indices. More...
 
DType * inputContainerData_
 DType pointer to an array to store input container's data to be processed. More...
 
std::vector< int64_t > priorityFrequencies_
 The Vector to store frequencies of each priority. This is used in Offload::arg_quantile_segment_indices method. More...
 
std::vector< DType > toShuffleVector_
 The Vector to store intermediate values to be shuffled. More...
 
std::vector< DType > uniquePriorities_
 The Vector to store unique priorities. This is used in Offload::arg_quantile_segment_indices method. More...
 

Detailed Description

template<typename DType>
class Offload< DType >

Template Offload class for CPU with CPU optimized OpenMP routines.

Constructor & Destructor Documentation

◆ Offload()

template<typename DType >
Offload< DType >::Offload ( int64_t  bufferSize)
explicit

Constructor for Offload. Dynamically allocates required memory and initialises necessary variables.

◆ ~Offload()

template<typename DType >
Offload< DType >::~Offload

Destructor for Offload. De-allocated all dynamically allocated memory.

Member Function Documentation

◆ arg_quantile_segment_indices()

template<typename DType >
template<class Container >
void Offload< DType >::arg_quantile_segment_indices ( int64_t  numSegments,
const Container &  inputContainer,
int64_t  parallelismSizeThreshold 
)

The template method generates the quantile segments for given input container and the resulting indices of inputContainer from this operation is flushed into Offload::result.

Template Arguments

  • Container: Must be an STL Container initialised with DType, hence must have implemented size method.
Parameters
numSegments: The number of segments to be divided inputContainer into.
inputContainer: The input container which is to be divided into numSegments segments.
parallelismSizeThreshold: The threshold size of inputContainer beyond which OpenMP parallelized routines are to be used.

◆ cumulative_sum()

template<typename DType >
template<class Container >
DType Offload< DType >::cumulative_sum ( const Container &  inputContainer,
int64_t  parallelismSizeThreshold 
)

This template method computes the cumulative sum of a given input container.

Template Arguments

  • Container: Must be an STL Container initialised with DType, hence must have implemented size method.
Parameters
inputContainer: The input container for which sum has to be computed.
parallelismSizeThreshold: The threshold size of inputContainer beyond which OpenMP parallelized routines are to be used.
Returns
The cumulative sum.

◆ generate_priority_seeds()

template<typename DType >
void Offload< DType >::generate_priority_seeds ( DType  cumulativeSum,
int64_t  parallelismSizeThreshold,
uint64_t  startPoint = 0.0 
)

This method generates the priority seeds. This is used by C_Memory::sample when using proportional prioritization strategy. This method generates seeds between arguments startPoint and cumulativeSum. Results are flushed into Offload::result.

Parameters
cumulativeSum: The cumulative sum upto which the seeds are to be generated.
parallelismSizeThreshold: The threshold size of inputContainer beyond which OpenMP parallelized routines are to be used.
startPoint: The start point, i.e. the smallest value of the generated seeds.

◆ reset()

template<typename DType >
void Offload< DType >::reset

Reset method for Offload. This will clear the Offload::result vector and fills it with 0.

◆ shuffle()

template<typename DType >
template<class Container >
void Offload< DType >::shuffle ( const Container &  inputContainer,
int64_t  parallelismSizeThreshold,
size_t  numElements = -1 
)

This template method shuffles the given input container. Results are flushed into Offload::shuffle

Template Arguments

  • Container: Must be an STL Container initialised with DType, hence must have implemented size method.
Parameters
inputContainer: The input container which has to be shuffled.
parallelismSizeThreshold: The threshold size of inputContainer beyond which OpenMP parallelized routines are to be used.
numElements: The number of elements in the inputContainer from the beginning to be shuffled. Default: -1, which will include all the elements of inputContainer.

Field Documentation

◆ errorArray_

template<typename DType >
float_t* Offload< DType >::errorArray_
private

Float pointer to an array to store random errors.

◆ indexArray_

template<typename DType >
uint64_t* Offload< DType >::indexArray_
private

Int64 pointer to an array to store indices.

◆ inputContainerData_

template<typename DType >
DType* Offload< DType >::inputContainerData_
private

DType pointer to an array to store input container's data to be processed.

◆ priorityFrequencies_

template<typename DType >
std::vector<int64_t> Offload< DType >::priorityFrequencies_
private

The Vector to store frequencies of each priority. This is used in Offload::arg_quantile_segment_indices method.

◆ result

template<typename DType >
std::vector<DType> Offload< DType >::result

The vector to store final results.

◆ toShuffleVector_

template<typename DType >
std::vector<DType> Offload< DType >::toShuffleVector_
private

The Vector to store intermediate values to be shuffled.

◆ uniquePriorities_

template<typename DType >
std::vector<DType> Offload< DType >::uniquePriorities_
private

The Vector to store unique priorities. This is used in Offload::arg_quantile_segment_indices method.