21 lines · cpp
1// RUN: %libomptarget-compilexx-run-and-check-generic2 3#include <omp.h>4#include <stdio.h>5 6int main(void) {7 int isHost = 0;8 9#pragma omp target map(from : isHost)10 { isHost = omp_is_initial_device(); }11 12 if (isHost < 0) {13 printf("Runtime error, isHost=%d\n", isHost);14 }15 16 // CHECK: Target region executed on the device17 printf("Target region executed on the %s\n", isHost ? "host" : "device");18 19 return isHost;20}21