1 #include "MicroBenchmarksF16.h"
2 #include "Error.h"
3
add_while_f16(const float16_t * pSrcA,const float16_t * pSrcB,float16_t * pDst,uint32_t blockSize)4 static void add_while_f16(
5 const float16_t * pSrcA,
6 const float16_t * pSrcB,
7 float16_t * pDst,
8 uint32_t blockSize)
9 {
10 uint32_t blkCnt;
11
12 blkCnt = blockSize;
13
14 while (blkCnt > 0U)
15 {
16 /* C = A + B */
17
18 /* Add and store result in destination buffer. */
19 *pDst++ = (*pSrcA++) + (*pSrcB++);
20
21 /* Decrement loop counter */
22 blkCnt--;
23 }
24 }
25
add_for_f16(const float16_t * pSrcA,const float16_t * pSrcB,float16_t * pDst,uint32_t blockSize)26 static void add_for_f16(
27 const float16_t * pSrcA,
28 const float16_t * pSrcB,
29 float16_t * pDst,
30 uint32_t blockSize)
31 {
32 uint32_t blkCnt;
33 int32_t i;
34
35 blkCnt = blockSize;
36
37 for(i=0; i<blkCnt; i++)
38 {
39 /* C = A + B */
40
41 /* Add and store result in destination buffer. */
42 *pDst++ = (*pSrcA++) + (*pSrcB++);
43
44 }
45 }
46
add_array_f16(const float16_t * pSrcA,const float16_t * pSrcB,float16_t * pDst,uint32_t blockSize)47 static void add_array_f16(
48 const float16_t * pSrcA,
49 const float16_t * pSrcB,
50 float16_t * pDst,
51 uint32_t blockSize)
52 {
53 uint32_t blkCnt;
54 int32_t i;
55
56 blkCnt = blockSize;
57
58 for(i=0; i<blkCnt; i++)
59 {
60 /* C = A + B */
61
62 /* Add and store result in destination buffer. */
63 pDst[i] = pSrcA[i] + pSrcB[i];
64
65 }
66 }
67
test_while_f16()68 void MicroBenchmarksF16::test_while_f16()
69 {
70 add_while_f16(this->inp1,this->inp2,this->outp,this->nbSamples);
71 }
72
test_for_f16()73 void MicroBenchmarksF16::test_for_f16()
74 {
75 add_for_f16(this->inp1,this->inp2,this->outp,this->nbSamples);
76 }
77
test_array_f16()78 void MicroBenchmarksF16::test_array_f16()
79 {
80 add_array_f16(this->inp1,this->inp2,this->outp,this->nbSamples);
81 }
82
83
setUp(Testing::testID_t id,std::vector<Testing::param_t> & params,Client::PatternMgr * mgr)84 void MicroBenchmarksF16::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
85 {
86
87
88 std::vector<Testing::param_t>::iterator it = params.begin();
89 this->nbSamples = *it;
90
91 input1.reload(MicroBenchmarksF16::INPUT1_F16_ID,mgr,this->nbSamples);
92 input2.reload(MicroBenchmarksF16::INPUT2_F16_ID,mgr,this->nbSamples);
93
94
95 output.create(this->nbSamples,MicroBenchmarksF16::OUT_SAMPLES_F16_ID,mgr);
96
97 this->inp1=input1.ptr();
98 this->inp2=input2.ptr();
99 this->outp=output.ptr();
100
101 }
102
tearDown(Testing::testID_t id,Client::PatternMgr * mgr)103 void MicroBenchmarksF16::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
104 {
105 }
106