[flang][cuda] Do not register global constants (#118582)
[llvm-project.git] / offload / test / offloading / dynamic-schedule.cpp
blob6d68982686a83ad16e9d45b6bf3842e9565f9d4c
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-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
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 parallel for schedule(dynamic, chunk) \
28 map(tofrom : result[ : N])
29 for (i = lb; i < ub; i += stride) {
30 result[i] += i;
33 int value = 0;
34 bool success = true;
35 for (i = 0; i < N; i += stride) {
36 if (value != result[i]) {
37 printf("ERROR: result[%d] = %d instead of %d\n", i, result[i], value);
38 success = false;
39 break;
41 value += stride;
44 return success;
47 int main() {
48 // CHECK: SUCCESS CHUNK SIZE 1
49 if (schedule(0, N, 5, 1))
50 printf("SUCCESS CHUNK SIZE 1\n");
52 // CHECK: SUCCESS CHUNK SIZE 3
53 if (schedule(0, N, 5, 3))
54 printf("SUCCESS CHUNK SIZE 3\n");
56 return 0;