llvm-c166/offload/test/offloading/force-usm.cpp
Ivan R. Ivanov 58f386207a
[offload] Remove omptarget references from tests (#208205)
Make check lines more generic so that we can move and rename components
without breaking the tests

This is in preparation for splitting off parts of libomptarget into
libompaccsupport, which will be used by both OpenACC and OpenMP. Some
debug prints will be printed from `ompaccsupport` and not `omptarget`,
thus the need for this change.
2026-08-03 16:55:38 +02:00

62 lines
1.8 KiB
C++

// clang-format off
// RUN: %libomptarget-compilexx-generic
// RUN: env LIBOMPTARGET_INFO=32 %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefix=NO-USM
//
// RUN: %libomptarget-compilexxx-generic-force-usm
// RUN: env HSA_XNACK=1 LIBOMPTARGET_INFO=32 \
// RUN: %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefix=FORCE-USM
//
// REQUIRES: unified_shared_memory
//
// UNSUPPORTED: nvptx64-nvidia-cuda
// UNSUPPORTED: nvptx64-nvidia-cuda-LTO
// UNSUPPORTED: intelgpu
// clang-format on
#include <cassert>
#include <cstdio>
#include <cstdlib>
int GI;
#pragma omp declare target
int *pGI;
#pragma omp end declare target
int main(void) {
GI = 0;
// Implicit mappings
int alpha = 1;
int beta[3] = {2, 5, 8};
// Require map clauses for non-USM execution
pGI = (int *)malloc(sizeof(int));
*pGI = 42;
#pragma omp target map(pGI[ : 1], GI)
{
GI = 1 * alpha;
*pGI = 2 * beta[1];
}
assert(GI == 1);
assert(*pGI == 10);
printf("SUCCESS\n");
return 0;
}
// clang-format off
// NO-USM: device 0 info: Copying data from host to device, HstPtr={{.*}}, TgtPtr={{.*}}, Size=4
// NO-USM: device 0 info: Copying data from host to device, HstPtr={{.*}}, TgtPtr={{.*}}, Size=12
// NO-USM-NEXT: device 0 info: Copying data from host to device, HstPtr={{.*}}, TgtPtr={{.*}}, Size=4
// NO-USM-NEXT: device 0 info: Copying data from host to device, HstPtr={{.*}}, TgtPtr={{.*}}, Size=8, Name=pGI
// NO-USM-NEXT: device 0 info: Copying data from device to host, TgtPtr={{.*}}, HstPtr={{.*}}, Size=4
// NO-USM-NEXT: device 0 info: Copying data from device to host, TgtPtr={{.*}}, HstPtr={{.*}}, Size=12
// NO-USM-NEXT: device 0 info: Copying data from device to host, TgtPtr={{.*}}, HstPtr={{.*}}, Size=4
// NO-USM-NEXT: SUCCESS
// FORCE-USM: SUCCESS
//
// clang-format on