1 #include "MicroBenchmarksQ7.h"
2 #include "Error.h"
3 
add_while_q7(const q7_t * pSrcA,const q7_t * pSrcB,q7_t * pDst,uint32_t blockSize)4 static void add_while_q7(
5   const q7_t * pSrcA,
6   const q7_t * pSrcB,
7         q7_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_q7(const q7_t * pSrcA,const q7_t * pSrcB,q7_t * pDst,uint32_t blockSize)26 static void add_for_q7(
27   const q7_t * pSrcA,
28   const q7_t * pSrcB,
29         q7_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_q7(const q7_t * pSrcA,const q7_t * pSrcB,q7_t * pDst,uint32_t blockSize)47 static void add_array_q7(
48   const q7_t * pSrcA,
49   const q7_t * pSrcB,
50         q7_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_q7()68     void MicroBenchmarksQ7::test_while_q7()
69     {
70       add_while_q7(this->inp1,this->inp2,this->outp,this->nbSamples);
71     }
72 
test_for_q7()73     void MicroBenchmarksQ7::test_for_q7()
74     {
75       add_for_q7(this->inp1,this->inp2,this->outp,this->nbSamples);
76     }
77 
test_array_q7()78     void MicroBenchmarksQ7::test_array_q7()
79     {
80       add_array_q7(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 MicroBenchmarksQ7::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(MicroBenchmarksQ7::INPUT1_Q7_ID,mgr,this->nbSamples);
92        input2.reload(MicroBenchmarksQ7::INPUT2_Q7_ID,mgr,this->nbSamples);
93 
94 
95        output.create(this->nbSamples,MicroBenchmarksQ7::OUT_SAMPLES_Q7_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 MicroBenchmarksQ7::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
104     {
105     }
106