Bump version to 19.1.0-rc3
[llvm-project.git] / offload / test / offloading / dynamic-schedule-non-spmd.cpp
blobae3a480b0090b4bc7339c193eb8f291e1403a4db
1 // clang-format off
2 // RUN: %libomptarget-compilexx-generic && %libomptarget-run-generic 2>&1 | %fcheck-generic
3 // clang-format on
5 // UNSUPPORTED: aarch64-unknown-linux-gnu
6 // UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
7 // UNSUPPORTED: x86_64-pc-linux-gnu
8 // UNSUPPORTED: x86_64-pc-linux-gnu-LTO
9 // UNSUPPORTED: s390x-ibm-linux-gnu
10 // UNSUPPORTED: s390x-ibm-linux-gnu-LTO
12 // REQUIRES: amdgcn-amd-amdhsa
14 #include <omp.h>
15 #include <stdio.h>
17 #define N 100
19 bool schedule(int lb, int ub, int stride, int chunk) {
20 int i;
22 int result[N];
23 for (i = 0; i < N; i++) {
24 result[i] = 0;
27 #pragma omp target map(tofrom : result[ : N])
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;
36 int value = 0;
37 bool success = true;
38 for (i = 0; i < N; i += stride) {
39 if (value != result[i]) {
40 printf("ERROR: result[%d] = %d instead of %d\n", i, result[i], value);
41 success = false;
42 break;
44 value += stride;
47 return success;
50 int main() {
51 // CHECK: SUCCESS CHUNK SIZE 1
52 if (schedule(0, N, 5, 1))
53 printf("SUCCESS CHUNK SIZE 1\n");
55 // CHECK: SUCCESS CHUNK SIZE 3
56 if (schedule(0, N, 5, 3))
57 printf("SUCCESS CHUNK SIZE 3\n");
59 return 0;