[Openmp-commits] [openmp] aa32655 - [OpenMP][libomptarget] Init device when printing device info

Kevin Sala via Openmp-commits openmp-commits at lists.llvm.org
Tue May 9 09:50:17 PDT 2023


Author: Kevin Sala
Date: 2023-05-09T18:47:46+02:00
New Revision: aa326559c443382030c735db167645685da245a2

URL: https://github.com/llvm/llvm-project/commit/aa326559c443382030c735db167645685da245a2
DIFF: https://github.com/llvm/llvm-project/commit/aa326559c443382030c735db167645685da245a2.diff

LOG: [OpenMP][libomptarget] Init device when printing device info

This patch fixes the printing of device information. Devices are initialized
before printing its information. Fixes #61392

Differential Revision: https://reviews.llvm.org/D146081

Added: 
    

Modified: 
    openmp/libomptarget/src/interface.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/src/interface.cpp b/openmp/libomptarget/src/interface.cpp
index b155d09dcf8c..6f9c63ab941e 100644
--- a/openmp/libomptarget/src/interface.cpp
+++ b/openmp/libomptarget/src/interface.cpp
@@ -384,6 +384,12 @@ EXTERN void __tgt_set_info_flag(uint32_t NewInfoLevel) {
 }
 
 EXTERN int __tgt_print_device_info(int64_t DeviceId) {
+  // Make sure the device is ready.
+  if (!deviceIsReady(DeviceId)) {
+    DP("Device %" PRId64 " is not ready\n", DeviceId);
+    return OMP_TGT_FAIL;
+  }
+
   return PM->Devices[DeviceId]->printDeviceInfo(
       PM->Devices[DeviceId]->RTLDeviceID);
 }


        


More information about the Openmp-commits mailing list