FFTLIB User Guide
FFTLIB_LINALG_matrixMatrixMultiply_ixX_ixX_oxX_cn.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2 **+--------------------------------------------------------------------------+**
3 **| **** |**
4 **| **** |**
5 **| ******o*** |**
6 **| ********_///_**** |**
7 **| ***** /_//_/ **** |**
8 **| ** ** (__/ **** |**
9 **| ********* |**
10 **| **** |**
11 **| *** |**
12 **| |**
13 **| Copyright (c) 2016 Texas Instruments Incorporated |**
14 **| ALL RIGHTS RESERVED |**
15 **| |**
16 **| Permission to use, copy, modify, or distribute this software, |**
17 **| whether in part or in whole, for any purpose is forbidden without |**
18 **| a signed licensing agreement and NDA from Texas Instruments |**
19 **| Incorporated (TI). |**
20 **| |**
21 **| TI makes no representation or warranties with respect to the |**
22 **| performance of this computer program, and specifically disclaims |**
23 **| any responsibility for any damages, special or consequential, |**
24 **| connected with the use of this program. |**
25 **| |**
26 **+--------------------------------------------------------------------------+**
27 *******************************************************************************/
28 
29 
31 
33  FFTLIB_kernelHandle handle,
34  const FFTLIB_bufParams2D_t *src0_addr,
35  const FFTLIB_bufParams2D_t *src1_addr,
36  const FFTLIB_bufParams2D_t *dst_addr,
38 {
40 
41  // store parameters
44  pKerPrivArgs->M = src0_addr->dim_y;
45  pKerPrivArgs->K = src0_addr->dim_x;
46  pKerPrivArgs->N = src1_addr->dim_x;
47 
48  return status;
49 }
50 
51 template <typename dataType, typename accumulateType>
53  const void * src0,
54  const void * src1,
55  void *dst)
56 {
58  int32_t m, k, n;
59  accumulateType product, sum;
60 
62 
63  int32_t M = pKerPrivArgs->M;
64  int32_t K = pKerPrivArgs->K;
65  int32_t N = pKerPrivArgs->N;
66  int32_t strideA = pKerPrivArgs->strideAElements;
67  int32_t strideB = pKerPrivArgs->strideBElements;
68  int32_t strideC = pKerPrivArgs->strideCElements;
69 
70  int8_t shift = pKerPrivArgs->initArgs.shift;
71 
72 
73  const dataType *A = (const dataType *)src0;
74  const dataType *B = (const dataType *)src1;
75  dataType *C = (dataType *)dst;
76 
77  for (m = 0; m < M; m++) {
78  for (n = 0; n < N; n++) {
79  sum = 0;
80  for (k = 0; k < K; k++){
81  product = FFTLIB_UTIL_mult(A[k + m*strideA], B[n + k*strideB]);
82  sum = sum + product;
83  }
84  C[n + m*strideC] = FFTLIB_UTIL_shiftAndRound<accumulateType, dataType>(sum, shift);
85 
86 #if defined(FFTLIB_INDUCE_NATURALC_ERROR)
87  C[n + m*StrideC] = 77;
88 #endif
89  }
90  }
91  return (status);
92 }
93 
94 // explicit instantiation for the different data type versions
96  const void * src0,
97  const void * src1,
98  void *dst);
99 
101  const void * src0,
102  const void * src1,
103  void *dst);
104 
106  const void * src0,
107  const void * src1,
108  void *dst);
FFTLIB_STATUS FFTLIB_LINALG_matrixMatrixMultiply_ixX_ixX_oxX_exec_cn(FFTLIB_kernelHandle handle, const void *src0, const void *src1, void *dst)
This function is the main execution function for the natural C implementation of the matrix-matrix mu...
template FFTLIB_STATUS FFTLIB_LINALG_matrixMatrixMultiply_ixX_ixX_oxX_exec_cn< int32_t, FFTLIB_int128_t >(FFTLIB_kernelHandle handle, const void *src0, const void *src1, void *dst)
template FFTLIB_STATUS FFTLIB_LINALG_matrixMatrixMultiply_ixX_ixX_oxX_exec_cn< int16_t, int64_t >(FFTLIB_kernelHandle handle, const void *src0, const void *src1, void *dst)
FFTLIB_STATUS FFTLIB_LINALG_matrixMatrixMultiply_ixX_ixX_oxX_init_cn(FFTLIB_kernelHandle handle, const FFTLIB_bufParams2D_t *src0_addr, const FFTLIB_bufParams2D_t *src1_addr, const FFTLIB_bufParams2D_t *dst_addr, const FFTLIB_LINALG_matrixMatrixMultiply_ixX_ixX_oxX_InitArgs *pKerInitArgs)
This function is the initialization function for the natural C implementation of the kernel.
template FFTLIB_STATUS FFTLIB_LINALG_matrixMatrixMultiply_ixX_ixX_oxX_exec_cn< int8_t, int32_t >(FFTLIB_kernelHandle handle, const void *src0, const void *src1, void *dst)
Header file for kernel's internal use. For the kernel's interface, please see FFTLIB_LINALG_matrixMat...
void * FFTLIB_kernelHandle
Handle type for FFTLIB operations.
Definition: FFTLIB_types.h:217
FFTLIB_STATUS_NAME
The enumeration of all status codes.
Definition: FFTLIB_types.h:172
@ FFTLIB_SUCCESS
Definition: FFTLIB_types.h:173
static void FFTLIB_UTIL_mult(int64_t *ph, int64_t *pl, int64_t a, int64_t b)
This structure holds all the initialization parameters for matrix- matrix multiplication.
int32_t K
Number of blocks in the horizontal dimension of the first input matrix. In the case of natural C code...
int32_t M
Number of blocks in the vertical dimension of the first input matrix. In the case of natural C code,...
int32_t N
Number of blocks in the horizontal dimension of the second input matrix. In the case of natural C cod...
FFTLIB_LINALG_matrixMatrixMultiply_ixX_ixX_oxX_InitArgs initArgs
Structure holding initialization parameters.
A structure for a 2 dimensional buffer descriptor.
uint32_t dim_y
Height of buffer in Y dimension in elements.
uint32_t dim_x
Width of buffer in X dimension in elements.