1 /* OpenACC parallelism dimensions clauses: num_gangs, num_workers,
2    vector_length.  */
3 
4 /* Copied from '../libgomp.oacc-c-c++-common/parallel-dims.c'.  */
5 
6 /* Used by 'parallel-dims.f90'.  */
7 
8 #include <limits.h>
9 #include <openacc.h>
10 #include <gomp-constants.h>
11 
12 /* TODO: "(int) acc_device_*" casts because of the C++ acc_on_device wrapper
13    not behaving as expected for -O0.  */
14 #pragma acc routine seq
acc_gang()15 /* static */ unsigned int __attribute__ ((optimize ("O2"))) acc_gang ()
16 {
17   if (acc_on_device ((int) acc_device_host))
18     return 0;
19   else if (acc_on_device ((int) acc_device_nvidia))
20     return __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
21   else
22     __builtin_abort ();
23 }
24 
25 #pragma acc routine seq
acc_worker()26 /* static */ unsigned int __attribute__ ((optimize ("O2"))) acc_worker ()
27 {
28   if (acc_on_device ((int) acc_device_host))
29     return 0;
30   else if (acc_on_device ((int) acc_device_nvidia))
31     return __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
32   else
33     __builtin_abort ();
34 }
35 
36 #pragma acc routine seq
acc_vector()37 /* static */ unsigned int __attribute__ ((optimize ("O2"))) acc_vector ()
38 {
39   if (acc_on_device ((int) acc_device_host))
40     return 0;
41   else if (acc_on_device ((int) acc_device_nvidia))
42     return __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
43   else
44     __builtin_abort ();
45 }
46