Skip to content

Complex Matrix Matrix Multiplication

Module: Strided Matrix operations

More...

Modules

Name
Complex Matrix Matrix Multiplication Kernels

Functions

Name
void plp_mat_mult_cmplx_stride_f32(const float restrict pSrcA, const float restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t strideA, uint32_t strideB, uint32_t strideC, float *restrict pDstC)
Glue code of strided matrix matrix multiplication for complex 32-bit floats.
void plp_mat_mult_cmplx_stride_f32_parallel(const float restrict pSrcA, const float restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t strideA, uint32_t strideB, uint32_t strideC, uint32_t nPE, float *restrict pDstC)
Glue code of parallel strided matrix matrix multiplication for complex 32-bit floats.
void plp_mat_mult_cmplx_stride_i16(const int16_t restrict pSrcA, const int16_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t strideA, uint32_t strideB, uint32_t strideC, int32_t *restrict pDstC)
Glue code of strided matrix matrix multiplication for complex 16-bit integers.
void plp_mat_mult_cmplx_stride_i16_parallel(const int16_t restrict pSrcA, const int16_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t strideA, uint32_t strideB, uint32_t strideC, uint32_t nPE, int32_t *restrict pDstC)
Glue code of parallel strided matrix matrix multiplication for complex 16-bit integers.
void plp_mat_mult_cmplx_stride_i32(const int32_t restrict pSrcA, const int32_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t strideA, uint32_t strideB, uint32_t strideC, int32_t *restrict pDstC)
Glue code of strided matrix matrix multiplication for complex 32-bit integers.
void plp_mat_mult_cmplx_stride_i32_parallel(const int32_t restrict pSrcA, const int32_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t strideA, uint32_t strideB, uint32_t strideC, uint32_t nPE, int32_t *restrict pDstC)
Glue code of parallel strided matrix matrix multiplication for complex 32-bit integers.
void plp_mat_mult_cmplx_stride_i8(const int8_t restrict pSrcA, const int8_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t strideA, uint32_t strideB, uint32_t strideC, int32_t *restrict pDstC)
Glue code of strided matrix matrix multiplication for complex 8-bit integers.
void plp_mat_mult_cmplx_stride_i8_parallel(const int8_t restrict pSrcA, const int8_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t strideA, uint32_t strideB, uint32_t strideC, uint32_t nPE, int32_t *restrict pDstC)
Glue code of parallel strided matrix matrix multiplication for complex 8-bit integers.
void plp_mat_mult_cmplx_stride_q16(const int16_t restrict pSrcA, const int16_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t strideA, uint32_t strideB, uint32_t strideC, uint32_t shift, int16_t *restrict pDstC)
Glue code of strided matrix matrix multiplication for complex 16-bit fix-point.
void plp_mat_mult_cmplx_stride_q16_parallel(const int16_t restrict pSrcA, const int16_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t strideA, uint32_t strideB, uint32_t strideC, uint32_t shift, uint32_t nPE, int16_t *restrict pDstC)
Glue code of parallel strided matrix matrix multiplication for complex 16-bit fix-point.
void plp_mat_mult_cmplx_stride_q32(const int32_t restrict pSrcA, const int32_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t strideA, uint32_t strideB, uint32_t strideC, uint32_t shift, int32_t *restrict pDstC)
Glue code of strided matrix matrix multiplication for complex 32-bit fix-point.
void plp_mat_mult_cmplx_stride_q32_parallel(const int32_t restrict pSrcA, const int32_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t strideA, uint32_t strideB, uint32_t strideC, uint32_t shift, uint32_t nPE, int32_t *restrict pDstC)
Glue code of parallel strided matrix matrix multiplication for complex 32-bit fix-point.
void plp_mat_mult_cmplx_stride_q8(const int8_t restrict pSrcA, const int8_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t strideA, uint32_t strideB, uint32_t strideC, uint32_t shift, int8_t *restrict pDstC)
Glue code of strided matrix matrix multiplication for complex 8-bit fix-point.
void plp_mat_mult_cmplx_stride_q8_parallel(const int8_t restrict pSrcA, const int8_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t strideA, uint32_t strideB, uint32_t strideC, uint32_t shift, uint32_t nPE, int8_t *restrict pDstC)
Glue code of parallel strided matrix matrix multiplication for complex 8-bit fix-point.

Detailed Description

This module contains the glue code for complex strided matrix matrix multiplication. The kernel codes (kernels) are in the Module Complex Matrix Matrix Multiplication Kernels.

The Matrix Matrix Multiplication computes the product of two matrices with dimensions MxN and NxO. The first matrix is accessed row wise, the second column wise, all values form the first are multiplied with the values of the second and then sum of the result gives the value for the result matrix.

pDst[m,o] = pSrcA[m,0]*pSrcB[0,o] + pSrcA[m,1]*pSrcB[1,o] + ... + pSrcA[m,N-1]*pSrcB[N-1,o]

These functions assume both source matrices (pSrcA and pSrcB) and the output matrix (pDstC) to be complex. They must be stored such that real and imaginary part of any element directly are directly next to eachother. The dimensionality (M, N, O) still counts the number of elements in each dimension, such that a complex matrix X with shape MxN has size M * N * 2. To access the real and imatinary part of this matrix X, do:

Re(X[m, n]): pX[(m * N + n) * 2]
Im(X[m, n]): pX[(m * N + n) * 2 + 1]

There are functions for integer 32- 16- and 8-bit data types. For lower precision integers (16- and 8-bit), functions exploiting SIMD instructions are provided.

The naming scheme of the functions follows the following pattern (for example plp_mat_mult_cmplx_stride_i32):

plp_<function name>_<data type><precision>[_parallel]
name description
function_name mat_mult_cmplx
data type {f, i, q} respectively for floats, integers, fixed points
precision {32, 16, 8} bits

Functions Documentation

function plp_mat_mult_cmplx_stride_f32

void plp_mat_mult_cmplx_stride_f32(
    const float *__restrict__ pSrcA,
    const float *__restrict__ pSrcB,
    uint32_t M,
    uint32_t N,
    uint32_t O,
    uint32_t strideA,
    uint32_t strideB,
    uint32_t strideC,
    float *__restrict__ pDstC
)

Glue code of strided matrix matrix multiplication for complex 32-bit floats.

Parameters:

  • pSrcA Points to the first input matrix of shape MxN
  • pSrcB Points to the second input matrix of shape NxO
  • M Height of matrix SrcA and DstC
  • N Width of matrix SrcA and height of matrix SrcB
  • O Width of matrix SrcB and DstC
  • strideA Stride of input matrix A (elements between each row)
  • strideB Stride of input matrix B (elements between each row)
  • strideC Stride of output matrix C (Elements between each row)
  • pDstC Points to the output matrix of shape MxO

Return: none

function plp_mat_mult_cmplx_stride_f32_parallel

void plp_mat_mult_cmplx_stride_f32_parallel(
    const float *__restrict__ pSrcA,
    const float *__restrict__ pSrcB,
    uint32_t M,
    uint32_t N,
    uint32_t O,
    uint32_t strideA,
    uint32_t strideB,
    uint32_t strideC,
    uint32_t nPE,
    float *__restrict__ pDstC
)

Glue code of parallel strided matrix matrix multiplication for complex 32-bit floats.

Parameters:

  • pSrcA Points to the first input matrix of shape MxN
  • pSrcB Points to the second input matrix of shape NxO
  • M Height of matrix SrcA and DstC
  • N Width of matrix SrcA and height of matrix SrcB
  • O Width of matrix SrcB and DstC
  • strideA Stride of input matrix A (elements between each row)
  • strideB Stride of input matrix B (elements between each row)
  • strideC Stride of output matrix C (Elements between each row)
  • nPE Number of cores to use for computation
  • pDstC Points to the output matrix of shape MxO

Return: none

function plp_mat_mult_cmplx_stride_i16

void plp_mat_mult_cmplx_stride_i16(
    const int16_t *__restrict__ pSrcA,
    const int16_t *__restrict__ pSrcB,
    uint32_t M,
    uint32_t N,
    uint32_t O,
    uint32_t strideA,
    uint32_t strideB,
    uint32_t strideC,
    int32_t *__restrict__ pDstC
)

Glue code of strided matrix matrix multiplication for complex 16-bit integers.

Parameters:

  • pSrcA Points to the first input matrix of shape MxN
  • pSrcB Points to the second input matrix of shape NxO
  • M Height of matrix SrcA and DstC
  • N Width of matrix SrcA and height of matrix SrcB
  • O Width of matrix SrcB and DstC
  • strideA Stride of input matrix A (elements between each row)
  • strideB Stride of input matrix B (elements between each row)
  • strideC Stride of output matrix C (Elements between each row)
  • pDstC Points to the output matrix of shape MxO

Return: none

function plp_mat_mult_cmplx_stride_i16_parallel

void plp_mat_mult_cmplx_stride_i16_parallel(
    const int16_t *__restrict__ pSrcA,
    const int16_t *__restrict__ pSrcB,
    uint32_t M,
    uint32_t N,
    uint32_t O,
    uint32_t strideA,
    uint32_t strideB,
    uint32_t strideC,
    uint32_t nPE,
    int32_t *__restrict__ pDstC
)

Glue code of parallel strided matrix matrix multiplication for complex 16-bit integers.

Parameters:

  • pSrcA Points to the first input matrix of shape MxN
  • pSrcB Points to the second input matrix of shape NxO
  • M Height of matrix SrcA and DstC
  • N Width of matrix SrcA and height of matrix SrcB
  • O Width of matrix SrcB and DstC
  • strideA Stride of input matrix A (elements between each row)
  • strideB Stride of input matrix B (elements between each row)
  • strideC Stride of output matrix C (Elements between each row)
  • nPE Number of cores to use for computation
  • pDstC Points to the output matrix of shape MxO

Return: none

function plp_mat_mult_cmplx_stride_i32

void plp_mat_mult_cmplx_stride_i32(
    const int32_t *__restrict__ pSrcA,
    const int32_t *__restrict__ pSrcB,
    uint32_t M,
    uint32_t N,
    uint32_t O,
    uint32_t strideA,
    uint32_t strideB,
    uint32_t strideC,
    int32_t *__restrict__ pDstC
)

Glue code of strided matrix matrix multiplication for complex 32-bit integers.

Parameters:

  • pSrcA Points to the first input matrix of shape MxN
  • pSrcB Points to the second input matrix of shape NxO
  • M Height of matrix SrcA and DstC
  • N Width of matrix SrcA and height of matrix SrcB
  • O Width of matrix SrcB and DstC
  • strideA Stride of input matrix A (elements between each row)
  • strideB Stride of input matrix B (elements between each row)
  • strideC Stride of output matrix C (Elements between each row)
  • pDstC Points to the output matrix of shape MxO

Return: none

function plp_mat_mult_cmplx_stride_i32_parallel

void plp_mat_mult_cmplx_stride_i32_parallel(
    const int32_t *__restrict__ pSrcA,
    const int32_t *__restrict__ pSrcB,
    uint32_t M,
    uint32_t N,
    uint32_t O,
    uint32_t strideA,
    uint32_t strideB,
    uint32_t strideC,
    uint32_t nPE,
    int32_t *__restrict__ pDstC
)

Glue code of parallel strided matrix matrix multiplication for complex 32-bit integers.

Parameters:

  • pSrcA Points to the first input matrix of shape MxN
  • pSrcB Points to the second input matrix of shape NxO
  • M Height of matrix SrcA and DstC
  • N Width of matrix SrcA and height of matrix SrcB
  • O Width of matrix SrcB and DstC
  • strideA Stride of input matrix A (elements between each row)
  • strideB Stride of input matrix B (elements between each row)
  • strideC Stride of output matrix C (Elements between each row)
  • nPE Number of cores to use for computation
  • pDstC Points to the output matrix of shape MxO

Return: none

function plp_mat_mult_cmplx_stride_i8

void plp_mat_mult_cmplx_stride_i8(
    const int8_t *__restrict__ pSrcA,
    const int8_t *__restrict__ pSrcB,
    uint32_t M,
    uint32_t N,
    uint32_t O,
    uint32_t strideA,
    uint32_t strideB,
    uint32_t strideC,
    int32_t *__restrict__ pDstC
)

Glue code of strided matrix matrix multiplication for complex 8-bit integers.

Parameters:

  • pSrcA Points to the first input matrix of shape MxN
  • pSrcB Points to the second input matrix of shape NxO
  • M Height of matrix SrcA and DstC
  • N Width of matrix SrcA and height of matrix SrcB
  • O Width of matrix SrcB and DstC
  • strideA Stride of input matrix A (elements between each row)
  • strideB Stride of input matrix B (elements between each row)
  • strideC Stride of output matrix C (Elements between each row)
  • pDstC Points to the output matrix of shape MxO

Return: none

function plp_mat_mult_cmplx_stride_i8_parallel

void plp_mat_mult_cmplx_stride_i8_parallel(
    const int8_t *__restrict__ pSrcA,
    const int8_t *__restrict__ pSrcB,
    uint32_t M,
    uint32_t N,
    uint32_t O,
    uint32_t strideA,
    uint32_t strideB,
    uint32_t strideC,
    uint32_t nPE,
    int32_t *__restrict__ pDstC
)

Glue code of parallel strided matrix matrix multiplication for complex 8-bit integers.

Parameters:

  • pSrcA Points to the first input matrix of shape MxN
  • pSrcB Points to the second input matrix of shape NxO
  • M Height of matrix SrcA and DstC
  • N Width of matrix SrcA and height of matrix SrcB
  • O Width of matrix SrcB and DstC
  • strideA Stride of input matrix A (elements between each row)
  • strideB Stride of input matrix B (elements between each row)
  • strideC Stride of output matrix C (Elements between each row)
  • nPE Number of cores to use for computation
  • pDstC Points to the output matrix of shape MxO

Return: none

function plp_mat_mult_cmplx_stride_q16

void plp_mat_mult_cmplx_stride_q16(
    const int16_t *__restrict__ pSrcA,
    const int16_t *__restrict__ pSrcB,
    uint32_t M,
    uint32_t N,
    uint32_t O,
    uint32_t strideA,
    uint32_t strideB,
    uint32_t strideC,
    uint32_t shift,
    int16_t *__restrict__ pDstC
)

Glue code of strided matrix matrix multiplication for complex 16-bit fix-point.

Parameters:

  • pSrcA Points to the first input matrix of shape MxN
  • pSrcB Points to the second input matrix of shape NxO
  • M Height of matrix SrcA and DstC
  • N Width of matrix SrcA and height of matrix SrcB
  • O Width of matrix SrcB and DstC
  • strideA Stride of input matrix A (elements between each row)
  • strideB Stride of input matrix B (elements between each row)
  • strideC Stride of output matrix C (Elements between each row)
  • shift Amount to shift the result of each multiplication ot the right
  • pDstC Points to the output matrix of shape MxO

Return: none

Par: Fix-Point

Fix-Point and Shifting The result will be shifted by the parameter shift to the right (which corresponds to a multiplication by 2^-shift). Assume that matrix A is represente as pSrcA * 2^-x and matrix B as pSrcB * 2^-y (which means that A has x, and B has y bits after the binary point). Then, the output matrix C is represented as pDstC * 2^-(x + y - shift). The output matrix is also stored with the same number of bits as the inputs. Set the shift parameter such that no overflow occurrs.

function plp_mat_mult_cmplx_stride_q16_parallel

void plp_mat_mult_cmplx_stride_q16_parallel(
    const int16_t *__restrict__ pSrcA,
    const int16_t *__restrict__ pSrcB,
    uint32_t M,
    uint32_t N,
    uint32_t O,
    uint32_t strideA,
    uint32_t strideB,
    uint32_t strideC,
    uint32_t shift,
    uint32_t nPE,
    int16_t *__restrict__ pDstC
)

Glue code of parallel strided matrix matrix multiplication for complex 16-bit fix-point.

Parameters:

  • pSrcA Points to the first input matrix of shape MxN
  • pSrcB Points to the second input matrix of shape NxO
  • M Height of matrix SrcA and DstC
  • N Width of matrix SrcA and height of matrix SrcB
  • O Width of matrix SrcB and DstC
  • strideA Stride of input matrix A (elements between each row)
  • strideB Stride of input matrix B (elements between each row)
  • strideC Stride of output matrix C (Elements between each row)
  • shift Amount to shift the result of each multiplication ot the right
  • nPE Number of cores to use for computation
  • pDstC Points to the output matrix of shape MxO

Return: none

Par: Fix-Point

Fix-Point and Shifting The result will be shifted by the parameter shift to the right (which corresponds to a multiplication by 2^-shift). Assume that matrix A is represente as pSrcA * 2^-x and matrix B as pSrcB * 2^-y (which means that A has x, and B has y bits after the binary point). Then, the output matrix C is represented as pDstC * 2^-(x + y - shift). The output matrix is also stored with the same number of bits as the inputs. Set the shift parameter such that no overflow occurrs.

function plp_mat_mult_cmplx_stride_q32

void plp_mat_mult_cmplx_stride_q32(
    const int32_t *__restrict__ pSrcA,
    const int32_t *__restrict__ pSrcB,
    uint32_t M,
    uint32_t N,
    uint32_t O,
    uint32_t strideA,
    uint32_t strideB,
    uint32_t strideC,
    uint32_t shift,
    int32_t *__restrict__ pDstC
)

Glue code of strided matrix matrix multiplication for complex 32-bit fix-point.

Parameters:

  • pSrcA Points to the first input matrix of shape MxN
  • pSrcB Points to the second input matrix of shape NxO
  • M Height of matrix SrcA and DstC
  • N Width of matrix SrcA and height of matrix SrcB
  • O Width of matrix SrcB and DstC
  • strideA Stride of input matrix A (elements between each row)
  • strideB Stride of input matrix B (elements between each row)
  • strideC Stride of output matrix C (Elements between each row)
  • shift Amount to shift the result of each multiplication ot the right
  • pDstC Points to the output matrix of shape MxO

Return: none

Par: Fix-Point

Fix-Point and Shifting The result will be shifted by the parameter shift to the right (which corresponds to a multiplication by 2^-shift). Assume that matrix A is represente as pSrcA * 2^-x and matrix B as pSrcB * 2^-y (which means that A has x, and B has y bits after the binary point). Then, the output matrix C is represented as pDstC * 2^-(x + y - shift). The output matrix is also stored with the same number of bits as the inputs. Set the shift parameter such that no overflow occurrs.

function plp_mat_mult_cmplx_stride_q32_parallel

void plp_mat_mult_cmplx_stride_q32_parallel(
    const int32_t *__restrict__ pSrcA,
    const int32_t *__restrict__ pSrcB,
    uint32_t M,
    uint32_t N,
    uint32_t O,
    uint32_t strideA,
    uint32_t strideB,
    uint32_t strideC,
    uint32_t shift,
    uint32_t nPE,
    int32_t *__restrict__ pDstC
)

Glue code of parallel strided matrix matrix multiplication for complex 32-bit fix-point.

Parameters:

  • pSrcA Points to the first input matrix of shape MxN
  • pSrcB Points to the second input matrix of shape NxO
  • M Height of matrix SrcA and DstC
  • N Width of matrix SrcA and height of matrix SrcB
  • O Width of matrix SrcB and DstC
  • strideA Stride of input matrix A (elements between each row)
  • strideB Stride of input matrix B (elements between each row)
  • strideC Stride of output matrix C (Elements between each row)
  • shift Amount to shift the result of each multiplication ot the right
  • nPE Number of cores to use for computation
  • pDstC Points to the output matrix of shape MxO

Return: none

Par: Fix-Point

Fix-Point and Shifting The result will be shifted by the parameter shift to the right (which corresponds to a multiplication by 2^-shift). Assume that matrix A is represente as pSrcA * 2^-x and matrix B as pSrcB * 2^-y (which means that A has x, and B has y bits after the binary point). Then, the output matrix C is represented as pDstC * 2^-(x + y - shift). The output matrix is also stored with the same number of bits as the inputs. Set the shift parameter such that no overflow occurrs.

function plp_mat_mult_cmplx_stride_q8

void plp_mat_mult_cmplx_stride_q8(
    const int8_t *__restrict__ pSrcA,
    const int8_t *__restrict__ pSrcB,
    uint32_t M,
    uint32_t N,
    uint32_t O,
    uint32_t strideA,
    uint32_t strideB,
    uint32_t strideC,
    uint32_t shift,
    int8_t *__restrict__ pDstC
)

Glue code of strided matrix matrix multiplication for complex 8-bit fix-point.

Parameters:

  • pSrcA Points to the first input matrix of shape MxN
  • pSrcB Points to the second input matrix of shape NxO
  • M Height of matrix SrcA and DstC
  • N Width of matrix SrcA and height of matrix SrcB
  • O Width of matrix SrcB and DstC
  • strideA Stride of input matrix A (elements between each row)
  • strideB Stride of input matrix B (elements between each row)
  • strideC Stride of output matrix C (Elements between each row)
  • shift Amount to shift the result of each multiplication ot the right
  • pDstC Points to the output matrix of shape MxO

Return: none

Par: Fix-Point

Fix-Point and Shifting The result will be shifted by the parameter shift to the right (which corresponds to a multiplication by 2^-shift). Assume that matrix A is represente as pSrcA * 2^-x and matrix B as pSrcB * 2^-y (which means that A has x, and B has y bits after the binary point). Then, the output matrix C is represented as pDstC * 2^-(x + y - shift). The output matrix is also stored with the same number of bits as the inputs. Set the shift parameter such that no overflow occurrs.

function plp_mat_mult_cmplx_stride_q8_parallel

void plp_mat_mult_cmplx_stride_q8_parallel(
    const int8_t *__restrict__ pSrcA,
    const int8_t *__restrict__ pSrcB,
    uint32_t M,
    uint32_t N,
    uint32_t O,
    uint32_t strideA,
    uint32_t strideB,
    uint32_t strideC,
    uint32_t shift,
    uint32_t nPE,
    int8_t *__restrict__ pDstC
)

Glue code of parallel strided matrix matrix multiplication for complex 8-bit fix-point.

Parameters:

  • pSrcA Points to the first input matrix of shape MxN
  • pSrcB Points to the second input matrix of shape NxO
  • M Height of matrix SrcA and DstC
  • N Width of matrix SrcA and height of matrix SrcB
  • O Width of matrix SrcB and DstC
  • strideA Stride of input matrix A (elements between each row)
  • strideB Stride of input matrix B (elements between each row)
  • strideC Stride of output matrix C (Elements between each row)
  • shift Amount to shift the result of each multiplication ot the right
  • nPE Number of cores to use for computation
  • pDstC Points to the output matrix of shape MxO

Return: none

Par: Fix-Point

Fix-Point and Shifting The result will be shifted by the parameter shift to the right (which corresponds to a multiplication by 2^-shift). Assume that matrix A is represente as pSrcA * 2^-x and matrix B as pSrcB * 2^-y (which means that A has x, and B has y bits after the binary point). Then, the output matrix C is represented as pDstC * 2^-(x + y - shift). The output matrix is also stored with the same number of bits as the inputs. Set the shift parameter such that no overflow occurrs.


Updated on 2023-03-01 at 16:16:32 +0000