|
1 /* |
|
2 * LIBOIL - Library of Optimized Inner Loops |
|
3 * Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org> |
|
4 * All rights reserved. |
|
5 * |
|
6 * Redistribution and use in source and binary forms, with or without |
|
7 * modification, are permitted provided that the following conditions |
|
8 * are met: |
|
9 * 1. Redistributions of source code must retain the above copyright |
|
10 * notice, this list of conditions and the following disclaimer. |
|
11 * 2. 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 distribution. |
|
14 * |
|
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
|
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
|
19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
|
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
|
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
|
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
|
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
25 * POSSIBILITY OF SUCH DAMAGE. |
|
26 */ |
|
27 //Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
|
28 |
|
29 #ifdef HAVE_CONFIG_H |
|
30 #include "config.h" |
|
31 #endif |
|
32 |
|
33 #include <liboil/liboilfunction.h> |
|
34 #include <liboil/liboiltest.h> |
|
35 #include "liboil/simdpack/simdpack.h" |
|
36 #include <math.h> |
|
37 |
|
38 static void |
|
39 permute_test (OilTest *test) |
|
40 { |
|
41 int i; |
|
42 int n = test->n; |
|
43 int stride = oil_test_get_value (test, OIL_ARG_SSTR2); |
|
44 uint8_t *ptr = (uint8_t *) oil_test_get_source_data (test, OIL_ARG_SRC2); |
|
45 |
|
46 for(i=0;i<n;i++){ |
|
47 /* FIXME */ |
|
48 OIL_GET(ptr, i*stride, int32_t) = 0; /* oil_rand_s32(); */ |
|
49 } |
|
50 |
|
51 } |
|
52 |
|
53 #define PERMUTE_DEFINE_REF(type) \ |
|
54 static void permute_ ## type ## _ref( \ |
|
55 oil_type_ ## type *dest, int dstr, \ |
|
56 oil_type_ ## type *src1, int sstr1, \ |
|
57 int32_t *src2, int sstr2, int n) \ |
|
58 { \ |
|
59 int i; \ |
|
60 for(i=0;i<n;i++){ \ |
|
61 OIL_GET(dest,dstr*i, oil_type_ ## type) = OIL_GET(src1,sstr1* \ |
|
62 OIL_GET(src2,sstr2*i, int), oil_type_ ## type); \ |
|
63 } \ |
|
64 } \ |
|
65 OIL_DEFINE_IMPL_REF (permute_ ## type ## _ref, permute_ ## type); \ |
|
66 OIL_DEFINE_CLASS_FULL (permute_ ## type, "oil_type_" #type " *dest, int dstr, " \ |
|
67 "oil_type_" #type " *src1, int sstr1, int32_t *src2, int sstr2, int n", \ |
|
68 permute_test) |
|
69 |
|
70 /** |
|
71 * oil_permute_s8: |
|
72 * @dest: |
|
73 * @dstr: |
|
74 * @src1: |
|
75 * @sstr1: |
|
76 * @src2: |
|
77 * @sstr2: |
|
78 * @n: |
|
79 * |
|
80 * Copies elements in @src1 to @dest, permuting them by @src2. That is, |
|
81 * @dest[i] is set to @src1[@src2[i]]. Values in @src2 must be |
|
82 * non-negative and less than @n. |
|
83 */ |
|
84 PERMUTE_DEFINE_REF (s8); |
|
85 /** |
|
86 * oil_permute_u8: |
|
87 * @dest: |
|
88 * @dstr: |
|
89 * @src1: |
|
90 * @sstr1: |
|
91 * @src2: |
|
92 * @sstr2: |
|
93 * @n: |
|
94 * |
|
95 * Copies elements in @src1 to @dest, permuting them by @src2. That is, |
|
96 * @dest[i] is set to @src1[@src2[i]]. Values in @src2 must be |
|
97 * non-negative and less than @n. |
|
98 */ |
|
99 PERMUTE_DEFINE_REF (u8); |
|
100 /** |
|
101 * oil_permute_s16: |
|
102 * @dest: |
|
103 * @dstr: |
|
104 * @src1: |
|
105 * @sstr1: |
|
106 * @src2: |
|
107 * @sstr2: |
|
108 * @n: |
|
109 * |
|
110 * Copies elements in @src1 to @dest, permuting them by @src2. That is, |
|
111 * @dest[i] is set to @src1[@src2[i]]. Values in @src2 must be |
|
112 * non-negative and less than @n. |
|
113 */ |
|
114 PERMUTE_DEFINE_REF (s16); |
|
115 /** |
|
116 * oil_permute_u16: |
|
117 * @dest: |
|
118 * @dstr: |
|
119 * @src1: |
|
120 * @sstr1: |
|
121 * @src2: |
|
122 * @sstr2: |
|
123 * @n: |
|
124 * |
|
125 * Copies elements in @src1 to @dest, permuting them by @src2. That is, |
|
126 * @dest[i] is set to @src1[@src2[i]]. Values in @src2 must be |
|
127 * non-negative and less than @n. |
|
128 */ |
|
129 PERMUTE_DEFINE_REF (u16); |
|
130 /** |
|
131 * oil_permute_s32: |
|
132 * @dest: |
|
133 * @dstr: |
|
134 * @src1: |
|
135 * @sstr1: |
|
136 * @src2: |
|
137 * @sstr2: |
|
138 * @n: |
|
139 * |
|
140 * Copies elements in @src1 to @dest, permuting them by @src2. That is, |
|
141 * @dest[i] is set to @src1[@src2[i]]. Values in @src2 must be |
|
142 * non-negative and less than @n. |
|
143 */ |
|
144 PERMUTE_DEFINE_REF (s32); |
|
145 /** |
|
146 * oil_permute_u32: |
|
147 * @dest: |
|
148 * @dstr: |
|
149 * @src1: |
|
150 * @sstr1: |
|
151 * @src2: |
|
152 * @sstr2: |
|
153 * @n: |
|
154 * |
|
155 * Copies elements in @src1 to @dest, permuting them by @src2. That is, |
|
156 * @dest[i] is set to @src1[@src2[i]]. Values in @src2 must be |
|
157 * non-negative and less than @n. |
|
158 */ |
|
159 PERMUTE_DEFINE_REF (u32); |
|
160 /** |
|
161 * oil_permute_f32: |
|
162 * @dest: |
|
163 * @dstr: |
|
164 * @src1: |
|
165 * @sstr1: |
|
166 * @src2: |
|
167 * @sstr2: |
|
168 * @n: |
|
169 * |
|
170 * Copies elements in @src1 to @dest, permuting them by @src2. That is, |
|
171 * @dest[i] is set to @src1[@src2[i]]. Values in @src2 must be |
|
172 * non-negative and less than @n. |
|
173 */ |
|
174 PERMUTE_DEFINE_REF (f32); |
|
175 /** |
|
176 * oil_permute_f64: |
|
177 * @dest: |
|
178 * @dstr: |
|
179 * @src1: |
|
180 * @sstr1: |
|
181 * @src2: |
|
182 * @sstr2: |
|
183 * @n: |
|
184 * |
|
185 * Copies elements in @src1 to @dest, permuting them by @src2. That is, |
|
186 * @dest[i] is set to @src1[@src2[i]]. Values in @src2 must be |
|
187 * non-negative and less than @n. |
|
188 */ |
|
189 PERMUTE_DEFINE_REF (f64); |
|
190 |
|
191 #ifdef __SYMBIAN32__ |
|
192 |
|
193 #endif |
|
194 OilFunctionClass* __oil_function_class_permute_f32() |
|
195 { |
|
196 return &_oil_function_class_permute_f32; |
|
197 } |
|
198 |
|
199 #ifdef __SYMBIAN32__ |
|
200 |
|
201 #endif |
|
202 OilFunctionClass* __oil_function_class_permute_f64() |
|
203 { |
|
204 return &_oil_function_class_permute_f64; |
|
205 } |
|
206 |
|
207 |
|
208 #ifdef __SYMBIAN32__ |
|
209 |
|
210 #endif |
|
211 OilFunctionClass* __oil_function_class_permute_s16() |
|
212 { |
|
213 return &_oil_function_class_permute_s16; |
|
214 } |
|
215 |
|
216 #ifdef __SYMBIAN32__ |
|
217 |
|
218 #endif |
|
219 OilFunctionClass* __oil_function_class_permute_s32() |
|
220 { |
|
221 return &_oil_function_class_permute_s32; |
|
222 } |
|
223 |
|
224 #ifdef __SYMBIAN32__ |
|
225 |
|
226 #endif |
|
227 OilFunctionClass* __oil_function_class_permute_s8() |
|
228 { |
|
229 return &_oil_function_class_permute_s8; |
|
230 } |
|
231 |
|
232 #ifdef __SYMBIAN32__ |
|
233 |
|
234 #endif |
|
235 OilFunctionClass* __oil_function_class_permute_u16() |
|
236 { |
|
237 return &_oil_function_class_permute_u16; |
|
238 } |
|
239 |
|
240 #ifdef __SYMBIAN32__ |
|
241 |
|
242 #endif |
|
243 OilFunctionClass* __oil_function_class_permute_u32() |
|
244 { |
|
245 return &_oil_function_class_permute_u32; |
|
246 } |
|
247 |
|
248 #ifdef __SYMBIAN32__ |
|
249 |
|
250 #endif |
|
251 OilFunctionClass* __oil_function_class_permute_u8() |
|
252 { |
|
253 return &_oil_function_class_permute_u8; |
|
254 } |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 #ifdef __SYMBIAN32__ |
|
260 |
|
261 OilFunctionImpl* __oil_function_impl_permute_s8_ref() { |
|
262 return &_oil_function_impl_permute_s8_ref; |
|
263 } |
|
264 #endif |
|
265 |
|
266 #ifdef __SYMBIAN32__ |
|
267 |
|
268 OilFunctionImpl* __oil_function_impl_permute_u8_ref() { |
|
269 return &_oil_function_impl_permute_u8_ref; |
|
270 } |
|
271 #endif |
|
272 |
|
273 #ifdef __SYMBIAN32__ |
|
274 |
|
275 OilFunctionImpl* __oil_function_impl_permute_s16_ref() { |
|
276 return &_oil_function_impl_permute_s16_ref; |
|
277 } |
|
278 #endif |
|
279 |
|
280 #ifdef __SYMBIAN32__ |
|
281 |
|
282 OilFunctionImpl* __oil_function_impl_permute_u16_ref() { |
|
283 return &_oil_function_impl_permute_u16_ref; |
|
284 } |
|
285 #endif |
|
286 |
|
287 #ifdef __SYMBIAN32__ |
|
288 |
|
289 OilFunctionImpl* __oil_function_impl_permute_s32_ref() { |
|
290 return &_oil_function_impl_permute_s32_ref; |
|
291 } |
|
292 #endif |
|
293 |
|
294 #ifdef __SYMBIAN32__ |
|
295 |
|
296 OilFunctionImpl* __oil_function_impl_permute_u32_ref() { |
|
297 return &_oil_function_impl_permute_u32_ref; |
|
298 } |
|
299 #endif |
|
300 |
|
301 #ifdef __SYMBIAN32__ |
|
302 |
|
303 OilFunctionImpl* __oil_function_impl_permute_f32_ref() { |
|
304 return &_oil_function_impl_permute_f32_ref; |
|
305 } |
|
306 #endif |
|
307 |
|
308 #ifdef __SYMBIAN32__ |
|
309 |
|
310 OilFunctionImpl* __oil_function_impl_permute_f64_ref() { |
|
311 return &_oil_function_impl_permute_f64_ref; |
|
312 } |
|
313 #endif |
|
314 |