1// RUN: %libomptarget-compile-run-and-check-generic
2
3#include <omp.h>
4#include <stdio.h>
5
6int test_omp_get_device_num() {
7 /* checks that omp_get_device_num() == omp_get_num_devices() in the host */
8 int device_num = omp_get_device_num();
9 printf(format: "device_num = %d\n", device_num);
10
11#pragma omp target
12 {}
13
14 return (device_num == omp_get_num_devices());
15}
16
17int main() {
18 int i;
19 int failed = 0;
20
21 if (!test_omp_get_device_num()) {
22 failed++;
23 }
24 if (failed)
25 printf(format: "FAIL\n");
26 else
27 printf(format: "PASS\n");
28 return failed;
29}
30
31// CHECK: PASS
32

source code of offload/test/api/omp_get_device_num.c