| 1 | // clang-format off |
| 2 | // RUN: %libomptarget-compilexx-generic && %libomptarget-run-generic 2>&1 | %fcheck-generic |
| 3 | // clang-format on |
| 4 | |
| 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 |
| 11 | |
| 12 | // REQUIRES: amdgcn-amd-amdhsa |
| 13 | |
| 14 | #include <omp.h> |
| 15 | #include <stdio.h> |
| 16 | |
| 17 | #define N 100 |
| 18 | |
| 19 | bool schedule(int lb, int ub, int stride, int chunk) { |
| 20 | int i; |
| 21 | |
| 22 | int result[N]; |
| 23 | for (i = 0; i < N; i++) { |
| 24 | result[i] = 0; |
| 25 | } |
| 26 | |
| 27 | #pragma omp target map(tofrom : result[ : N]) |
| 28 | { |
| 29 | int a = 0; |
| 30 | #pragma omp parallel for schedule(dynamic, chunk) |
| 31 | for (i = lb; i < ub; i += stride) { |
| 32 | result[i] += i + a; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | int value = 0; |
| 37 | bool success = true; |
| 38 | for (i = 0; i < N; i += stride) { |
| 39 | if (value != result[i]) { |
| 40 | printf(format: "ERROR: result[%d] = %d instead of %d\n" , i, result[i], value); |
| 41 | success = false; |
| 42 | break; |
| 43 | } |
| 44 | value += stride; |
| 45 | } |
| 46 | |
| 47 | return success; |
| 48 | } |
| 49 | |
| 50 | int main() { |
| 51 | // CHECK: SUCCESS CHUNK SIZE 1 |
| 52 | if (schedule(lb: 0, N, stride: 5, chunk: 1)) |
| 53 | printf(format: "SUCCESS CHUNK SIZE 1\n" ); |
| 54 | |
| 55 | // CHECK: SUCCESS CHUNK SIZE 3 |
| 56 | if (schedule(lb: 0, N, stride: 5, chunk: 3)) |
| 57 | printf(format: "SUCCESS CHUNK SIZE 3\n" ); |
| 58 | |
| 59 | return 0; |
| 60 | } |
| 61 | |