numexpr 2.14.2__cp313-cp313-win_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,602 @@
1
+ /*********************************************************************
2
+ Numexpr - Fast numerical array expression evaluator for NumPy.
3
+
4
+ License: MIT
5
+ Author: See AUTHORS.txt
6
+
7
+ See LICENSE.txt for details about copyright and rights to use.
8
+ **********************************************************************/
9
+
10
+ // WARNING: This file is included multiple times in `interpreter.cpp`. It is
11
+ // essentially a very macro-heavy jump table. Interpretation is best done by
12
+ // the developer by expanding all macros (e.g. adding `'-E'` to the `extra_cflags`
13
+ // argument in `setup.py` and looking at the resulting `interpreter.cpp`.
14
+ //
15
+ // Changes made to this file will not be recognized by the compile, so the developer
16
+ // must make a trivial change is made to `interpreter.cpp` or delete the `build/`
17
+ // directory in-between each build.
18
+ {
19
+ #define VEC_LOOP(expr) for(j = 0; j < BLOCK_SIZE; j++) { \
20
+ expr; \
21
+ }
22
+
23
+ #define VEC_ARG0(expr) \
24
+ BOUNDS_CHECK(store_in); \
25
+ { \
26
+ char *dest = mem[store_in]; \
27
+ VEC_LOOP(expr); \
28
+ } break
29
+
30
+ #define VEC_ARG1(expr) \
31
+ BOUNDS_CHECK(store_in); \
32
+ BOUNDS_CHECK(arg1); \
33
+ { \
34
+ char *dest = mem[store_in]; \
35
+ char *x1 = mem[arg1]; \
36
+ npy_intp ss1 = params.memsizes[arg1]; \
37
+ npy_intp sb1 = memsteps[arg1]; \
38
+ /* nowarns is defined and used so as to \
39
+ avoid compiler warnings about unused \
40
+ variables */ \
41
+ npy_intp nowarns = ss1+sb1+*x1; \
42
+ nowarns += 1; \
43
+ VEC_LOOP(expr); \
44
+ } break
45
+
46
+ #define VEC_ARG2(expr) \
47
+ BOUNDS_CHECK(store_in); \
48
+ BOUNDS_CHECK(arg1); \
49
+ BOUNDS_CHECK(arg2); \
50
+ { \
51
+ char *dest = mem[store_in]; \
52
+ char *x1 = mem[arg1]; \
53
+ npy_intp ss1 = params.memsizes[arg1]; \
54
+ npy_intp sb1 = memsteps[arg1]; \
55
+ /* nowarns is defined and used so as to \
56
+ avoid compiler warnings about unused \
57
+ variables */ \
58
+ npy_intp nowarns = ss1+sb1+*x1; \
59
+ char *x2 = mem[arg2]; \
60
+ npy_intp ss2 = params.memsizes[arg2]; \
61
+ npy_intp sb2 = memsteps[arg2]; \
62
+ nowarns += ss2+sb2+*x2; \
63
+ VEC_LOOP(expr); \
64
+ } break
65
+
66
+ #define VEC_ARG3(expr) \
67
+ BOUNDS_CHECK(store_in); \
68
+ BOUNDS_CHECK(arg1); \
69
+ BOUNDS_CHECK(arg2); \
70
+ BOUNDS_CHECK(arg3); \
71
+ { \
72
+ char *dest = mem[store_in]; \
73
+ char *x1 = mem[arg1]; \
74
+ npy_intp ss1 = params.memsizes[arg1]; \
75
+ npy_intp sb1 = memsteps[arg1]; \
76
+ /* nowarns is defined and used so as to \
77
+ avoid compiler warnings about unused \
78
+ variables */ \
79
+ npy_intp nowarns = ss1+sb1+*x1; \
80
+ char *x2 = mem[arg2]; \
81
+ npy_intp ss2 = params.memsizes[arg2]; \
82
+ npy_intp sb2 = memsteps[arg2]; \
83
+ char *x3 = mem[arg3]; \
84
+ npy_intp ss3 = params.memsizes[arg3]; \
85
+ npy_intp sb3 = memsteps[arg3]; \
86
+ nowarns += ss2+sb2+*x2; \
87
+ nowarns += ss3+sb3+*x3; \
88
+ VEC_LOOP(expr); \
89
+ } break
90
+
91
+ #define VEC_ARG1_VML(expr) \
92
+ BOUNDS_CHECK(store_in); \
93
+ BOUNDS_CHECK(arg1); \
94
+ { \
95
+ char *dest = mem[store_in]; \
96
+ char *x1 = mem[arg1]; \
97
+ expr; \
98
+ } break
99
+
100
+ #define VEC_ARG2_VML(expr) \
101
+ BOUNDS_CHECK(store_in); \
102
+ BOUNDS_CHECK(arg1); \
103
+ BOUNDS_CHECK(arg2); \
104
+ { \
105
+ char *dest = mem[store_in]; \
106
+ char *x1 = mem[arg1]; \
107
+ char *x2 = mem[arg2]; \
108
+ expr; \
109
+ } break
110
+
111
+ #define VEC_ARG3_VML(expr) \
112
+ BOUNDS_CHECK(store_in); \
113
+ BOUNDS_CHECK(arg1); \
114
+ BOUNDS_CHECK(arg2); \
115
+ BOUNDS_CHECK(arg3); \
116
+ { \
117
+ char *dest = mem[store_in]; \
118
+ char *x1 = mem[arg1]; \
119
+ char *x2 = mem[arg2]; \
120
+ char *x3 = mem[arg3]; \
121
+ expr; \
122
+ } break
123
+
124
+ int pc;
125
+ unsigned int j;
126
+
127
+ // set up pointers to next block of inputs and outputs
128
+ #ifdef SINGLE_ITEM_CONST_LOOP
129
+ mem[0] = params.output;
130
+ #else // SINGLE_ITEM_CONST_LOOP
131
+ // use the iterator's inner loop data
132
+ memcpy(mem, iter_dataptr, (1+params.n_inputs)*sizeof(char*));
133
+ # ifndef NO_OUTPUT_BUFFERING
134
+ // if output buffering is necessary, first write to the buffer
135
+ if(params.out_buffer != NULL) {
136
+ mem[0] = params.out_buffer;
137
+ }
138
+ # endif // NO_OUTPUT_BUFFERING
139
+ memcpy(memsteps, iter_strides, (1+params.n_inputs)*sizeof(npy_intp));
140
+ #endif // SINGLE_ITEM_CONST_LOOP
141
+
142
+ // WARNING: From now on, only do references to mem[arg[123]]
143
+ // & memsteps[arg[123]] inside the VEC_ARG[123] macros,
144
+ // or you will risk accessing invalid addresses.
145
+
146
+ for (pc = 0; pc < params.prog_len; pc += 4) {
147
+ unsigned char op = params.program[pc];
148
+ unsigned int store_in = params.program[pc+1];
149
+ unsigned int arg1 = params.program[pc+2];
150
+ unsigned int arg2 = params.program[pc+3];
151
+ #define arg3 params.program[pc+5]
152
+ // Iterator reduce macros
153
+ #ifdef REDUCTION_INNER_LOOP // Reduce is the inner loop
154
+ #define i_reduce *(int *)dest
155
+ #define l_reduce *(long long *)dest
156
+ #define f_reduce *(float *)dest
157
+ #define d_reduce *(double *)dest
158
+ #define cr_reduce *(double *)dest
159
+ #define ci_reduce *((double *)dest+1)
160
+ #else /* Reduce is the outer loop */
161
+ #define i_reduce i_dest
162
+ #define l_reduce l_dest
163
+ #define f_reduce f_dest
164
+ #define d_reduce d_dest
165
+ #define cr_reduce cr_dest
166
+ #define ci_reduce ci_dest
167
+ #endif
168
+ #define b_dest ((char *)dest)[j]
169
+ #define i_dest ((int *)dest)[j]
170
+ #define l_dest ((long long *)dest)[j]
171
+ #define f_dest ((float *)dest)[j]
172
+ #define d_dest ((double *)dest)[j]
173
+ #define cr_dest ((double *)dest)[2*j]
174
+ #define ci_dest ((double *)dest)[2*j+1]
175
+ #define s_dest ((char *)dest + j*memsteps[store_in])
176
+ #define b1 ((char *)(x1+j*sb1))[0]
177
+ #define i1 ((int *)(x1+j*sb1))[0]
178
+ #define l1 ((long long *)(x1+j*sb1))[0]
179
+ #define f1 ((float *)(x1+j*sb1))[0]
180
+ #define d1 ((double *)(x1+j*sb1))[0]
181
+ #define c1r ((double *)(x1+j*sb1))[0]
182
+ #define c1i ((double *)(x1+j*sb1))[1]
183
+ #define s1 ((char *)x1+j*sb1)
184
+ #define b2 ((char *)(x2+j*sb2))[0]
185
+ #define i2 ((int *)(x2+j*sb2))[0]
186
+ #define l2 ((long long *)(x2+j*sb2))[0]
187
+ #define f2 ((float *)(x2+j*sb2))[0]
188
+ #define d2 ((double *)(x2+j*sb2))[0]
189
+ #define c2r ((double *)(x2+j*sb2))[0]
190
+ #define c2i ((double *)(x2+j*sb2))[1]
191
+ #define s2 ((char *)x2+j*sb2)
192
+ #define b3 ((char *)(x3+j*sb3))[0]
193
+ #define i3 ((int *)(x3+j*sb3))[0]
194
+ #define l3 ((long long *)(x3+j*sb3))[0]
195
+ #define f3 ((float *)(x3+j*sb3))[0]
196
+ #define d3 ((double *)(x3+j*sb3))[0]
197
+ #define c3r ((double *)(x3+j*sb3))[0]
198
+ #define c3i ((double *)(x3+j*sb3))[1]
199
+ #define s3 ((char *)x3+j*sb3)
200
+ /* Some temporaries */
201
+ double da, db;
202
+ std::complex<double> ca, cb;
203
+
204
+ switch (op) {
205
+
206
+ case OP_NOOP: break;
207
+
208
+ case OP_COPY_BB: VEC_ARG1(b_dest = b1);
209
+ case OP_COPY_SS: VEC_ARG1(memcpy(s_dest, s1, ss1));
210
+ /* The next versions of copy opcodes can cope with unaligned
211
+ data even on platforms that crash while accessing it
212
+ (like the Sparc architecture under Solaris). */
213
+ case OP_COPY_II: VEC_ARG1(memcpy(&i_dest, s1, sizeof(int)));
214
+ case OP_COPY_LL: VEC_ARG1(memcpy(&l_dest, s1, sizeof(long long)));
215
+ case OP_COPY_FF: VEC_ARG1(memcpy(&f_dest, s1, sizeof(float)));
216
+ case OP_COPY_DD: VEC_ARG1(memcpy(&d_dest, s1, sizeof(double)));
217
+ case OP_COPY_CC: VEC_ARG1(memcpy(&cr_dest, s1, sizeof(double)*2));
218
+
219
+ /* Bool */
220
+ case OP_INVERT_BB: VEC_ARG1(b_dest = !b1);
221
+ case OP_AND_BBB: VEC_ARG2(b_dest = (b1 && b2));
222
+ case OP_OR_BBB: VEC_ARG2(b_dest = (b1 || b2));
223
+ case OP_XOR_BBB: VEC_ARG2(b_dest = (b1 || b2) && !(b1 && b2) );
224
+
225
+ case OP_EQ_BBB: VEC_ARG2(b_dest = (b1 == b2));
226
+ case OP_NE_BBB: VEC_ARG2(b_dest = (b1 != b2));
227
+ case OP_WHERE_BBBB: VEC_ARG3(b_dest = b1 ? b2 : b3);
228
+
229
+ /* Comparisons */
230
+ case OP_GT_BII: VEC_ARG2(b_dest = (i1 > i2));
231
+ case OP_GE_BII: VEC_ARG2(b_dest = (i1 >= i2));
232
+ case OP_EQ_BII: VEC_ARG2(b_dest = (i1 == i2));
233
+ case OP_NE_BII: VEC_ARG2(b_dest = (i1 != i2));
234
+
235
+ case OP_GT_BLL: VEC_ARG2(b_dest = (l1 > l2));
236
+ case OP_GE_BLL: VEC_ARG2(b_dest = (l1 >= l2));
237
+ case OP_EQ_BLL: VEC_ARG2(b_dest = (l1 == l2));
238
+ case OP_NE_BLL: VEC_ARG2(b_dest = (l1 != l2));
239
+
240
+ case OP_GT_BFF: VEC_ARG2(b_dest = (f1 > f2));
241
+ case OP_GE_BFF: VEC_ARG2(b_dest = (f1 >= f2));
242
+ case OP_EQ_BFF: VEC_ARG2(b_dest = (f1 == f2));
243
+ case OP_NE_BFF: VEC_ARG2(b_dest = (f1 != f2));
244
+
245
+ case OP_GT_BDD: VEC_ARG2(b_dest = (d1 > d2));
246
+ case OP_GE_BDD: VEC_ARG2(b_dest = (d1 >= d2));
247
+ case OP_EQ_BDD: VEC_ARG2(b_dest = (d1 == d2));
248
+ case OP_NE_BDD: VEC_ARG2(b_dest = (d1 != d2));
249
+
250
+ case OP_GT_BSS: VEC_ARG2(b_dest = (stringcmp(s1, s2, ss1, ss2) > 0));
251
+ case OP_GE_BSS: VEC_ARG2(b_dest = (stringcmp(s1, s2, ss1, ss2) >= 0));
252
+ case OP_EQ_BSS: VEC_ARG2(b_dest = (stringcmp(s1, s2, ss1, ss2) == 0));
253
+ case OP_NE_BSS: VEC_ARG2(b_dest = (stringcmp(s1, s2, ss1, ss2) != 0));
254
+
255
+ case OP_CONTAINS_BSS: VEC_ARG2(b_dest = stringcontains(s1, s2, ss1, ss2));
256
+
257
+ /* Int */
258
+ case OP_CAST_IB: VEC_ARG1(i_dest = (int)(b1));
259
+ case OP_ONES_LIKE_II: VEC_ARG0(i_dest = 1);
260
+ case OP_NEG_II: VEC_ARG1(i_dest = -i1);
261
+
262
+ case OP_ADD_III: VEC_ARG2(i_dest = i1 + i2);
263
+ case OP_SUB_III: VEC_ARG2(i_dest = i1 - i2);
264
+ case OP_MUL_III: VEC_ARG2(i_dest = i1 * i2);
265
+ case OP_DIV_III: VEC_ARG2(i_dest = i2 ? (i1 / i2) : 0);
266
+ case OP_POW_III: VEC_ARG2(i_dest = (i2 < 0) ? (1 / i1) : (int)pow((double)i1, i2));
267
+ case OP_MOD_III: VEC_ARG2(i_dest = i2 == 0 ? 0 :((i1 % i2) + i2) % i2);
268
+ case OP_FLOORDIV_III: VEC_ARG2(i_dest = i2 ? (i1 / i2) - ((i1 % i2 != 0) && (i1 < 0 != i2 < 0)) : 0);
269
+ case OP_LSHIFT_III: VEC_ARG2(i_dest = (unsigned int)i2 < 32 ? i1 << i2 : 0);
270
+ case OP_RSHIFT_III: VEC_ARG2(i_dest = i1 >> ((unsigned int)i2 < 32 ? i2 : 31));
271
+
272
+ case OP_WHERE_IBII: VEC_ARG3(i_dest = b1 ? i2 : i3);
273
+ //Bitwise ops
274
+ case OP_INVERT_II: VEC_ARG1(i_dest = ~i1);
275
+ case OP_AND_III: VEC_ARG2(i_dest = (i1 & i2));
276
+ case OP_OR_III: VEC_ARG2(i_dest = (i1 | i2));
277
+ case OP_XOR_III: VEC_ARG2(i_dest = (i1 ^ i2));
278
+
279
+ /* Long */
280
+ case OP_CAST_LI: VEC_ARG1(l_dest = (long long)(i1));
281
+ case OP_ONES_LIKE_LL: VEC_ARG0(l_dest = 1);
282
+ case OP_NEG_LL: VEC_ARG1(l_dest = -l1);
283
+
284
+ case OP_ADD_LLL: VEC_ARG2(l_dest = l1 + l2);
285
+ case OP_SUB_LLL: VEC_ARG2(l_dest = l1 - l2);
286
+ case OP_MUL_LLL: VEC_ARG2(l_dest = l1 * l2);
287
+ case OP_DIV_LLL: VEC_ARG2(l_dest = l2 ? (l1 / l2) : 0);
288
+ #if defined _MSC_VER && _MSC_VER < 1800
289
+ case OP_POW_LLL: VEC_ARG2(l_dest = (l2 < 0) ? (1 / l1) : (long long)pow((long double)l1, (long double)l2));
290
+ #else
291
+ case OP_POW_LLL: VEC_ARG2(l_dest = (l2 < 0) ? (1 / l1) : (long long)llround(pow((long double)l1, (long double)l2)));
292
+ #endif
293
+ case OP_MOD_LLL: VEC_ARG2(l_dest = l2 == 0 ? 0 :((l1 % l2) + l2) % l2);
294
+ case OP_FLOORDIV_LLL: VEC_ARG2(l_dest = l2 ? (l1 / l2) - ((l1 % l2 != 0) && (l1 < 0 != l2 < 0)): 0);
295
+ case OP_LSHIFT_LLL: VEC_ARG2(l_dest = (unsigned long long)l2 < 64 ? l1 << l2 : 0);
296
+ case OP_RSHIFT_LLL: VEC_ARG2(l_dest = l1 >> ((unsigned long long)l2 < 64 ? l2 : 63));
297
+
298
+ case OP_WHERE_LBLL: VEC_ARG3(l_dest = b1 ? l2 : l3);
299
+ //Bitwise ops
300
+ case OP_INVERT_LL: VEC_ARG1(l_dest = ~l1);
301
+ case OP_AND_LLL: VEC_ARG2(l_dest = (l1 & l2));
302
+ case OP_OR_LLL: VEC_ARG2(l_dest = (l1 | l2));
303
+ case OP_XOR_LLL: VEC_ARG2(l_dest = (l1 ^ l2));
304
+
305
+ /* Float */
306
+ case OP_CAST_FI: VEC_ARG1(f_dest = (float)(i1));
307
+ case OP_CAST_FL: VEC_ARG1(f_dest = (float)(l1));
308
+ case OP_ONES_LIKE_FF: VEC_ARG0(f_dest = 1.0);
309
+ case OP_NEG_FF: VEC_ARG1(f_dest = -f1);
310
+
311
+ case OP_ADD_FFF: VEC_ARG2(f_dest = f1 + f2);
312
+ case OP_SUB_FFF: VEC_ARG2(f_dest = f1 - f2);
313
+ case OP_MUL_FFF: VEC_ARG2(f_dest = f1 * f2);
314
+ case OP_DIV_FFF:
315
+ #ifdef USE_VML
316
+ VEC_ARG2_VML(vsDiv(BLOCK_SIZE,
317
+ (float*)x1, (float*)x2, (float*)dest));
318
+ #else
319
+ VEC_ARG2(f_dest = f1 / f2);
320
+ #endif
321
+ case OP_POW_FFF:
322
+ #ifdef USE_VML
323
+ VEC_ARG2_VML(vsPow(BLOCK_SIZE,
324
+ (float*)x1, (float*)x2, (float*)dest));
325
+ #else
326
+ VEC_ARG2(f_dest = powf(f1, f2));
327
+ #endif
328
+ case OP_MOD_FFF: VEC_ARG2(f_dest = f1 - floorf(f1/f2) * f2);
329
+ case OP_FLOORDIV_FFF: VEC_ARG2(f_dest = floorf(f1/f2));
330
+
331
+ case OP_SQRT_FF:
332
+ #ifdef USE_VML
333
+ VEC_ARG1_VML(vsSqrt(BLOCK_SIZE, (float*)x1, (float*)dest));
334
+ #else
335
+ VEC_ARG1(f_dest = sqrtf(f1));
336
+ #endif
337
+
338
+ case OP_WHERE_FBFF: VEC_ARG3(f_dest = b1 ? f2 : f3);
339
+
340
+ case OP_FUNC_FFN:
341
+ #ifdef USE_VML
342
+ VEC_ARG1_VML(functions_ff_vml[arg2](BLOCK_SIZE,
343
+ (float*)x1, (float*)dest));
344
+ #else
345
+ VEC_ARG1(f_dest = functions_ff[arg2](f1));
346
+ #endif
347
+ case OP_FUNC_FFFN:
348
+ #ifdef USE_VML
349
+ VEC_ARG2_VML(functions_fff_vml[arg3](BLOCK_SIZE,
350
+ (float*)x1, (float*)x2,
351
+ (float*)dest));
352
+ #else
353
+ VEC_ARG2(f_dest = functions_fff[arg3](f1, f2));
354
+ #endif
355
+
356
+ /* Double */
357
+ case OP_CAST_DI: VEC_ARG1(d_dest = (double)(i1));
358
+ case OP_CAST_DL: VEC_ARG1(d_dest = (double)(l1));
359
+ case OP_CAST_DF: VEC_ARG1(d_dest = (double)(f1));
360
+ case OP_ONES_LIKE_DD: VEC_ARG0(d_dest = 1.0);
361
+ case OP_NEG_DD: VEC_ARG1(d_dest = -d1);
362
+
363
+ case OP_ADD_DDD: VEC_ARG2(d_dest = d1 + d2);
364
+ case OP_SUB_DDD: VEC_ARG2(d_dest = d1 - d2);
365
+ case OP_MUL_DDD: VEC_ARG2(d_dest = d1 * d2);
366
+ case OP_DIV_DDD:
367
+ #ifdef USE_VML
368
+ VEC_ARG2_VML(vdDiv(BLOCK_SIZE,
369
+ (double*)x1, (double*)x2, (double*)dest));
370
+ #else
371
+ VEC_ARG2(d_dest = d1 / d2);
372
+ #endif
373
+ case OP_POW_DDD:
374
+ #ifdef USE_VML
375
+ VEC_ARG2_VML(vdPow(BLOCK_SIZE,
376
+ (double*)x1, (double*)x2, (double*)dest));
377
+ #else
378
+ VEC_ARG2(d_dest = pow(d1, d2));
379
+ #endif
380
+ case OP_MOD_DDD: VEC_ARG2(d_dest = d1 - floor(d1/d2) * d2);
381
+ case OP_FLOORDIV_DDD: VEC_ARG2(d_dest = floor(d1/d2));
382
+
383
+ case OP_SQRT_DD:
384
+ #ifdef USE_VML
385
+ VEC_ARG1_VML(vdSqrt(BLOCK_SIZE, (double*)x1, (double*)dest));
386
+ #else
387
+ VEC_ARG1(d_dest = sqrt(d1));
388
+ #endif
389
+
390
+ case OP_WHERE_DBDD: VEC_ARG3(d_dest = b1 ? d2 : d3);
391
+
392
+ case OP_FUNC_DDN:
393
+ #ifdef USE_VML
394
+ VEC_ARG1_VML(functions_dd_vml[arg2](BLOCK_SIZE,
395
+ (double*)x1, (double*)dest));
396
+ #else
397
+ VEC_ARG1(d_dest = functions_dd[arg2](d1));
398
+ #endif
399
+ case OP_FUNC_DDDN:
400
+ #ifdef USE_VML
401
+ VEC_ARG2_VML(functions_ddd_vml[arg3](BLOCK_SIZE,
402
+ (double*)x1, (double*)x2,
403
+ (double*)dest));
404
+ #else
405
+ VEC_ARG2(d_dest = functions_ddd[arg3](d1, d2));
406
+ #endif
407
+
408
+ /* Complex */
409
+ case OP_CAST_CI: VEC_ARG1(cr_dest = (double)(i1);
410
+ ci_dest = 0);
411
+ case OP_CAST_CL: VEC_ARG1(cr_dest = (double)(l1);
412
+ ci_dest = 0);
413
+ case OP_CAST_CF: VEC_ARG1(cr_dest = f1;
414
+ ci_dest = 0);
415
+ case OP_CAST_CD: VEC_ARG1(cr_dest = d1;
416
+ ci_dest = 0);
417
+ case OP_ONES_LIKE_CC: VEC_ARG0(cr_dest = 1;
418
+ ci_dest = 0);
419
+ case OP_NEG_CC: VEC_ARG1(cr_dest = -c1r;
420
+ ci_dest = -c1i);
421
+
422
+ case OP_ADD_CCC: VEC_ARG2(cr_dest = c1r + c2r;
423
+ ci_dest = c1i + c2i);
424
+ case OP_SUB_CCC: VEC_ARG2(cr_dest = c1r - c2r;
425
+ ci_dest = c1i - c2i);
426
+ case OP_MUL_CCC: VEC_ARG2(da = c1r*c2r - c1i*c2i;
427
+ ci_dest = c1r*c2i + c1i*c2r;
428
+ cr_dest = da);
429
+ case OP_DIV_CCC:
430
+ #ifdef USE_VMLXXX /* VML complex division is slower */
431
+ VEC_ARG2_VML(vzDiv(BLOCK_SIZE, (const MKL_Complex16*)x1,
432
+ (const MKL_Complex16*)x2, (MKL_Complex16*)dest));
433
+ #else
434
+ VEC_ARG2(da = c2r*c2r + c2i*c2i;
435
+ db = (c1r*c2r + c1i*c2i) / da;
436
+ ci_dest = (c1i*c2r - c1r*c2i) / da;
437
+ cr_dest = db);
438
+ #endif
439
+ case OP_EQ_BCC: VEC_ARG2(b_dest = (c1r == c2r && c1i == c2i));
440
+ case OP_NE_BCC: VEC_ARG2(b_dest = (c1r != c2r || c1i != c2i));
441
+
442
+ case OP_WHERE_CBCC: VEC_ARG3(cr_dest = b1 ? c2r : c3r;
443
+ ci_dest = b1 ? c2i : c3i);
444
+ case OP_FUNC_CCN:
445
+ #ifdef USE_VML
446
+ VEC_ARG1_VML(functions_cc_vml[arg2](BLOCK_SIZE,
447
+ (const MKL_Complex16*)x1,
448
+ (MKL_Complex16*)dest));
449
+ #else
450
+ VEC_ARG1(ca.real(c1r);
451
+ ca.imag(c1i);
452
+ functions_cc[arg2](&ca, &ca);
453
+ cr_dest = ca.real();
454
+ ci_dest = ca.imag());
455
+ #endif
456
+ case OP_FUNC_CCCN: VEC_ARG2(ca.real(c1r);
457
+ ca.imag(c1i);
458
+ cb.real(c2r);
459
+ cb.imag(c2i);
460
+ functions_ccc[arg3](&ca, &cb, &ca);
461
+ cr_dest = ca.real();
462
+ ci_dest = ca.imag());
463
+
464
+ case OP_REAL_DC: VEC_ARG1(d_dest = c1r);
465
+ case OP_IMAG_DC: VEC_ARG1(d_dest = c1i);
466
+ case OP_COMPLEX_CDD: VEC_ARG2(cr_dest = d1;
467
+ ci_dest = d2);
468
+
469
+ // Boolean return types
470
+ case OP_FUNC_BFN:
471
+ #ifdef USE_VML
472
+ VEC_ARG1_VML(functions_bf_vml[arg2](BLOCK_SIZE,
473
+ (float*)x1, (bool*)dest));
474
+ #else
475
+ VEC_ARG1(b_dest = functions_bf[arg2](f1));
476
+ #endif
477
+
478
+
479
+ case OP_FUNC_BDN:
480
+ #ifdef USE_VML
481
+ VEC_ARG1_VML(functions_bd_vml[arg2](BLOCK_SIZE,
482
+ (double*)x1, (bool*)dest));
483
+ #else
484
+ VEC_ARG1(b_dest = functions_bd[arg2](d1));
485
+ #endif
486
+
487
+ case OP_FUNC_BCN:
488
+ #ifdef USE_VML
489
+ VEC_ARG1_VML(functions_bc_vml[arg2](BLOCK_SIZE,
490
+ (const MKL_Complex16*)x1, (bool*)dest));
491
+ #else
492
+ VEC_ARG1(ca.real(c1r);
493
+ ca.imag(c1i);
494
+ b_dest = functions_bc[arg2](&ca));
495
+ #endif
496
+
497
+ /* Integer return types */
498
+ case OP_FUNC_IIN:
499
+ #ifdef USE_VML
500
+ VEC_ARG1_VML(functions_ii_vml[arg2](BLOCK_SIZE,
501
+ (int*)x1, (int*)dest));
502
+ #else
503
+ VEC_ARG1(i_dest = functions_ii[arg2](i1));
504
+ #endif
505
+ case OP_FUNC_LLN:
506
+ #ifdef USE_VML
507
+ VEC_ARG1_VML(functions_ll_vml[arg2](BLOCK_SIZE,
508
+ (long*)x1, (long*)dest));
509
+ #else
510
+ VEC_ARG1(l_dest = functions_ll[arg2](l1));
511
+ #endif
512
+
513
+ /* Reductions */
514
+ case OP_SUM_IIN: VEC_ARG1(i_reduce += i1);
515
+ case OP_SUM_LLN: VEC_ARG1(l_reduce += l1);
516
+ case OP_SUM_FFN: VEC_ARG1(f_reduce += f1);
517
+ case OP_SUM_DDN: VEC_ARG1(d_reduce += d1);
518
+ case OP_SUM_CCN: VEC_ARG1(cr_reduce += c1r;
519
+ ci_reduce += c1i);
520
+
521
+ case OP_PROD_IIN: VEC_ARG1(i_reduce *= i1);
522
+ case OP_PROD_LLN: VEC_ARG1(l_reduce *= l1);
523
+ case OP_PROD_FFN: VEC_ARG1(f_reduce *= f1);
524
+ case OP_PROD_DDN: VEC_ARG1(d_reduce *= d1);
525
+ case OP_PROD_CCN: VEC_ARG1(da = cr_reduce*c1r - ci_reduce*c1i;
526
+ ci_reduce = cr_reduce*c1i + ci_reduce*c1r;
527
+ cr_reduce = da);
528
+
529
+ case OP_MIN_IIN: VEC_ARG1(i_reduce = fmin(i_reduce, i1));
530
+ case OP_MIN_LLN: VEC_ARG1(l_reduce = fmin(l_reduce, l1));
531
+ case OP_MIN_FFN: VEC_ARG1(f_reduce = fmin(f_reduce, f1));
532
+ case OP_MIN_DDN: VEC_ARG1(d_reduce = fmin(d_reduce, d1));
533
+
534
+ case OP_MAX_IIN: VEC_ARG1(i_reduce = fmax(i_reduce, i1));
535
+ case OP_MAX_LLN: VEC_ARG1(l_reduce = fmax(l_reduce, l1));
536
+ case OP_MAX_FFN: VEC_ARG1(f_reduce = fmax(f_reduce, f1));
537
+ case OP_MAX_DDN: VEC_ARG1(d_reduce = fmax(d_reduce, d1));
538
+
539
+ default:
540
+ *pc_error = pc;
541
+ return -3;
542
+ break;
543
+ }
544
+ }
545
+
546
+ #ifndef NO_OUTPUT_BUFFERING
547
+ // If output buffering was necessary, copy the buffer to the output
548
+ if(params.out_buffer != NULL) {
549
+ memcpy(iter_dataptr[0], params.out_buffer, params.memsizes[0] * BLOCK_SIZE);
550
+ }
551
+ #endif // NO_OUTPUT_BUFFERING
552
+
553
+ #undef VEC_LOOP
554
+ #undef VEC_ARG1
555
+ #undef VEC_ARG2
556
+ #undef VEC_ARG3
557
+
558
+ #undef i_reduce
559
+ #undef l_reduce
560
+ #undef f_reduce
561
+ #undef d_reduce
562
+ #undef cr_reduce
563
+ #undef ci_reduce
564
+ #undef b_dest
565
+ #undef i_dest
566
+ #undef l_dest
567
+ #undef f_dest
568
+ #undef d_dest
569
+ #undef cr_dest
570
+ #undef ci_dest
571
+ #undef s_dest
572
+ #undef b1
573
+ #undef i1
574
+ #undef l1
575
+ #undef f1
576
+ #undef d1
577
+ #undef c1r
578
+ #undef c1i
579
+ #undef s1
580
+ #undef b2
581
+ #undef i2
582
+ #undef l2
583
+ #undef f2
584
+ #undef d2
585
+ #undef c2r
586
+ #undef c2i
587
+ #undef s2
588
+ #undef b3
589
+ #undef i3
590
+ #undef l3
591
+ #undef f3
592
+ #undef d3
593
+ #undef c3r
594
+ #undef c3i
595
+ #undef s3
596
+ }
597
+
598
+ /*
599
+ Local Variables:
600
+ c-basic-offset: 4
601
+ End:
602
+ */
Binary file