Developer Reference for Intel® Integrated Performance Primitives

TopK

Returns maximum K values of an array.

Syntax

IppStatus ippsTopK_32f(const Ipp32f pSrc, Ipp64s srcIndex, Ipp64s srcLen, Ipp32f* pDstValue, Ipp64s* pDstIndex, Ipp64s dstLen, IppTopKMode hint, Ipp8u* pBuffer);

IppStatus ippsTopK_32s(const Ipp32s pSrc, Ipp64s srcIndex, Ipp64s srcLen, Ipp32s* pDstValue, Ipp64s* pDstIndex, Ipp64s dstLen, IppTopKMode hint, Ipp8u* pBuffer);

Include Files

ipps.h

Domain Dependencies

Headers: ippcore.h, ippvm.h

Libraries: ippcore.lib, ippvm.lib

Parameters

pSrc

Pointer to the source vector.

srcIndex

Index of the pSrc[0] element, index of pSrc[n] is equal to srcIndex+n.

srcLen

Number of elements in the source vector.

pDstValue

Maximum values found by the function.

dstIndex

Indexes of maximum values.

dstLen

Number of K values to be returned, the function returns min(K, dstLen) elements.

hint

Parameter to choose the optimization that is most suitable for the srcLen+dstlen(K) combination, supported values: ippTopKAuto/ ippTopKDirect/ ippTopKRadix.

pBuffer

Pointer to the work buffer.

Description

This function searches for dstLen maximum values and their indexes in an input vector. The function is designed to process large input vectors by small blocks, it takes into account results of previous blocks processing getting maximum values of pSrc and pDstValue and then combining the final results into pDstValue.

The srcIndex parameter stores the index of the first element pSrc[0] of each new block, thus supporting the continuous numbering of elements. Before calling the ippsTopK function, compute the required buffer size and initialize pDstValue and pDstIndex using the ippsTopKGetBufferSize and ippsTopKInit_32s functions, respectively.

Return Values

ippStsNoErr

Indicates no error.

ippStsNullPtrErr

Indicates an error when at least one of the pointers is NULL.

ippStsSizeErr

Indicates an error when at least one of the srcLen or dstLen values is less than, or equal to zero.

ippStsBadArgErr

Indicates an error when the hint value is not supported.

See Also