aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.oacc-c-c++-common/reduction.h
blob: 1b3f8d45ace50d40d035c026b891644c41f43b77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef REDUCTION_H
#define REDUCTION_H

#define DO_PRAGMA(x) _Pragma (#x)

#define check_reduction_op(type, op, init, b, gwv_par, gwv_loop)	\
  {									\
    type res, vres;							\
    res = (init);							\
DO_PRAGMA (acc parallel gwv_par copy (res))				\
DO_PRAGMA (acc loop gwv_loop reduction (op:res))			\
    for (i = 0; i < n; i++)						\
      res = res op (b);							\
									\
    vres = (init);							\
    for (i = 0; i < n; i++)						\
      vres = vres op (b);						\
									\
    if (res != vres)							\
      abort ();								\
  }

#define check_reduction_macro(type, op, init, b, gwv_par, gwv_loop)	\
  {									\
    type res, vres;							\
    res = (init);							\
    DO_PRAGMA (acc parallel gwv_par copy(res))				\
DO_PRAGMA (acc loop gwv_loop reduction (op:res))			\
    for (i = 0; i < n; i++)						\
      res = op (res, (b));						\
									\
    vres = (init);							\
    for (i = 0; i < n; i++)						\
      vres = op (vres, (b));						\
									\
    if (res != vres)							\
      abort ();								\
  }

#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

#endif