brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · b30ce12 Raw
39 lines · c
1// clang-format off2// RUN: %libomptarget-compileopt-generic3// RUN: %not --crash env -u LLVM_DISABLE_SYMBOLIZATION %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefixes=CHECK,NTRCE4// RUN: %libomptarget-compileopt-generic5// RUN: %not --crash env -u LLVM_DISABLE_SYMBOLIZATION OFFLOAD_TRACK_ALLOCATION_TRACES=1 %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefixes=CHECK,TRACE6// clang-format on7 8// FIXME: https://github.com/llvm/llvm-project/issues/1612659// UNSUPPORTED: nvidiagpu10//11// REQUIRES: gpu12 13#include <omp.h>14 15void *llvm_omp_target_alloc_host(size_t Size, int DeviceNum);16void llvm_omp_target_free_host(void *Ptr, int DeviceNum);17 18int main() {19  int N = (1 << 30);20  char *A = (char *)llvm_omp_target_alloc_host(N, omp_get_default_device());21  char *P;22#pragma omp target map(from : P)23  {24    P = &A[0];25    *P = 3;26  }27  // clang-format off28// CHECK: OFFLOAD ERROR: memory access fault by GPU {{.*}} (agent 0x{{.*}}) at virtual address [[PTR:0x[0-9a-z]*]]. Reasons: {{.*}}29// NTRCE: Use 'OFFLOAD_TRACK_ALLOCATION_TRACES=true' to track device allocations30// TRACE: Device pointer [[PTR]] does not point into any (current or prior) host-issued allocation.31// TRACE: Closest host-issued allocation (distance 4096 bytes; might be by page):32// TRACE: Last allocation of size 107374182433// clang-format on34#pragma omp target35  { P[-4] = 5; }36 37  llvm_omp_target_free_host(A, omp_get_default_device());38}39