Files
clang-p2996/openmp/libomptarget/test/api/omp_device_memory.c
Joseph Huber f8b1f93f26 [libomptarget] Enable the device allocator for AMDGPU
This patch adds support for the device memory type, this is currently equivalent
to the default type so it should be treated as the same.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D133128
2022-09-01 12:40:59 -05:00

28 lines
600 B
C

// RUN: %libomptarget-compile-run-and-check-generic
#include <omp.h>
#include <stdio.h>
int main() {
const int N = 64;
int *device_ptr =
omp_alloc(N * sizeof(int), llvm_omp_target_device_mem_alloc);
#pragma omp target teams distribute parallel for is_device_ptr(device_ptr)
for (int i = 0; i < N; ++i) {
device_ptr[i] = 1;
}
int sum = 0;
#pragma omp target reduction(+ : sum) is_device_ptr(device_ptr)
for (int i = 0; i < N; ++i)
sum += device_ptr[i];
// CHECK: PASS
if (sum == N)
printf("PASS\n");
omp_free(device_ptr, llvm_omp_target_device_mem_alloc);
}