| 1 |
#ifndef REDUCTION_H |
| 2 |
#define REDUCTION_H |
| 3 |
|
| 4 |
#define DO_PRAGMA(x) _Pragma (#x) |
| 5 |
|
| 6 |
#define check_reduction_op(type, op, init, b, gwv_par, gwv_loop) \ |
| 7 |
{ \ |
| 8 |
type res, vres; \ |
| 9 |
res = (init); \ |
| 10 |
DO_PRAGMA (acc parallel gwv_par copy (res)) \ |
| 11 |
DO_PRAGMA (acc loop gwv_loop reduction (op:res)) \ |
| 12 |
for (i = 0; i < n; i++) \ |
| 13 |
res = res op (b); \ |
| 14 |
\ |
| 15 |
vres = (init); \ |
| 16 |
for (i = 0; i < n; i++) \ |
| 17 |
vres = vres op (b); \ |
| 18 |
\ |
| 19 |
if (res != vres) \ |
| 20 |
abort (); \ |
| 21 |
} |
| 22 |
|
| 23 |
#define check_reduction_macro(type, op, init, b, gwv_par, gwv_loop) \ |
| 24 |
{ \ |
| 25 |
type res, vres; \ |
| 26 |
res = (init); \ |
| 27 |
DO_PRAGMA (acc parallel gwv_par copy(res)) \ |
| 28 |
DO_PRAGMA (acc loop gwv_loop reduction (op:res)) \ |
| 29 |
for (i = 0; i < n; i++) \ |
| 30 |
res = op (res, (b)); \ |
| 31 |
\ |
| 32 |
vres = (init); \ |
| 33 |
for (i = 0; i < n; i++) \ |
| 34 |
vres = op (vres, (b)); \ |
| 35 |
\ |
| 36 |
if (res != vres) \ |
| 37 |
abort (); \ |
| 38 |
} |
| 39 |
|
| 40 |
#define max(a, b) (((a) > (b)) ? (a) : (b)) |
| 41 |
#define min(a, b) (((a) < (b)) ? (a) : (b)) |
| 42 |
|
| 43 |
#endif |