1 #include "UnaryF32.h"
2 #include "Error.h"
3 
4 /* Upper bound of maximum matrix dimension used by Python */
5 #define MAXMATRIXDIM 40
6 
7 /*
8 
9 Offset in input test pattern for matrix of dimension d * d.
10 Must be coherent with Python script Matrix.py
11 
12 */
cholesky_offset(int d)13 static int cholesky_offset(int d)
14 {
15   int offset=14;
16   switch (d)
17   {
18    case 4:
19      offset = 14;
20    break;
21    case 8:
22      offset = 79;
23    break;
24    case 9:
25      offset = 143;
26    break;
27    case 15:
28      offset = 224;
29    break;
30    case 16:
31      offset = 449;
32    break;
33    default:
34     offset = 14;
35    break;
36   }
37 
38   return(offset);
39 }
40 
41 
test_mat_scale_f32()42     void UnaryF32::test_mat_scale_f32()
43     {
44        arm_mat_scale_f32(&this->in1,0.5,&this->out);
45     }
46 
test_mat_inverse_f32()47     void UnaryF32::test_mat_inverse_f32()
48     {
49        arm_mat_inverse_f32(&this->in1,&this->out);
50     }
51 
test_mat_trans_f32()52     void UnaryF32::test_mat_trans_f32()
53     {
54        arm_mat_trans_f32(&this->in1,&this->out);
55     }
56 
test_mat_cmplx_trans_f32()57     void UnaryF32::test_mat_cmplx_trans_f32()
58     {
59        arm_mat_cmplx_trans_f32(&this->in1,&this->out);
60     }
61 
test_mat_add_f32()62     void UnaryF32::test_mat_add_f32()
63     {
64        arm_mat_add_f32(&this->in1,&this->in1,&this->out);
65     }
66 
test_mat_sub_f32()67     void UnaryF32::test_mat_sub_f32()
68     {
69        arm_mat_sub_f32(&this->in1,&this->in1,&this->out);
70     }
71 
test_mat_vec_mult_f32()72     void UnaryF32::test_mat_vec_mult_f32()
73     {
74        arm_mat_vec_mult_f32(&this->in1, vecp, outp);
75     }
76 
test_mat_cholesky_dpo_f32()77     void UnaryF32::test_mat_cholesky_dpo_f32()
78     {
79         arm_mat_cholesky_f32(&this->in1,&this->out);
80     }
81 
test_solve_upper_triangular_f32()82     void UnaryF32::test_solve_upper_triangular_f32()
83     {
84         arm_mat_solve_upper_triangular_f32(&this->in1,&this->in2,&this->out);
85     }
86 
test_solve_lower_triangular_f32()87     void UnaryF32::test_solve_lower_triangular_f32()
88     {
89         arm_mat_solve_lower_triangular_f32(&this->in1,&this->in2,&this->out);
90     }
91 
test_ldlt_decomposition_f32()92     void UnaryF32::test_ldlt_decomposition_f32()
93     {
94         arm_mat_ldlt_f32(&this->in1,&this->outll,&this->outd,(uint16_t*)outp);
95     }
96 
97 
setUp(Testing::testID_t id,std::vector<Testing::param_t> & params,Client::PatternMgr * mgr)98     void UnaryF32::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
99     {
100 
101 
102        std::vector<Testing::param_t>::iterator it = params.begin();
103 
104        this->nbr = *it++;
105        this->nbc = *it;
106 
107 
108        switch(id)
109        {
110           case TEST_MAT_VEC_MULT_F32_6:
111              input1.reload(UnaryF32::INPUTA_F32_ID,mgr,this->nbr*this->nbc);
112              vec.reload(UnaryF32::INPUTVEC1_F32_ID,mgr,this->nbc);
113              output.create(this->nbr,UnaryF32::OUT_F32_ID,mgr);
114              vecp=vec.ptr();
115              outp=output.ptr();
116 
117              this->in1.numRows = this->nbr;
118              this->in1.numCols = this->nbc;
119              this->in1.pData = input1.ptr();
120           break;
121           case TEST_MAT_TRANS_F32_3:
122               input1.reload(UnaryF32::INPUTA_F32_ID,mgr,this->nbr*this->nbc);
123               output.create(this->nbr*this->nbc,UnaryF32::OUT_F32_ID,mgr);
124 
125               this->out.numRows = this->nbc;
126               this->out.numCols = this->nbr;
127               this->out.pData = output.ptr();
128 
129               this->in1.numRows = this->nbr;
130               this->in1.numCols = this->nbc;
131               this->in1.pData = input1.ptr();
132           break;
133           case TEST_MAT_CMPLX_TRANS_F32_7:
134               input1.reload(UnaryF32::INPUTAC_F32_ID,mgr,2*this->nbr*this->nbc);
135               output.create(2*this->nbr*this->nbc,UnaryF32::OUT_F32_ID,mgr);
136 
137               this->out.numRows = this->nbc;
138               this->out.numCols = this->nbr;
139               this->out.pData = output.ptr();
140 
141               this->in1.numRows = this->nbr;
142               this->in1.numCols = this->nbc;
143               this->in1.pData = input1.ptr();
144           break;
145 
146           case TEST_MAT_CHOLESKY_DPO_F32_8:
147           {
148             int offset=14;
149             float32_t *p;
150             float32_t *aPtr;
151             input1.reload(UnaryF32::INPUTSCHOLESKY1_DPO_F32_ID,mgr);
152             output.create(this->nbc * this->nbr,UnaryF32::OUT_F32_ID,mgr);
153 
154             a.create(this->nbr*this->nbc,UnaryF32::TMPA_F32_ID,mgr);
155 
156             /* Offsets must be coherent with the sizes used in python script
157                 Matrix.py for pattern generation */
158             offset=cholesky_offset(this->nbr);
159 
160              p = input1.ptr();
161              aPtr = a.ptr();
162 
163 
164 
165              memcpy(aPtr,p + offset,sizeof(float32_t)*this->nbr*this->nbr);
166 
167              this->out.numRows = this->nbr;
168              this->out.numCols = this->nbc;
169              this->out.pData = output.ptr();
170 
171              this->in1.numRows = this->nbr;
172              this->in1.numCols = this->nbc;
173              this->in1.pData = aPtr;
174 
175 
176 
177           }
178           break;
179 
180           case TEST_SOLVE_UPPER_TRIANGULAR_F32_9:
181           {
182              int offset=14;
183              float32_t *p;
184              float32_t *aPtr;
185              float32_t *bPtr;
186 
187              input1.reload(UnaryF32::INPUT_UT_DPO_F32_ID,mgr);
188              input2.reload(UnaryF32::INPUT_RNDA_DPO_F32_ID,mgr);
189              output.create(this->nbc * this->nbr,UnaryF32::OUT_F32_ID,mgr);
190 
191              a.create(this->nbr*this->nbc,UnaryF32::TMPA_F32_ID,mgr);
192              b.create(this->nbr*this->nbc,UnaryF32::TMPB_F32_ID,mgr);
193 
194              /* Offsets must be coherent with the sizes used in python script
195                 Matrix.py for pattern generation */
196              offset=cholesky_offset(this->nbr);
197 
198              p = input1.ptr();
199              aPtr = a.ptr();
200              memcpy(aPtr,&p[offset],sizeof(float32_t)*this->nbr*this->nbr);
201 
202              p = input2.ptr();
203              bPtr = b.ptr();
204              memcpy(bPtr,&p[offset],sizeof(float32_t)*this->nbr*this->nbr);
205 
206              this->out.numRows = this->nbr;
207              this->out.numCols = this->nbc;
208              this->out.pData = output.ptr();
209 
210              this->in1.numRows = this->nbr;
211              this->in1.numCols = this->nbc;
212              this->in1.pData = aPtr;
213 
214              this->in2.numRows = this->nbr;
215              this->in2.numCols = this->nbc;
216              this->in2.pData = bPtr;
217           }
218           break;
219 
220           case TEST_SOLVE_LOWER_TRIANGULAR_F32_10:
221           {
222              int offset=14;
223              float32_t *p;
224              float32_t *aPtr;
225              float32_t *bPtr;
226 
227              input1.reload(UnaryF32::INPUT_LT_DPO_F32_ID,mgr);
228              input2.reload(UnaryF32::INPUT_RNDA_DPO_F32_ID,mgr);
229              output.create(this->nbc * this->nbr,UnaryF32::OUT_F32_ID,mgr);
230 
231              a.create(this->nbr*this->nbc,UnaryF32::TMPA_F32_ID,mgr);
232              b.create(this->nbr*this->nbc,UnaryF32::TMPB_F32_ID,mgr);
233 
234              /* Offsets must be coherent with the sizes used in python script
235                 Matrix.py for pattern generation */
236              offset=cholesky_offset(this->nbr);
237 
238              p = input1.ptr();
239              aPtr = a.ptr();
240              memcpy(aPtr,&p[offset],sizeof(float32_t)*this->nbr*this->nbr);
241 
242              p = input2.ptr();
243              bPtr = b.ptr();
244              memcpy(bPtr,&p[offset],sizeof(float32_t)*this->nbr*this->nbr);
245 
246              this->out.numRows = this->nbr;
247              this->out.numCols = this->nbc;
248              this->out.pData = output.ptr();
249 
250              this->in1.numRows = this->nbr;
251              this->in1.numCols = this->nbc;
252              this->in1.pData = aPtr;
253 
254              this->in2.numRows = this->nbr;
255              this->in2.numCols = this->nbc;
256              this->in2.pData = bPtr;
257           }
258           break;
259 
260           case TEST_LDLT_DECOMPOSITION_F32_11:
261           {
262              float32_t *p, *aPtr;
263 
264              int offset=14;
265              input1.reload(UnaryF32::INPUTSCHOLESKY1_DPO_F32_ID,mgr);
266 
267 
268              outputll.create(this->nbr*this->nbr,UnaryF32::LL_F32_ID,mgr);
269              outputd.create(this->nbr*this->nbr,UnaryF32::D_F32_ID,mgr);
270              outputp.create(this->nbr,UnaryF32::PERM_S16_ID,mgr);
271 
272 
273              a.create(MAXMATRIXDIM*MAXMATRIXDIM,UnaryF32::TMPA_F32_ID,mgr);
274 
275              /* Offsets must be coherent with the sizes used in python script
276                 Matrix.py for pattern generation */
277              offset=cholesky_offset(this->nbr);
278 
279              p = input1.ptr();
280              aPtr = a.ptr();
281              memcpy(aPtr,&p[offset],sizeof(float32_t)*this->nbr*this->nbr);
282 
283              this->in1.numRows = this->nbr;
284              this->in1.numCols = this->nbc;
285              this->in1.pData = aPtr;
286 
287              this->outll.numRows = this->nbr;
288              this->outll.numCols = this->nbc;
289              this->outll.pData = outputll.ptr();
290 
291              this->outd.numRows = this->nbr;
292              this->outd.numCols = this->nbc;
293              this->outd.pData = outputd.ptr();
294 
295 
296              outpp = outputp.ptr();
297           }
298           break;
299 
300           default:
301               input1.reload(UnaryF32::INPUTA_F32_ID,mgr,this->nbr*this->nbc);
302               output.create(this->nbr*this->nbc,UnaryF32::OUT_F32_ID,mgr);
303 
304               this->out.numRows = this->nbr;
305               this->out.numCols = this->nbc;
306               this->out.pData = output.ptr();
307 
308               this->in1.numRows = this->nbr;
309               this->in1.numCols = this->nbc;
310               this->in1.pData = input1.ptr();
311           break;
312        }
313 
314 
315 
316 
317 
318 
319 
320     }
321 
tearDown(Testing::testID_t id,Client::PatternMgr * mgr)322     void UnaryF32::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
323     {
324     }
325