1// RUN: %libomptarget-compile-run-and-check-generic
2
3#include <omp.h>
4#include <stdio.h>
5
6#pragma omp declare target
7int isHost;
8#pragma omp end declare target
9
10int main(void) {
11 isHost = -1;
12
13#pragma omp target enter data map(to : isHost)
14
15#pragma omp target
16 { isHost = omp_is_initial_device(); }
17#pragma omp target update from(isHost)
18
19 if (isHost < 0) {
20 printf(format: "Runtime error, isHost=%d\n", isHost);
21 }
22
23#pragma omp target exit data map(delete : isHost)
24
25 // CHECK: Target region executed on the device
26 printf(format: "Target region executed on the %s\n", isHost ? "host" : "device");
27
28 return isHost;
29}
30

source code of offload/test/mapping/delete_inf_refcount.c