DSPLIB User Guide
DSPLIB_matMul_fixed_ci.cpp File Reference

Go to the source code of this file.

Macros

#define SE_PARAM_BASE   (0x0000)
 
#define SE0_PARAM_OFFSET   (SE_PARAM_BASE)
 
#define SE1_PARAM_OFFSET   (SE0_PARAM_OFFSET + SE_PARAM_SIZE)
 
#define SA0_PARAM_OFFSET   (SE1_PARAM_OFFSET + SE_PARAM_SIZE)
 
#define DSPLIB_MATMUL_FIXED_UNROLL   (32)
 

Functions

template<typename dataTypeIn , typename dataTypeOut >
void DSPLIB_matMul_fixed_PromoteTranspose_init_ci (__SE_TEMPLATE_v1 *se0Params, __SE_TEMPLATE_v1 *se1Params)
 
template<>
void DSPLIB_matMul_fixed_PromoteTranspose_init_ci< DSPLIB_MATMAPY_FXD_I16S_O16S > (__SE_TEMPLATE_v1 *se0Params, __SE_TEMPLATE_v1 *se1Params)
 
template<>
void DSPLIB_matMul_fixed_PromoteTranspose_init_ci< DSPLIB_MATMAPY_FXD_I8S_O8S > (__SE_TEMPLATE_v1 *se0Params, __SE_TEMPLATE_v1 *se1Params)
 
template<typename dataTypeIn , typename dataTypeOut >
DSPLIB_STATUS DSPLIB_matMul_fixed_init_ci (DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsIn0, const DSPLIB_bufParams2D_t *bufParamsIn1, const DSPLIB_bufParams2D_t *bufParamsOut, const DSPLIB_matMul_fixed_InitArgs *pKerInitArgs)
 This function is the initialization function for the C7x implementation of the kernel. The function declaration conforms to the declaration of DSPLIB_matMul_fixed_init. More...
 
template DSPLIB_STATUS DSPLIB_matMul_fixed_init_ci< DSPLIB_MATMAPY_FXD_I8S_O8S > (DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsIn0, const DSPLIB_bufParams2D_t *bufParamsIn1, const DSPLIB_bufParams2D_t *bufParamsOut, const DSPLIB_matMul_fixed_InitArgs *pKerInitArgs)
 
template DSPLIB_STATUS DSPLIB_matMul_fixed_init_ci< DSPLIB_MATMAPY_FXD_I16S_O16S > (DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsIn0, const DSPLIB_bufParams2D_t *bufParamsIn1, const DSPLIB_bufParams2D_t *bufParamsOut, const DSPLIB_matMul_fixed_InitArgs *pKerInitArgs)
 
template<typename V >
static c7x::uchar_vec setMask ()
 
template<>
c7x::uchar_vec setMask< int16_t > ()
 
template<>
c7x::uchar_vec setMask< int8_t > ()
 
template<typename V , __SE_REG , __SE_REG >
static void vecMulAcc (V outSum0, V outSum1)
 
template<>
void vecMulAcc< c7x::long_vec &, __SE_REG_0, __SE_REG_1_ADV > (c7x::long_vec &outSum0, c7x::long_vec &outSum1)
 
template<>
void vecMulAcc< c7x::long_vec &, __SE_REG_0_ADV, __SE_REG_1_ADV > (c7x::long_vec &outSum0, c7x::long_vec &outSum1)
 
template<>
void vecMulAcc< c7x::int_vec &, __SE_REG_0, __SE_REG_1_ADV > (c7x::int_vec &outSum0, c7x::int_vec &outSum1)
 
template<>
void vecMulAcc< c7x::int_vec &, __SE_REG_0_ADV, __SE_REG_1_ADV > (c7x::int_vec &outSum0, c7x::int_vec &outSum1)
 
template<typename V >
static void vecShiftRight (V vecSR0, V vecSR1, V shiftVec)
 
template<>
void vecShiftRight< c7x::long_vec & > (c7x::long_vec &vecSRL0, c7x::long_vec &vecSRL1, c7x::long_vec &shiftVec)
 
template<>
void vecShiftRight< c7x::int_vec & > (c7x::int_vec &vecSRI0, c7x::int_vec &vecSRI1, c7x::int_vec &shiftVec)
 
template<typename V >
static void resetVec (V vecRes0, V vecRes1)
 
template<>
void resetVec< c7x::long_vec & > (c7x::long_vec &vecResL0, c7x::long_vec &vecResL1)
 
template<>
void resetVec< c7x::int_vec & > (c7x::int_vec &vecResI0, c7x::int_vec &vecResI1)
 
template<typename V >
static void packAlternate (V vecPA0, V vecPA1, V vecPA2, V vecPA3, V vecPAOut0, V vecPAOut1)
 
template<>
void packAlternate< c7x::long_vec & > (c7x::long_vec &vecPAL0, c7x::long_vec &vecPAL1, c7x::long_vec &vecPAL2, c7x::long_vec &vecPAL3, c7x::long_vec &vecPALOut0, c7x::long_vec &vecPALOut1)
 
template<>
void packAlternate< c7x::int_vec & > (c7x::int_vec &vecPAI0, c7x::int_vec &vecPAI1, c7x::int_vec &vecPAI2, c7x::int_vec &vecPAI3, c7x::int_vec &vecPAIOut0, c7x::int_vec &vecPAIOut1)
 
template<typename V , typename W >
static void vecPermutePack (V vecPerm1, V vecPerm2, V vecPerm3, V vecPerm4, V vecPerm5, V vecPerm6, V vecPerm7, V vecPerm8, W pOutLocal, c7x::uchar_vec vMask)
 
template<>
void vecPermutePack< c7x::long_vec &, int16_t * > (c7x::long_vec &vecPermL1, c7x::long_vec &vecPermL2, c7x::long_vec &vecPermL3, c7x::long_vec &vecPermL4, c7x::long_vec &vecPermL5, c7x::long_vec &vecPermL6, c7x::long_vec &vecPermL7, c7x::long_vec &vecPermL8, int16_t *pOutLocal, c7x::uchar_vec vMaskPerm)
 
template<>
void vecPermutePack< c7x::int_vec &, int8_t * > (c7x::int_vec &vecPermI1, c7x::int_vec &vecPermI2, c7x::int_vec &vecPermI3, c7x::int_vec &vecPermI4, c7x::int_vec &vecPermI5, c7x::int_vec &vecPermI6, c7x::int_vec &vecPermI7, c7x::int_vec &vecPermI8, int8_t *pOutLocal, c7x::uchar_vec vMaskPerm)
 
template<typename dataTypeIn >
static void writeOutSA0 (dataTypeIn *pOut, c7x::short_vec v1, c7x::short_vec v2)
 
template<>
void writeOutSA0 (int16_t *pOut, c7x::short_vec v1, c7x::short_vec v2)
 
template<>
void writeOutSA0 (int8_t *pOut, c7x::short_vec v1, c7x::short_vec v2)
 
template<typename dataTypeIn , typename dataTypeOut >
DSPLIB_STATUS DSPLIB_matMul_fixed_exec_ci (DSPLIB_kernelHandle handle, void *restrict pIn0, void *restrict pIn1, void *restrict pOut)
 This function is the main execution function for the C7x implementation of the kernel. The function declaration conforms to the declaration of DSPLIB_matMul_fixed_exec. More...
 
template DSPLIB_STATUS DSPLIB_matMul_fixed_exec_ci< DSPLIB_MATMAPY_FXD_I16S_O16S > (DSPLIB_kernelHandle handle, void *restrict pIn0, void *restrict pIn1, void *restrict pOut)
 
template DSPLIB_STATUS DSPLIB_matMul_fixed_exec_ci< DSPLIB_MATMAPY_FXD_I8S_O8S > (DSPLIB_kernelHandle handle, void *restrict pIn0, void *restrict pIn1, void *restrict pOut)
 

Macro Definition Documentation

◆ SE_PARAM_BASE

#define SE_PARAM_BASE   (0x0000)

Definition at line 43 of file DSPLIB_matMul_fixed_ci.cpp.

◆ SE0_PARAM_OFFSET

#define SE0_PARAM_OFFSET   (SE_PARAM_BASE)

Definition at line 44 of file DSPLIB_matMul_fixed_ci.cpp.

◆ SE1_PARAM_OFFSET

#define SE1_PARAM_OFFSET   (SE0_PARAM_OFFSET + SE_PARAM_SIZE)

Definition at line 45 of file DSPLIB_matMul_fixed_ci.cpp.

◆ SA0_PARAM_OFFSET

#define SA0_PARAM_OFFSET   (SE1_PARAM_OFFSET + SE_PARAM_SIZE)

Definition at line 46 of file DSPLIB_matMul_fixed_ci.cpp.

◆ DSPLIB_MATMUL_FIXED_UNROLL

#define DSPLIB_MATMUL_FIXED_UNROLL   (32)

Definition at line 47 of file DSPLIB_matMul_fixed_ci.cpp.

Function Documentation

◆ DSPLIB_matMul_fixed_PromoteTranspose_init_ci()

template<typename dataTypeIn , typename dataTypeOut >
void DSPLIB_matMul_fixed_PromoteTranspose_init_ci ( __SE_TEMPLATE_v1 *  se0Params,
__SE_TEMPLATE_v1 *  se1Params 
)
inline

◆ DSPLIB_matMul_fixed_PromoteTranspose_init_ci< DSPLIB_MATMAPY_FXD_I16S_O16S >()

template<>
void DSPLIB_matMul_fixed_PromoteTranspose_init_ci< DSPLIB_MATMAPY_FXD_I16S_O16S > ( __SE_TEMPLATE_v1 *  se0Params,
__SE_TEMPLATE_v1 *  se1Params 
)
inline

Definition at line 55 of file DSPLIB_matMul_fixed_ci.cpp.

◆ DSPLIB_matMul_fixed_PromoteTranspose_init_ci< DSPLIB_MATMAPY_FXD_I8S_O8S >()

template<>
void DSPLIB_matMul_fixed_PromoteTranspose_init_ci< DSPLIB_MATMAPY_FXD_I8S_O8S > ( __SE_TEMPLATE_v1 *  se0Params,
__SE_TEMPLATE_v1 *  se1Params 
)
inline

Definition at line 66 of file DSPLIB_matMul_fixed_ci.cpp.

◆ DSPLIB_matMul_fixed_init_ci()

template<typename dataTypeIn , typename dataTypeOut >
DSPLIB_STATUS DSPLIB_matMul_fixed_init_ci ( DSPLIB_kernelHandle  handle,
const DSPLIB_bufParams2D_t bufParamsIn0,
const DSPLIB_bufParams2D_t bufParamsIn1,
const DSPLIB_bufParams2D_t bufParamsOut,
const DSPLIB_matMul_fixed_InitArgs pKerInitArgs 
)

This function is the initialization function for the C7x implementation of the kernel. The function declaration conforms to the declaration of DSPLIB_matMul_fixed_init.

This function determines the configuration for the streaming engine and MMA hardware resources based on the function call parameters, and the configuration is saved in bufPBlock array. In the kernel call sequence, DSPLIB_matMul_fixed_exec_ci would be called later independently by the application. When DSPLIB_matMul_fixed_exec_ci runs, it merely retrieves the configuration from the bufPBlock and uses it to set up the hardware resources. This arrangement is so that DSPLIB_matMul_fixed_exec_ci does not lose cycles to determine the hardware configuration.

Parameters
[in]handle: Active handle to the kernel
[in]bufParamsIn1: Pointer to the structure containing dimensional information of input buffer 1
[in]bufParamsIn2: Pointer to the structure containing dimensional information of input buffer 2
[out]bufParamsOut: Pointer to the structure containing dimensional information of ouput buffer
[in]pKerInitArgs: Pointer to the structure holding init parameters
Returns
Status value indicating success or failure. Refer to DSPLIB_STATUS.

Definition at line 77 of file DSPLIB_matMul_fixed_ci.cpp.

◆ DSPLIB_matMul_fixed_init_ci< DSPLIB_MATMAPY_FXD_I8S_O8S >()

template DSPLIB_STATUS DSPLIB_matMul_fixed_init_ci< DSPLIB_MATMAPY_FXD_I8S_O8S > ( DSPLIB_kernelHandle  handle,
const DSPLIB_bufParams2D_t bufParamsIn0,
const DSPLIB_bufParams2D_t bufParamsIn1,
const DSPLIB_bufParams2D_t bufParamsOut,
const DSPLIB_matMul_fixed_InitArgs pKerInitArgs 
)

◆ DSPLIB_matMul_fixed_init_ci< DSPLIB_MATMAPY_FXD_I16S_O16S >()

template DSPLIB_STATUS DSPLIB_matMul_fixed_init_ci< DSPLIB_MATMAPY_FXD_I16S_O16S > ( DSPLIB_kernelHandle  handle,
const DSPLIB_bufParams2D_t bufParamsIn0,
const DSPLIB_bufParams2D_t bufParamsIn1,
const DSPLIB_bufParams2D_t bufParamsOut,
const DSPLIB_matMul_fixed_InitArgs pKerInitArgs 
)

◆ setMask()

template<typename V >
static c7x::uchar_vec setMask ( )
inlinestatic

◆ setMask< int16_t >()

template<>
c7x::uchar_vec setMask< int16_t > ( )
inline

Definition at line 182 of file DSPLIB_matMul_fixed_ci.cpp.

◆ setMask< int8_t >()

template<>
c7x::uchar_vec setMask< int8_t > ( )
inline

Definition at line 191 of file DSPLIB_matMul_fixed_ci.cpp.

◆ vecMulAcc()

template<typename V , __SE_REG , __SE_REG >
static void vecMulAcc ( outSum0,
outSum1 
)
inlinestatic

◆ vecMulAcc< c7x::long_vec &, __SE_REG_0, __SE_REG_1_ADV >()

template<>
void vecMulAcc< c7x::long_vec &, __SE_REG_0, __SE_REG_1_ADV > ( c7x::long_vec &  outSum0,
c7x::long_vec &  outSum1 
)
inline

Definition at line 203 of file DSPLIB_matMul_fixed_ci.cpp.

◆ vecMulAcc< c7x::long_vec &, __SE_REG_0_ADV, __SE_REG_1_ADV >()

template<>
void vecMulAcc< c7x::long_vec &, __SE_REG_0_ADV, __SE_REG_1_ADV > ( c7x::long_vec &  outSum0,
c7x::long_vec &  outSum1 
)
inline

Definition at line 212 of file DSPLIB_matMul_fixed_ci.cpp.

◆ vecMulAcc< c7x::int_vec &, __SE_REG_0, __SE_REG_1_ADV >()

template<>
void vecMulAcc< c7x::int_vec &, __SE_REG_0, __SE_REG_1_ADV > ( c7x::int_vec &  outSum0,
c7x::int_vec &  outSum1 
)
inline

Definition at line 221 of file DSPLIB_matMul_fixed_ci.cpp.

◆ vecMulAcc< c7x::int_vec &, __SE_REG_0_ADV, __SE_REG_1_ADV >()

template<>
void vecMulAcc< c7x::int_vec &, __SE_REG_0_ADV, __SE_REG_1_ADV > ( c7x::int_vec &  outSum0,
c7x::int_vec &  outSum1 
)
inline

Definition at line 228 of file DSPLIB_matMul_fixed_ci.cpp.

◆ vecShiftRight()

template<typename V >
static void vecShiftRight ( vecSR0,
vecSR1,
shiftVec 
)
inlinestatic

◆ vecShiftRight< c7x::long_vec & >()

template<>
void vecShiftRight< c7x::long_vec & > ( c7x::long_vec &  vecSRL0,
c7x::long_vec &  vecSRL1,
c7x::long_vec &  shiftVec 
)
inline

Definition at line 237 of file DSPLIB_matMul_fixed_ci.cpp.

◆ vecShiftRight< c7x::int_vec & >()

template<>
void vecShiftRight< c7x::int_vec & > ( c7x::int_vec &  vecSRI0,
c7x::int_vec &  vecSRI1,
c7x::int_vec &  shiftVec 
)
inline

Definition at line 244 of file DSPLIB_matMul_fixed_ci.cpp.

◆ resetVec()

template<typename V >
static void resetVec ( vecRes0,
vecRes1 
)
inlinestatic

◆ resetVec< c7x::long_vec & >()

template<>
void resetVec< c7x::long_vec & > ( c7x::long_vec &  vecResL0,
c7x::long_vec &  vecResL1 
)
inline

Definition at line 251 of file DSPLIB_matMul_fixed_ci.cpp.

◆ resetVec< c7x::int_vec & >()

template<>
void resetVec< c7x::int_vec & > ( c7x::int_vec &  vecResI0,
c7x::int_vec &  vecResI1 
)
inline

Definition at line 257 of file DSPLIB_matMul_fixed_ci.cpp.

◆ packAlternate()

template<typename V >
static void packAlternate ( vecPA0,
vecPA1,
vecPA2,
vecPA3,
vecPAOut0,
vecPAOut1 
)
inlinestatic

◆ packAlternate< c7x::long_vec & >()

template<>
void packAlternate< c7x::long_vec & > ( c7x::long_vec &  vecPAL0,
c7x::long_vec &  vecPAL1,
c7x::long_vec &  vecPAL2,
c7x::long_vec &  vecPAL3,
c7x::long_vec &  vecPALOut0,
c7x::long_vec &  vecPALOut1 
)
inline

Definition at line 266 of file DSPLIB_matMul_fixed_ci.cpp.

◆ packAlternate< c7x::int_vec & >()

template<>
void packAlternate< c7x::int_vec & > ( c7x::int_vec &  vecPAI0,
c7x::int_vec &  vecPAI1,
c7x::int_vec &  vecPAI2,
c7x::int_vec &  vecPAI3,
c7x::int_vec &  vecPAIOut0,
c7x::int_vec &  vecPAIOut1 
)
inline

Definition at line 278 of file DSPLIB_matMul_fixed_ci.cpp.

◆ vecPermutePack()

template<typename V , typename W >
static void vecPermutePack ( vecPerm1,
vecPerm2,
vecPerm3,
vecPerm4,
vecPerm5,
vecPerm6,
vecPerm7,
vecPerm8,
pOutLocal,
c7x::uchar_vec  vMask 
)
inlinestatic

◆ vecPermutePack< c7x::long_vec &, int16_t * >()

template<>
void vecPermutePack< c7x::long_vec &, int16_t * > ( c7x::long_vec &  vecPermL1,
c7x::long_vec &  vecPermL2,
c7x::long_vec &  vecPermL3,
c7x::long_vec &  vecPermL4,
c7x::long_vec &  vecPermL5,
c7x::long_vec &  vecPermL6,
c7x::long_vec &  vecPermL7,
c7x::long_vec &  vecPermL8,
int16_t *  pOutLocal,
c7x::uchar_vec  vMaskPerm 
)
inline

Definition at line 301 of file DSPLIB_matMul_fixed_ci.cpp.

◆ vecPermutePack< c7x::int_vec &, int8_t * >()

template<>
void vecPermutePack< c7x::int_vec &, int8_t * > ( c7x::int_vec &  vecPermI1,
c7x::int_vec &  vecPermI2,
c7x::int_vec &  vecPermI3,
c7x::int_vec &  vecPermI4,
c7x::int_vec &  vecPermI5,
c7x::int_vec &  vecPermI6,
c7x::int_vec &  vecPermI7,
c7x::int_vec &  vecPermI8,
int8_t *  pOutLocal,
c7x::uchar_vec  vMaskPerm 
)
inline

Definition at line 342 of file DSPLIB_matMul_fixed_ci.cpp.

◆ writeOutSA0() [1/3]

template<typename dataTypeIn >
static void writeOutSA0 ( dataTypeIn *  pOut,
c7x::short_vec  v1,
c7x::short_vec  v2 
)
inlinestatic

◆ writeOutSA0() [2/3]

template<>
void writeOutSA0 ( int16_t *  pOut,
c7x::short_vec  v1,
c7x::short_vec  v2 
)
inline

Definition at line 372 of file DSPLIB_matMul_fixed_ci.cpp.

◆ writeOutSA0() [3/3]

template<>
void writeOutSA0 ( int8_t *  pOut,
c7x::short_vec  v1,
c7x::short_vec  v2 
)
inline

Definition at line 379 of file DSPLIB_matMul_fixed_ci.cpp.

◆ DSPLIB_matMul_fixed_exec_ci()

template<typename dataTypeIn , typename dataTypeOut >
DSPLIB_STATUS DSPLIB_matMul_fixed_exec_ci ( DSPLIB_kernelHandle  handle,
void *restrict  pIn1,
void *restrict  pIn2,
void *restrict  pOut 
)

This function is the main execution function for the C7x implementation of the kernel. The function declaration conforms to the declaration of DSPLIB_matMul_fixed_exec.

The function uses MMA hardware accelerator to perform the convolution computation. Filter data is loaded into B panel of the MMA from memory using one streaming engine, while the input data is loaded into A vectors of the MMA using the other streaming engine. Result of the compute from MMA C panel is stored into memory using a stream matMul_fixedress generator.

Parameters
[in]handle: Active handle to the kernel
[in]pIn: Pointer to buffer holding the input data
[out]pOut: Pointer to buffer holding the output data
Returns
Status value indicating success or failure. Refer to DSPLIB_STATUS.
Performance Considerations:
For best performance,
  • the input and output data buffers are expected to be in L2 memory
  • the buffer pointers are assumed to be 64-byte aligned

Definition at line 388 of file DSPLIB_matMul_fixed_ci.cpp.

◆ DSPLIB_matMul_fixed_exec_ci< DSPLIB_MATMAPY_FXD_I16S_O16S >()

template DSPLIB_STATUS DSPLIB_matMul_fixed_exec_ci< DSPLIB_MATMAPY_FXD_I16S_O16S > ( DSPLIB_kernelHandle  handle,
void *restrict  pIn0,
void *restrict  pIn1,
void *restrict  pOut 
)

◆ DSPLIB_matMul_fixed_exec_ci< DSPLIB_MATMAPY_FXD_I8S_O8S >()

template DSPLIB_STATUS DSPLIB_matMul_fixed_exec_ci< DSPLIB_MATMAPY_FXD_I8S_O8S > ( DSPLIB_kernelHandle  handle,
void *restrict  pIn0,
void *restrict  pIn1,
void *restrict  pOut 
)