Files
clang-p2996/openmp/libomptarget/test/libc/malloc.c
Joseph Huber 183a1b1e38 [OpenMP] Enable the 'libc/malloc.c' test on NVPTX
Summary:
Previously this test hanged indefinitely on NVPTX. This was due to an
issue fixed previously where we would wait indefinitely inside the CUDA
runtime waiting for the kernel to complete if it was blocked on the RPC
server. This patch enables this test again now that it can run without
deadlocking, at least on CUDA 12.2.
2023-09-28 14:41:35 -05:00

30 lines
520 B
C

// RUN: %libomptarget-compile-run-and-check-generic
// REQUIRES: libc
#include <stdio.h>
#include <stdlib.h>
#pragma omp declare target to(malloc)
#pragma omp declare target to(free)
int main() {
unsigned h_x;
unsigned *d_x;
#pragma omp target map(from : d_x)
{
d_x = malloc(sizeof(unsigned));
*d_x = 1;
}
#pragma omp target is_device_ptr(d_x) map(from : h_x)
{ h_x = *d_x; }
#pragma omp target is_device_ptr(d_x)
{ free(d_x); }
// CHECK: PASS
if (h_x == 1)
fputs("PASS\n", stdout);
}