2 // RUN: %libomptarget-compile-generic && %libomptarget-run-generic 2>&1 | %fcheck-generic
5 // UNSUPPORTED: aarch64-unknown-linux-gnu
6 // UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
7 // UNSUPPORTED: x86_64-unknown-linux-gnu
8 // UNSUPPORTED: x86_64-unknown-linux-gnu-LTO
9 // UNSUPPORTED: s390x-ibm-linux-gnu
10 // UNSUPPORTED: s390x-ibm-linux-gnu-LTO
12 // REQUIRES: amdgcn-amd-amdhsa
18 int ordered_example(int lb
, int ub
, int stride
, int nteams
) {
20 int size
= (ub
- lb
) / stride
;
21 double *output
= (double *)malloc(size
* sizeof(double));
23 #pragma omp target teams map(from : output[0 : size]) num_teams(nteams) \
25 #pragma omp parallel for ordered schedule(dynamic)
26 for (i
= lb
; i
< ub
; i
+= stride
) {
28 { output
[(i
- lb
) / stride
] = omp_get_wtime(); }
32 for (int j
= 0; j
< size
; j
++) {
33 for (int jj
= j
+ 1; jj
< size
; jj
++) {
34 if (output
[j
] > output
[jj
]) {
35 printf("Fail to schedule in order.\n");
44 printf("test ordered OK\n");
49 int NO_order_example(int lb
, int ub
, int stride
, int nteams
) {
51 int size
= (ub
- lb
) / stride
;
52 double *output
= (double *)malloc(size
* sizeof(double));
54 #pragma omp target teams map(from : output[0 : size]) num_teams(nteams) \
56 #pragma omp parallel for schedule(dynamic)
57 for (i
= lb
; i
< ub
; i
+= stride
) {
58 output
[(i
- lb
) / stride
] = omp_get_wtime();
62 for (int j
= 0; j
< size
; j
++) {
63 for (int jj
= j
+ 1; jj
< size
; jj
++) {
64 if (output
[j
] > output
[jj
]) {
65 printf("Fail to schedule in order.\n");
74 printf("test no order OK\n");
80 // CHECK: test no order OK
81 NO_order_example(0, 10, 1, 8);
82 // CHECK: test ordered OK
83 return ordered_example(0, 10, 1, 8);