brintos

brintos / llvm-project-archived public Read only

0
0
Text · 612 B · f6016c1 Raw
30 lines · c
1// RUN: %libomptarget-compile-run-and-check-generic2 3#include <omp.h>4#include <stdio.h>5 6#pragma omp declare target7int isHost;8#pragma omp end declare target9 10int main(void) {11  isHost = -1;12 13#pragma omp target enter data map(to : isHost)14 15#pragma omp target16  { isHost = omp_is_initial_device(); }17#pragma omp target update from(isHost)18 19  if (isHost < 0) {20    printf("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 device26  printf("Target region executed on the %s\n", isHost ? "host" : "device");27 28  return isHost;29}30