Skip to content

Matrix Multiplication Kernels

Module: Matrix Functions / Matrix Transposed Matrix Multiplication

More...

Functions

Name
void plp_mat_mult_trans_f32p_xpulpv2(void * args)
Parallel matrix multiplication of 32-bit floating-point matrices kernel for XPULPV2 extension.
void plp_mat_mult_trans_f32s_xpulpv2(const float restrict pSrcA, const float restrict pSrcB, uint32_t M, uint32_t N, uint32_t O, float *restrict pDstC)
Matrix multiplication of 32-bit floating-point matrices kernel for XPULPV2 extension.
void plp_mat_mult_trans_i16p_xpulpv2(void * args)
Parallel matrix transposed matrix multiplication of a 16-bit integer matrices for XPULPV2 extension.
void plp_mat_mult_trans_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 multiplication of 16-bit integer matrices kernel for RV32IM extension.
void plp_mat_mult_trans_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 multiplication of 16-bit integer matrices kernel for XPULPV2 extension.
void plp_mat_mult_trans_i32p_xpulpv2(void * args)
Parallel matrix transposed matrix multiplication of a 32-bit integer matrices for RV32IM extension.
void plp_mat_mult_trans_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 multiplication of 32-bit integer matrices kernel for RV32IM extension.
void plp_mat_mult_trans_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 multiplication of 32-bit integer matrices kernel for XPULPV2 extension.
void plp_mat_mult_trans_i8p_xpulpv2(void * args)
Parallel matrix transposed matrix multiplication of a 8-bit integer matrices for XPULPV2 extension.
void plp_mat_mult_trans_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 multiplication of 8-bit integer matrices kernel for RV32IM extension.
void plp_mat_mult_trans_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 multiplication of 8-bit integer matrices kernel for XPULPV2 extension.
void plp_mat_mult_trans_q16p_xpulpv2(void * args)
Parallel Matrix multiplication of 16-bit fix-point matrices kernel for XPULPV2 extension.
void plp_mat_mult_trans_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 multiplication of 16-bit integer matrices kernel for RV32IM extension.
void plp_mat_mult_trans_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 multiplication of 16-bit integer matrices kernel for XPULPV2 extension.
void plp_mat_mult_trans_q32p_xpulpv2(void * args)
Parallel Matrix multiplication of 32-bit fix-point matrices kernel for XPULPV2 extension.
void plp_mat_mult_trans_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 multiplication of 32-bit integer matrices kernel for RV32IM extension.
void plp_mat_mult_trans_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 multiplication of 32-bit integer matrices kernel for XPULPV2 extension.
void plp_mat_mult_trans_q8p_xpulpv2(void * args)
Parallel Matrix multiplication of 8-bit fix-point matrices kernel for XPULPV2 extension.
void plp_mat_mult_trans_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 multiplication of 8-bit integer matrices kernel for RV32IM extension.
void plp_mat_mult_trans_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 multiplication of 8-bit integer matrices kernel for XPULPV2 extension.

Detailed Description

This module contains the kernels for matrix transpose matrix multiplications.

The Matrix Transpose Matrix Multiplication computes the product of two matrices with dimensions MxN and OxN. Both matrices is accessed row 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. The resulting matrix has shape MxO.

'pDst[m,o] = pSrcA[m,0]*pSrcB[o,0] + pSrcA[m,1]*pSrcB[o,1] + ... + pSrcA[m,N-1]*pSrcB[o,N-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_trans_i32s_xpulpv2):

`plp_<function name>_<data type><precision><method>_<isa_extension>`
name description
function_name mat_mult_trans
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_trans_f32p_xpulpv2

void plp_mat_mult_trans_f32p_xpulpv2(
    void * args
)

Parallel matrix multiplication of 32-bit floating-point matrices kernel for XPULPV2 extension.

Parameters:

Return: none

Parallel matrix transposed matrix multiplication of 32-bit floating-point matrices kernel for XPULPV2 extension.

function plp_mat_mult_trans_f32s_xpulpv2

void plp_mat_mult_trans_f32s_xpulpv2(
    const float *__restrict__ pSrcA,
    const float *__restrict__ pSrcB,
    uint32_t M,
    uint32_t N,
    uint32_t O,
    float *__restrict__ pDstC
)

Matrix multiplication of 32-bit floating-point matrices kernel for XPULPV2 extension.

Parameters:

  • pSrcA points to the first input matrix
  • pSrcB points to the second input matrix, stored transposed in memory
  • M height of the first input matrix
  • N width of the first input matrix and hight of the second
  • O width of the second input matrix
  • pDstC points to the output matrix

Return: none

matrix transposed matrix multiplication of a 32-bit floating-point matrices for XPULPV2 extension.

function plp_mat_mult_trans_i16p_xpulpv2

void plp_mat_mult_trans_i16p_xpulpv2(
    void * args
)

Parallel matrix transposed matrix multiplication of a 16-bit integer matrices for XPULPV2 extension.

Parameters:

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_trans_i16s_rv32im

void plp_mat_mult_trans_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 multiplication of 16-bit integer matrices kernel for RV32IM extension.

Parameters:

  • pSrcA points to the first input matrix
  • pSrcB points to the second input matrix
  • M height of the first input matrix
  • N width of the first input matrix and hight of the second
  • O width of the second input matrix
  • pDstC points to the output matrix

Return: none

Matrix transposed matrix multiplication of a 16-bit integer matrices for RV32IM extension.

function plp_mat_mult_trans_i16s_xpulpv2

void plp_mat_mult_trans_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 multiplication of 16-bit integer matrices kernel for XPULPV2 extension.

Parameters:

  • pSrcA points to the first input matrix
  • pSrcB points to the second input matrix
  • M height of the first input matrix
  • N width of the first input matrix and hight of the second
  • O width of the second input matrix
  • pDstC points to the output matrix

Return: none

Matrix transposed matrix multiplication of a 16-bit integer matrices for XPULPV2 extension.

function plp_mat_mult_trans_i32p_xpulpv2

void plp_mat_mult_trans_i32p_xpulpv2(
    void * args
)

Parallel matrix transposed matrix multiplication of a 32-bit integer matrices for RV32IM extension.

Parameters:

Return: none

function plp_mat_mult_trans_i32s_rv32im

void plp_mat_mult_trans_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 multiplication of 32-bit integer matrices kernel for RV32IM extension.

Parameters:

  • pSrcA points to the first input matrix
  • pSrcB points to the second input matrix
  • M height of the first input matrix
  • N width of the first input matrix and hight of the second
  • O width of the second input matrix
  • pDstC points to the output matrix

Return: none

Matrix transposed matrix multiplication of a 32-bit integer matrices for RV32IM extension.

function plp_mat_mult_trans_i32s_xpulpv2

void plp_mat_mult_trans_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 multiplication of 32-bit integer matrices kernel for XPULPV2 extension.

Parameters:

  • pSrcA points to the first input matrix
  • pSrcB points to the second input matrix
  • M height of the first input matrix
  • N width of the first input matrix and hight of the second
  • O width of the second input matrix
  • pDstC points to the output matrix

Return: none

Matrix transposed matrix multiplication of a 32-bit integer matrices for XPULPV2 extension.

function plp_mat_mult_trans_i8p_xpulpv2

void plp_mat_mult_trans_i8p_xpulpv2(
    void * args
)

Parallel matrix transposed matrix multiplication of a 8-bit integer matrices for XPULPV2 extension.

Parameters:

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_trans_i8s_rv32im

void plp_mat_mult_trans_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 multiplication of 8-bit integer matrices kernel for RV32IM extension.

Parameters:

  • pSrcA points to the first input matrix
  • pSrcB points to the second input matrix
  • M height of the first input matrix
  • N width of the first input matrix and hight of the second
  • O width of the second input matrix
  • pDstC points to the output matrix

Return: none

Matrix transposed matrix multiplication of a 8-bit integer matrices for RV32IM extension.

function plp_mat_mult_trans_i8s_xpulpv2

void plp_mat_mult_trans_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 multiplication of 8-bit integer matrices kernel for XPULPV2 extension.

Parameters:

  • pSrcA points to the first input matrix
  • pSrcB points to the second input matrix
  • M height of the first input matrix
  • N width of the first input matrix and hight of the second
  • O width of the second input matrix
  • pDstC points to the output matrix

Return: none

Matrix transposed matrix multiplication of a 8-bit integer matrices for XPULPV2 extension.

function plp_mat_mult_trans_q16p_xpulpv2

void plp_mat_mult_trans_q16p_xpulpv2(
    void * args
)

Parallel Matrix multiplication of 16-bit fix-point matrices kernel for XPULPV2 extension.

Parameters:

Return: none

Par: Fix-Point and Shifting

The result will be shifted by the parameter shift to the right (multiplied by 2^-shift). Assume that matrix A is represented as pSrcA * 2^-x, and matrix B as pSrcB * 2^-y (in other words, A has it's x last digits after the binary point). Then, the output is represented as pDstC * 2^-(x + y - shift).

Parallel matrix transposed matrix multiplication of 16-bit fix-point matrices kernel for XPULPV2 extension.

The output of the matrix multiplication will also be stored as an 16-bit array. Set the shift parameter such that no overflow ocurrs.

function plp_mat_mult_trans_q16s_rv32im

void plp_mat_mult_trans_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 multiplication of 16-bit integer matrices kernel for RV32IM extension.

Parameters:

  • pSrcA points to the first input matrix
  • pSrcB points to the second input matrix, stored transposed in memory
  • M height of the first input matrix
  • N width of the first input matrix and hight of the second
  • O width of the second input matrix
  • shift Amount to shift the result of each multiplication.
  • pDstC points to the output matrix

Return: none

Par: Fix-Point and Shifting

The result will be shifted by the parameter shift to the right (multiplied by 2^-shift). Assume that matrix A is represented as pSrcA * 2^-x, and matrix B as pSrcB * 2^-y (in other words, A has it's x last digits after the binary point). Then, the output is represented as pDstC * 2^-(x + y - shift).

matrix transposed matrix multiplication of a 16-bit fix-point matrices for RV32IM extension.

The output of the matrix multiplication will also be stored as an 16-bit array. Set the shift parameter such that no overflow ocurrs.

function plp_mat_mult_trans_q16s_xpulpv2

void plp_mat_mult_trans_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 multiplication of 16-bit integer matrices kernel for XPULPV2 extension.

Parameters:

  • pSrcA points to the first input matrix
  • pSrcB points to the second input matrix, stored transposed in memory
  • M height of the first input matrix
  • N width of the first input matrix and hight of the second
  • O width of the second input matrix
  • shift Amount to shift the result of each multiplication.
  • pDstC points to the output matrix

Return: none

Par: Fix-Point and Shifting

The result will be shifted by the parameter shift to the right (multiplied by 2^-shift). Assume that matrix A is represented as pSrcA * 2^-x, and matrix B as pSrcB * 2^-y (in other words, A has it's x last digits after the binary point). Then, the output is represented as pDstC * 2^-(x + y - shift).

matrix transposed matrix multiplication of a 16-bit fix-point matrices for XPULPV2 extension.

The output of the matrix multiplication will also be stored as an 16-bit array. Set the shift parameter such that no overflow ocurrs.

function plp_mat_mult_trans_q32p_xpulpv2

void plp_mat_mult_trans_q32p_xpulpv2(
    void * args
)

Parallel Matrix multiplication of 32-bit fix-point matrices kernel for XPULPV2 extension.

Parameters:

Return: none

Par: Fix-Point and Shifting

The result will be shifted by the parameter shift to the right (multiplied by 2^-shift). Assume that matrix A is represented as pSrcA * 2^-x, and matrix B as pSrcB * 2^-y (in other words, A has it's x last digits after the binary point). Then, the output is represented as pDstC * 2^-(x + y - shift).

Parallel matrix transposed matrix multiplication of 32-bit fix-point matrices kernel for XPULPV2 extension.

function plp_mat_mult_trans_q32s_rv32im

void plp_mat_mult_trans_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 multiplication of 32-bit integer matrices kernel for RV32IM extension.

Parameters:

  • pSrcA points to the first input matrix
  • pSrcB points to the second input matrix, stored transposed in memory
  • M height of the first input matrix
  • N width of the first input matrix and hight of the second
  • O width of the second input matrix
  • shift Amount to shift the result of each multiplication.
  • pDstC points to the output matrix

Return: none

Par: Fix-Point and Shifting

The result will be shifted by the parameter shift to the right (multiplied by 2^-shift). Assume that matrix A is represented as pSrcA * 2^-x, and matrix B as pSrcB * 2^-y (in other words, A has it's x last digits after the binary point). Then, the output is represented as pDstC * 2^-(x + y - shift).

matrix transposed matrix multiplication of a 32-bit fix-point matrices for RV32IM extension.

function plp_mat_mult_trans_q32s_xpulpv2

void plp_mat_mult_trans_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 multiplication of 32-bit integer matrices kernel for XPULPV2 extension.

Parameters:

  • pSrcA points to the first input matrix
  • pSrcB points to the second input matrix, stored transposed in memory
  • M height of the first input matrix
  • N width of the first input matrix and hight of the second
  • O width of the second input matrix
  • shift Amount to shift the result of each multiplication.
  • pDstC points to the output matrix

Return: none

Par: Fix-Point and Shifting

The result will be shifted by the parameter shift to the right (multiplied by 2^-shift). Assume that matrix A is represented as pSrcA * 2^-x, and matrix B as pSrcB * 2^-y (in other words, A has it's x last digits after the binary point). Then, the output is represented as pDstC * 2^-(x + y - shift).

matrix transposed matrix multiplication of a 32-bit fix-point matrices for XPULPV2 extension.

function plp_mat_mult_trans_q8p_xpulpv2

void plp_mat_mult_trans_q8p_xpulpv2(
    void * args
)

Parallel Matrix multiplication of 8-bit fix-point matrices kernel for XPULPV2 extension.

Parameters:

Return: none

Par: Fix-Point and Shifting

The result will be shifted by the parameter shift to the right (multiplied by 2^-shift). Assume that matrix A is represented as pSrcA * 2^-x, and matrix B as pSrcB * 2^-y (in other words, A has it's x last digits after the binary point). Then, the output is represented as pDstC * 2^-(x + y - shift).

Parallel matrix transposed matrix multiplication of 8-bit fix-point matrices kernel for XPULPV2 extension.

The output of the matrix multiplication will also be stored as an 8-bit array. Set the shift parameter such that no overflow ocurrs.

function plp_mat_mult_trans_q8s_rv32im

void plp_mat_mult_trans_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 multiplication of 8-bit integer matrices kernel for RV32IM extension.

Parameters:

  • pSrcA points to the first input matrix
  • pSrcB points to the second input matrix, stored transposed in memory
  • M height of the first input matrix
  • N width of the first input matrix and hight of the second
  • O width of the second input matrix
  • shift Amount to shift the result of each multiplication.
  • pDstC points to the output matrix

Return: none

Par: Fix-Point and Shifting

The result will be shifted by the parameter shift to the right (multiplied by 2^-shift). Assume that matrix A is represented as pSrcA * 2^-x, and matrix B as pSrcB * 2^-y (in other words, A has it's x last digits after the binary point). Then, the output is represented as pDstC * 2^-(x + y - shift).

matrix transposed matrix multiplication of a 8-bit fix-point matrices for RV32IM extension.

The output of the matrix multiplication will also be stored as an 8-bit array. Set the shift parameter such that no overflow ocurrs.

function plp_mat_mult_trans_q8s_xpulpv2

void plp_mat_mult_trans_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 multiplication of 8-bit integer matrices kernel for XPULPV2 extension.

Parameters:

  • pSrcA points to the first input matrix
  • pSrcB points to the second input matrix, stored transposed in memory
  • M height of the first input matrix
  • N width of the first input matrix and hight of the second
  • O width of the second input matrix
  • shift Amount to shift the result of each multiplication.
  • pDstC points to the output matrix

Return: none

Par: Fix-Point and Shifting

The result will be shifted by the parameter shift to the right (multiplied by 2^-shift). Assume that matrix A is represented as pSrcA * 2^-x, and matrix B as pSrcB * 2^-y (in other words, A has it's x last digits after the binary point). Then, the output is represented as pDstC * 2^-(x + y - shift).

matrix transposed matrix multiplication of a 8-bit fix-point matrices for XPULPV2 extension.

The output of the matrix multiplication will also be stored as an 8-bit array. Set the shift parameter such that no overflow ocurrs.


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