Make sure the device is ready and initialized when printing the device information
Fixes #61392
Differential D146081
[OpenMP][libomptarget] Init device when printing device info kevinsala on Mar 14 2023, 12:34 PM. Authored by
Details Make sure the device is ready and initialized when printing the device information Fixes #61392
Diff Detail
Event TimelineComment Actions I also fear this will just make the script not crash but also useless. Comment Actions The initial patch should fix the crash for the llvm-omp-device-info case, or any other case calling __tgt_print_device_info. I saw lazy initialization of devices in other API calls and tried to reproduced the same behavior. Anyway, initializing them explicitly from the tool seems more clean, so I just updated the patch with it. Regarding the usefulness of this tool, it's true that it does not print anything relevant since nextgen plugins are not printing any information for the moment. I'm going to open a new patch to print at least the information reported by old plugins. Comment Actions There is also the option to auto initialize the devices at the plugin level when GenericPluginTy::getDevice(N) is called and device N is in a uninitialized state. In my opinion, that would be the safest option and would cover all cases. But it will require implementing a similar mechanism from libomptarget level to guarantee the device creation and initialization is tread-safe and serialized (i.e., std::call_once in libomptarget).
Comment Actions Updating patch to initial version. We make sure in libomptarget that the device is initialized (ready) when printing its information. Together with https://reviews.llvm.org/D148178, it should fix the llvm-omp-device-info command. |
Isn't this the same code as in __tgt_print_device_info? Why do we need this?