Bump version to 19.1.0-rc3
[llvm-project.git] / offload / test / api / omp_device_memory.c
blob60f47e94f90dbea17440dd4989f6aef44a58a49f
1 // RUN: %libomptarget-compile-run-and-check-generic
3 #include <omp.h>
4 #include <stdio.h>
6 int main() {
7 const int N = 64;
9 int *device_ptr =
10 omp_alloc(N * sizeof(int), llvm_omp_target_device_mem_alloc);
12 #pragma omp target teams distribute parallel for is_device_ptr(device_ptr)
13 for (int i = 0; i < N; ++i) {
14 device_ptr[i] = 1;
17 int sum = 0;
18 #pragma omp target parallel for reduction(+ : sum) is_device_ptr(device_ptr)
19 for (int i = 0; i < N; ++i)
20 sum += device_ptr[i];
22 // CHECK: PASS
23 if (sum == N)
24 printf("PASS\n");
26 omp_free(device_ptr, llvm_omp_target_device_mem_alloc);