| 1 | //===- llvm-offload-device-info.cpp - Device info as seen by LLVM/Offload -===// |
| 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 LLVM/Offload, and the device |
| 10 | // plugins, list devices information as seen by the runtime. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "omptarget.h" |
| 15 | #include <cstdio> |
| 16 | |
| 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 | printf("Found %d devices:\n" , omp_get_num_devices()); |
| 23 | for (int Dev = 0; Dev < omp_get_num_devices(); Dev++) { |
| 24 | printf(format: " Device %d:\n" , Dev); |
| 25 | if (!__tgt_print_device_info(Dev)) |
| 26 | printf(format: " print_device_info not implemented\n" ); |
| 27 | printf(format: "\n" ); |
| 28 | } |
| 29 | |
| 30 | __tgt_unregister_lib(&EmptyDesc); |
| 31 | return 0; |
| 32 | } |
| 33 | |