1 #include "MicroBenchmarksQ15.h"
2 #include "Error.h"
3 
add_while_q15(const q15_t * pSrcA,const q15_t * pSrcB,q15_t * pDst,uint32_t blockSize)4 static void add_while_q15(
5   const q15_t * pSrcA,
6   const q15_t * pSrcB,
7         q15_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_q15(const q15_t * pSrcA,const q15_t * pSrcB,q15_t * pDst,uint32_t blockSize)26 static void add_for_q15(
27   const q15_t * pSrcA,
28   const q15_t * pSrcB,
29         q15_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_q15(const q15_t * pSrcA,const q15_t * pSrcB,q15_t * pDst,uint32_t blockSize)47 static void add_array_q15(
48   const q15_t * pSrcA,
49   const q15_t * pSrcB,
50         q15_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_q15()68     void MicroBenchmarksQ15::test_while_q15()
69     {
70       add_while_q15(this->inp1,this->inp2,this->outp,this->nbSamples);
71     }
72 
test_for_q15()73     void MicroBenchmarksQ15::test_for_q15()
74     {
75       add_for_q15(this->inp1,this->inp2,this->outp,this->nbSamples);
76     }
77 
test_array_q15()78     void MicroBenchmarksQ15::test_array_q15()
79     {
80       add_array_q15(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 MicroBenchmarksQ15::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(MicroBenchmarksQ15::INPUT1_Q15_ID,mgr,this->nbSamples);
92        input2.reload(MicroBenchmarksQ15::INPUT2_Q15_ID,mgr,this->nbSamples);
93 
94 
95        output.create(this->nbSamples,MicroBenchmarksQ15::OUT_SAMPLES_Q15_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 MicroBenchmarksQ15::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
104     {
105     }
106