xref: /llvm-project/offload/test/jit/type_punning.c (revision 8823448807f3b1a1362d1417e062d763734e02f5)
1 // clang-format off
2 //
3 // RUN: %libomptarget-compileopt-generic -fopenmp-target-jit
4 // RUN: env LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE=%t.pre.ll     \
5 // RUN:     LIBOMPTARGET_JIT_SKIP_OPT=true                   \
6 // RUN:     %libomptarget-run-generic
7 // RUN: %fcheck-plain-generic --input-file %t.pre.ll %s
8 //
9 // clang-format on
10 
11 // REQUIRES: gpu
12 
13 // Ensure that there is only the kernel function left, not any outlined
14 // parallel regions.
15 //
16 // CHECK: define
17 // CHECK-NOT: define
18 
19 #include <omp.h>
20 #include <stdio.h>
21 
f(long * A,int N)22 void f(long *A, int N) {
23   long i = 0;
24 #pragma omp target map(A[ : N])
25   {
26 #pragma omp parallel firstprivate(i)
27     A[omp_get_thread_num()] = i;
28 #pragma omp parallel firstprivate(i, N)
29     A[omp_get_thread_num()] += i + N;
30   }
31 }
32 
main()33 int main() {
34   long A[1];
35   f(&A[0], 1);
36   printf("%li\n", A[0]);
37   return 0;
38 }
39