DSPLIB User Guide
DSPLIB_matMul_ci.cpp
Go to the documentation of this file.
1 /******************************************************************************/
2 /* Copyright (C) 2017 Texas Instruments Incorporated - https://www.ti.com/
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  ******************************************************************************/
33 
34 /*******************************************************************************
35  *
36  * INCLUDES
37  *
38  ******************************************************************************/
39 
40 #include "../common/c71/DSPLIB_inlines.h"
41 #include "DSPLIB_matMul_priv.h"
42 #include "DSPLIB_types.h"
43 #include "TI_platforms.h"
44 #include <cstdint>
45 #include <float.h>
46 
47 #define DSPLIB_MATMUL_UNROLL (1024)
48 
49 template <typename dataType>
51  const DSPLIB_bufParams2D_t *bufParamsIn0,
52  const DSPLIB_bufParams2D_t *bufParamsIn1,
53  const DSPLIB_bufParams2D_t *bufParamsOut,
54  const DSPLIB_matMul_InitArgs *pKerInitArgs)
55 {
56 
58  DSPLIB_matMul_PrivArgs *pKerPrivArgs = (DSPLIB_matMul_PrivArgs *) handle;
59 
60  int32_t N = pKerPrivArgs->N;
61 
62  if ((N * sizeof(dataType)) % DSPLIB_MATMUL_UNROLL == 0) {
63  status = DSPLIB_matMul_N_unroll_init_ci<dataType>(handle, bufParamsIn0, bufParamsIn1, bufParamsOut, pKerInitArgs);
64  }
65  else {
66  status = DSPLIB_matMul_generic_init_ci<dataType>(handle, bufParamsIn0, bufParamsIn1, bufParamsOut, pKerInitArgs);
67  }
68 
69  return status;
70 }
71 
73  const DSPLIB_bufParams2D_t *bufParamsIn0,
74  const DSPLIB_bufParams2D_t *bufParamsIn1,
75  const DSPLIB_bufParams2D_t *bufParamsOut,
76  const DSPLIB_matMul_InitArgs *pKerInitArgs);
78  const DSPLIB_bufParams2D_t *bufParamsIn0,
79  const DSPLIB_bufParams2D_t *bufParamsIn1,
80  const DSPLIB_bufParams2D_t *bufParamsOut,
81  const DSPLIB_matMul_InitArgs *pKerInitArgs);
82 template <typename dataType>
84 DSPLIB_matMul_exec_ci(DSPLIB_kernelHandle handle, void *restrict pIn0, void *restrict pIn1, void *restrict pOut)
85 {
86 
88  DSPLIB_matMul_PrivArgs *pKerPrivArgs = (DSPLIB_matMul_PrivArgs *) handle;
89 
90  int32_t N = pKerPrivArgs->N;
91 
92  if ((N * sizeof(dataType)) % DSPLIB_MATMUL_UNROLL == 0) {
93 
94  status = DSPLIB_matMul_N_unroll_exec_ci<dataType>(handle, pIn0, pIn1, pOut);
95  }
96  else {
97 
98  status = DSPLIB_matMul_generic_exec_ci<dataType>(handle, pIn0, pIn1, pOut);
99  }
100 
101  return status;
102 }
103 
105 DSPLIB_matMul_exec_ci<float>(DSPLIB_kernelHandle handle, void *restrict pIn0, void *restrict pIn1, void *restrict pOut);
106 
108  void *restrict pIn0,
109  void *restrict pIn1,
110  void *restrict pOut);
template DSPLIB_STATUS DSPLIB_matMul_exec_ci< float >(DSPLIB_kernelHandle handle, void *restrict pIn0, void *restrict pIn1, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_matMul_init_ci< float >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsIn0, const DSPLIB_bufParams2D_t *bufParamsIn1, const DSPLIB_bufParams2D_t *bufParamsOut, const DSPLIB_matMul_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_matMul_init_ci< double >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsIn0, const DSPLIB_bufParams2D_t *bufParamsIn1, const DSPLIB_bufParams2D_t *bufParamsOut, const DSPLIB_matMul_InitArgs *pKerInitArgs)
DSPLIB_STATUS DSPLIB_matMul_init_ci(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsIn0, const DSPLIB_bufParams2D_t *bufParamsIn1, const DSPLIB_bufParams2D_t *bufParamsOut, const DSPLIB_matMul_InitArgs *pKerInitArgs)
This function is the initialization function for the C7x implementation of the kernel....
DSPLIB_STATUS DSPLIB_matMul_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....
template DSPLIB_STATUS DSPLIB_matMul_exec_ci< double >(DSPLIB_kernelHandle handle, void *restrict pIn0, void *restrict pIn1, void *restrict pOut)
#define DSPLIB_MATMUL_UNROLL
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_matMul.
DSPLIB_STATUS_NAME
The enumeration of all status codes.
Definition: DSPLIB_types.h:151
void * DSPLIB_kernelHandle
Handle type for DSPLIB operations.
Definition: DSPLIB_types.h:172
@ DSPLIB_SUCCESS
Definition: DSPLIB_types.h:152
A structure for a 2 dimensional buffer descriptor.
Structure containing the parameters to initialize the kernel.
Structure that is reserved for internal use by the kernel.