SortPayloadVpu#

Fully qualified name: pvaApl::SortPayloadVpu

Defined in public/src/primitive/pvaAplSortPayloadVpu.hpp

template<typename DataType, int Size>
class SortPayloadVpu#

SortPayload primitive template class.

Template Parameters:
  • DataType – Data Type of the input array. Must be one of: uint32_t, int32_t.

  • Size – Number of elements to sort. For 32-bit data type, must be one of: 512, 1024, 2048, 4096, 8192.

Public Functions

inline SortPayloadVpu()#
inline size_t Init(
DataType *src,
DataType *dst,
AgenCFG *cfgs,
uint8_t *scratch,
)#

Initialize the SortPayload algorithm parameters, setup agens for the Execute method.

The SortPayload primitive treats two consecutive elements as a key-payload pair and sort them based on the key value. Template parameter Size is the number of elements (including key and payload) in the input data. The SortPayload primitive only supports ascending sort.

Taking the two buffers separately lets the caller place them in different VMEM superbanks. Use the SortPayloadContext overload when a single combined allocation is acceptable.

Parameters:
  • src – Pointer to the src buffer which contains the input data. The input data should be consecutively stored in a 1D array with no pitch. Input buffer size should be at least MIN_INPUT_BUFFER_SIZE.

  • dst – Pointer to the dst buffer where the result is written to. The output data will be stored in a 2D array with width = Size / 8, height = 8, pitch = Size / 8 + 2. Output buffer size should be at least MIN_OUTPUT_BUFFER_SIZE.

  • cfgs – Caller-owned storage for at least CFG_COUNT address-generator configurations.

  • scratch – Caller-owned scratch buffer of at least SCRATCH_SIZE bytes.

Returns:

Number of configurations written, which always equals CFG_COUNT.

inline void Init(
DataType *src,
DataType *dst,
SortPayloadContext *context,
)#

Initialize using the primitive’s combined context storage.

Parameters:
  • src – Pointer to the src buffer. Same requirements as in the overload taking separate buffers.

  • dst – Pointer to the dst buffer. Same requirements as in the overload taking separate buffers.

  • context – Pointer to the SortPayloadContext that provides the configuration and scratch storage.

inline void Execute(AgenCFG *cfgs)#

Execute the SortPayload algorithm using caller-owned address-generator configurations.

Parameters:

cfgs – The same configuration storage that was passed to Init().

inline void Execute(SortPayloadContext *context)#

Execute using the primitive’s combined context storage.

Parameters:

context – The same context that was passed to Init().

Public Static Attributes

static constexpr size_t CFG_COUNT = {detail::SortPayloadInitCfgCount(pva_elementsof(DVTYPEX), Size / pva_elementsof(DVTYPEX))}#

Number of address-generator configurations Init() writes for this instantiation.

Can be used to allocate appropriately sized configuration buffers or verify buffer sizes with static_assert.

static constexpr size_t CFGS_SIZE = {CFG_COUNT * sizeof(AgenCFG)}#

Minimum required size in bytes for the address-generator configuration buffer.

static constexpr size_t SCRATCH_SIZE{(pva_elementsof(DVTYPEX) + 2) * (Size / pva_elementsof(DVTYPEX)) * sizeof(DataType)}#

Minimum required size in bytes for the scratch buffer.

Can be used to allocate appropriately sized scratch buffers or verify buffer sizes with static_assert.

static constexpr size_t MIN_INPUT_BUFFER_SIZE{(pva_elementsof(DVTYPEX) + 2) * (Size / pva_elementsof(DVTYPEX)) * sizeof(DataType)}#

Minimum required size in bytes for the input buffer.

Can be used to allocate appropriately sized input buffers or verify buffer sizes with static_assert.

static constexpr size_t MIN_OUTPUT_BUFFER_SIZE{(2 * Size / pva_elementsof(DVTYPEX) + 2) * (pva_elementsof(DVTYPEX) / 2) * sizeof(DataType)}#

Minimum required size in bytes for the output buffer.

Can be used to allocate appropriately sized output buffers or verify buffer sizes with static_assert.