Bump version to 19.1.0-rc3
[llvm-project.git] / offload / test / api / omp_device_managed_memory_alloc.c
blobc48866922debafcc0da18b1b95da1f6d8592a154
1 // RUN: %libomptarget-compile-run-and-check-generic
2 // RUN: %libomptarget-compileopt-run-and-check-generic
4 #include <omp.h>
5 #include <stdio.h>
7 int main() {
8 const int N = 64;
10 // Allocates device managed memory that is shared between the host and device.
11 int *shared_ptr =
12 omp_alloc(N * sizeof(int), llvm_omp_target_shared_mem_alloc);
14 #pragma omp target teams distribute parallel for is_device_ptr(shared_ptr)
15 for (int i = 0; i < N; ++i) {
16 shared_ptr[i] = 1;
19 int sum = 0;
20 for (int i = 0; i < N; ++i)
21 sum += shared_ptr[i];
23 // CHECK: PASS
24 if (sum == N)
25 printf("PASS\n");
27 omp_free(shared_ptr, llvm_omp_target_shared_mem_alloc);