1 //===- llvm-omp-device-info.cpp - Obtain device info as seen from OpenMP --===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This is a command line utility that, by using Libomptarget, and the device
10 // plugins, list devices information as seen from the OpenMP Runtime.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "omptarget.h"
15 #include <cstdio>
16 
main(int argc,char ** argv)17 int main(int argc, char **argv) {
18   __tgt_bin_desc EmptyDesc = {0, nullptr, nullptr, nullptr};
19   __tgt_register_lib(&EmptyDesc);
20   __tgt_init_all_rtls();
21 
22   for (int Dev = 0; Dev < omp_get_num_devices(); Dev++) {
23     printf("Device (%d):\n", Dev);
24     if (!__tgt_print_device_info(Dev))
25       printf("    print_device_info not implemented\n");
26     printf("\n");
27   }
28 
29   __tgt_unregister_lib(&EmptyDesc);
30   return 0;
31 }
32