Complex Matrix Matrix Multiplication Kernels
Module: Matrix Functions / Complex Matrix Matrix Multiplication
Functions
Name | |
---|---|
void | plp_mat_mult_cmplx_f32p_xpulpv2(void * args) parallel matrix matrix multiplication for complex 32-bit floats on XpulpV2 |
void | plp_mat_mult_cmplx_f32s_xpulpv2(const float restrict pSrcA, const float restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, float *restrict pDstC) Matrix matrix multiplication for complex 32-bit floats on XpulpV2. |
void | plp_mat_mult_cmplx_i16p_xpulpv2(void * args) parallel matrix matrix multiplication for complex 16-bit integers on XpulpV2 |
void | plp_mat_mult_cmplx_i16s_rv32im(const int16_t restrict pSrcA, const int16_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, int32_t *restrict pDstC) Matrix matrix multiplication for complex 16-bit integers on RV32IM. |
void | plp_mat_mult_cmplx_i16s_xpulpv2(const int16_t restrict pSrcA, const int16_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, int32_t *restrict pDstC) Matrix matrix multiplication for complex 16-bit integers on XpulpV2. |
void | plp_mat_mult_cmplx_i32p_xpulpv2(void * args) parallel matrix matrix multiplication for complex 32-bit integers on XpulpV2 |
void | plp_mat_mult_cmplx_i32s_rv32im(const int32_t restrict pSrcA, const int32_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, int32_t *restrict pDstC) Matrix matrix multiplication for complex 32-bit integers on RV32IM. |
void | plp_mat_mult_cmplx_i32s_xpulpv2(const int32_t restrict pSrcA, const int32_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, int32_t *restrict pDstC) Matrix matrix multiplication for complex 32-bit integers on XpulpV2. |
void | plp_mat_mult_cmplx_i8p_xpulpv2(void * args) parallel matrix matrix multiplication for complex 8-bit integers on XpulpV2 |
void | plp_mat_mult_cmplx_i8s_rv32im(const int8_t restrict pSrcA, const int8_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, int32_t *restrict pDstC) Matrix matrix multiplication for complex 8-bit integers on RV32IM. |
void | plp_mat_mult_cmplx_i8s_xpulpv2(const int8_t restrict pSrcA, const int8_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, int32_t *restrict pDstC) Matrix matrix multiplication for complex 8-bit integers on XpulpV2. |
void | plp_mat_mult_cmplx_q16p_xpulpv2(void * args) parallel matrix matrix multiplication for complex 16-bit fix-point on XpulpV2 |
void | plp_mat_mult_cmplx_q16s_rv32im(const int16_t restrict pSrcA, const int16_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t shift, int16_t *restrict pDstC) Matrix matrix multiplication for complex 16-bit fix-point on RV32IM. |
void | plp_mat_mult_cmplx_q16s_xpulpv2(const int16_t restrict pSrcA, const int16_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t shift, int16_t *restrict pDstC) Matrix matrix multiplication for complex 16-bit fix-point on XpulpV2. |
void | plp_mat_mult_cmplx_q32p_xpulpv2(void * args) parallel matrix matrix multiplication for complex 32-bit fix-point on XpulpV2 |
void | plp_mat_mult_cmplx_q32s_rv32im(const int32_t restrict pSrcA, const int32_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t shift, int32_t *restrict pDstC) Matrix matrix multiplication for complex 32-bit fix-point on RV32IM. |
void | plp_mat_mult_cmplx_q32s_xpulpv2(const int32_t restrict pSrcA, const int32_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t shift, int32_t *restrict pDstC) Matrix matrix multiplication for complex 32-bit fix-point on XpulpV2. |
void | plp_mat_mult_cmplx_q8p_xpulpv2(void * args) parallel matrix matrix multiplication for complex 8-bit fix-point on XpulpV2 |
void | plp_mat_mult_cmplx_q8s_rv32im(const int8_t restrict pSrcA, const int8_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t shift, int8_t *restrict pDstC) Matrix matrix multiplication for complex 8-bit fix-point on RV32IM. |
void | plp_mat_mult_cmplx_q8s_xpulpv2(const int8_t restrict pSrcA, const int8_t restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, uint32_t shift, int8_t *restrict pDstC) Matrix matrix multiplication for complex 8-bit fix-point on XpulpV2. |
Detailed Description
This module contains the kernels for complex matrix matrix multiplication.
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_i32s_xpulpv2
):
plp_<function name>_<data type><precision><method>_<isa_extension>
name | description |
---|---|
function_name | mat_mult_cmplx |
data type | {f , i , q } respectively for floats, integers, fixed points |
precision | {32 , 16 , 8 } bits |
method | {s , v , p } meaning scalar, vectorized (i.e. SIMD) and parallel, respectively |
isa_extension | {rv32im , xpulpv2 } respectively for ibex and riscy |
Functions Documentation
function plp_mat_mult_cmplx_f32p_xpulpv2
void plp_mat_mult_cmplx_f32p_xpulpv2(
void * args
)
parallel matrix matrix multiplication for complex 32-bit floats on XpulpV2
Parameters:
- args pointer to plp_mat_mat_mult_cmplx_instance_f32 struct initialized by plp_mat_mult_cmplx_f32_parallel
Return: none
function plp_mat_mult_cmplx_f32s_xpulpv2
void plp_mat_mult_cmplx_f32s_xpulpv2(
const float *__restrict__ pSrcA,
const float *__restrict__ pSrcB,
uint32_t M,
uint32_t N,
uint32_t O,
float *__restrict__ pDstC
)
Matrix matrix multiplication for complex 32-bit floats on XpulpV2.
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
- pDstC Points to the output matrix of shape MxO
Return: none
function plp_mat_mult_cmplx_i16p_xpulpv2
void plp_mat_mult_cmplx_i16p_xpulpv2(
void * args
)
parallel matrix matrix multiplication for complex 16-bit integers on XpulpV2
Parameters:
- args pointer to plp_mat_mat_mult_cmplx_instance_i16 struct initialized by plp_mat_mult_cmplx_i16_parallel
Return: none
Par: Exploiting SIMD instructions
The 16 bit values are packed two each into 32 bit vectors and then the two dot products are performed on 32 bit vectors, with 32 bit accumulator.
function plp_mat_mult_cmplx_i16s_rv32im
void plp_mat_mult_cmplx_i16s_rv32im(
const int16_t *__restrict__ pSrcA,
const int16_t *__restrict__ pSrcB,
uint32_t M,
uint32_t N,
uint32_t O,
int32_t *__restrict__ pDstC
)
Matrix matrix multiplication for complex 16-bit integers on RV32IM.
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
- pDstC Points to the output matrix of shape MxO
Return: none
function plp_mat_mult_cmplx_i16s_xpulpv2
void plp_mat_mult_cmplx_i16s_xpulpv2(
const int16_t *__restrict__ pSrcA,
const int16_t *__restrict__ pSrcB,
uint32_t M,
uint32_t N,
uint32_t O,
int32_t *__restrict__ pDstC
)
Matrix matrix multiplication for complex 16-bit integers on XpulpV2.
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
- pDstC Points to the output matrix of shape MxO
Return: none
function plp_mat_mult_cmplx_i32p_xpulpv2
void plp_mat_mult_cmplx_i32p_xpulpv2(
void * args
)
parallel matrix matrix multiplication for complex 32-bit integers on XpulpV2
Parameters:
- args pointer to plp_mat_mat_mult_cmplx_instance_i32 struct initialized by plp_mat_mult_cmplx_i32_parallel
Return: none
function plp_mat_mult_cmplx_i32s_rv32im
void plp_mat_mult_cmplx_i32s_rv32im(
const int32_t *__restrict__ pSrcA,
const int32_t *__restrict__ pSrcB,
uint32_t M,
uint32_t N,
uint32_t O,
int32_t *__restrict__ pDstC
)
Matrix matrix multiplication for complex 32-bit integers on RV32IM.
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
- pDstC Points to the output matrix of shape MxO
Return: none
function plp_mat_mult_cmplx_i32s_xpulpv2
void plp_mat_mult_cmplx_i32s_xpulpv2(
const int32_t *__restrict__ pSrcA,
const int32_t *__restrict__ pSrcB,
uint32_t M,
uint32_t N,
uint32_t O,
int32_t *__restrict__ pDstC
)
Matrix matrix multiplication for complex 32-bit integers on XpulpV2.
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
- pDstC Points to the output matrix of shape MxO
Return: none
function plp_mat_mult_cmplx_i8p_xpulpv2
void plp_mat_mult_cmplx_i8p_xpulpv2(
void * args
)
parallel matrix matrix multiplication for complex 8-bit integers on XpulpV2
Parameters:
- args pointer to plp_mat_mat_mult_cmplx_instance_i8 struct initialized by plp_mat_mult_cmplx_i8_parallel
Return: none
Par: Exploiting SIMD instructions
The 8 bit values are packed four each into 32 bit vectors and then the four dot products are performed on 32 bit vectors, with 32 bit accumulator.
function plp_mat_mult_cmplx_i8s_rv32im
void plp_mat_mult_cmplx_i8s_rv32im(
const int8_t *__restrict__ pSrcA,
const int8_t *__restrict__ pSrcB,
uint32_t M,
uint32_t N,
uint32_t O,
int32_t *__restrict__ pDstC
)
Matrix matrix multiplication for complex 8-bit integers on RV32IM.
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
- pDstC Points to the output matrix of shape MxO
Return: none
function plp_mat_mult_cmplx_i8s_xpulpv2
void plp_mat_mult_cmplx_i8s_xpulpv2(
const int8_t *__restrict__ pSrcA,
const int8_t *__restrict__ pSrcB,
uint32_t M,
uint32_t N,
uint32_t O,
int32_t *__restrict__ pDstC
)
Matrix matrix multiplication for complex 8-bit integers on XpulpV2.
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
- pDstC Points to the output matrix of shape MxO
Return: none
function plp_mat_mult_cmplx_q16p_xpulpv2
void plp_mat_mult_cmplx_q16p_xpulpv2(
void * args
)
parallel matrix matrix multiplication for complex 16-bit fix-point on XpulpV2
Parameters:
- args pointer to plp_mat_mat_mult_cmplx_instance_q16 struct initialized by plp_mat_mult_cmplx_q16_parallel
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.
* Exploiting SIMD instructions
The 16 bit values are packed two each into 32 bit vectors and then the two dot products are performed on 32 bit vectors, with 32 bit accumulator.
function plp_mat_mult_cmplx_q16s_rv32im
void plp_mat_mult_cmplx_q16s_rv32im(
const int16_t *__restrict__ pSrcA,
const int16_t *__restrict__ pSrcB,
uint32_t M,
uint32_t N,
uint32_t O,
uint32_t shift,
int16_t *__restrict__ pDstC
)
Matrix matrix multiplication for complex 16-bit fix-point on RV32IM.
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
- 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_q16s_xpulpv2
void plp_mat_mult_cmplx_q16s_xpulpv2(
const int16_t *__restrict__ pSrcA,
const int16_t *__restrict__ pSrcB,
uint32_t M,
uint32_t N,
uint32_t O,
uint32_t shift,
int16_t *__restrict__ pDstC
)
Matrix matrix multiplication for complex 16-bit fix-point on XpulpV2.
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
- 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_q32p_xpulpv2
void plp_mat_mult_cmplx_q32p_xpulpv2(
void * args
)
parallel matrix matrix multiplication for complex 32-bit fix-point on XpulpV2
Parameters:
- args pointer to plp_mat_mat_mult_cmplx_instance_q32 struct initialized by plp_mat_mult_cmplx_q32_parallel
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_q32s_rv32im
void plp_mat_mult_cmplx_q32s_rv32im(
const int32_t *__restrict__ pSrcA,
const int32_t *__restrict__ pSrcB,
uint32_t M,
uint32_t N,
uint32_t O,
uint32_t shift,
int32_t *__restrict__ pDstC
)
Matrix matrix multiplication for complex 32-bit fix-point on RV32IM.
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
- 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_q32s_xpulpv2
void plp_mat_mult_cmplx_q32s_xpulpv2(
const int32_t *__restrict__ pSrcA,
const int32_t *__restrict__ pSrcB,
uint32_t M,
uint32_t N,
uint32_t O,
uint32_t shift,
int32_t *__restrict__ pDstC
)
Matrix matrix multiplication for complex 32-bit fix-point on XpulpV2.
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
- 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_q8p_xpulpv2
void plp_mat_mult_cmplx_q8p_xpulpv2(
void * args
)
parallel matrix matrix multiplication for complex 8-bit fix-point on XpulpV2
Parameters:
- args pointer to plp_mat_mat_mult_cmplx_instance_q8 struct initialized by plp_mat_mult_cmplx_q8_parallel
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.
* Exploiting SIMD instructions
The 8 bit values are packed four each into 32 bit vectors and then the four dot products are performed on 32 bit vectors, with 32 bit accumulator.
function plp_mat_mult_cmplx_q8s_rv32im
void plp_mat_mult_cmplx_q8s_rv32im(
const int8_t *__restrict__ pSrcA,
const int8_t *__restrict__ pSrcB,
uint32_t M,
uint32_t N,
uint32_t O,
uint32_t shift,
int8_t *__restrict__ pDstC
)
Matrix matrix multiplication for complex 8-bit fix-point on RV32IM.
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
- 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_q8s_xpulpv2
void plp_mat_mult_cmplx_q8s_xpulpv2(
const int8_t *__restrict__ pSrcA,
const int8_t *__restrict__ pSrcB,
uint32_t M,
uint32_t N,
uint32_t O,
uint32_t shift,
int8_t *__restrict__ pDstC
)
Matrix matrix multiplication for complex 8-bit fix-point on XpulpV2.
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
- 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.
Updated on 2023-03-01 at 16:16:32 +0000