[llvm-branch-commits] [llvm] [openmp] [OpenMP] Implement omp_get_uid_from_device() / omp_get_device_from_uid() (PR #164392)
@@ -91,6 +93,59 @@ EXTERN int omp_get_device_num(void) {
return HostDevice;
}
+EXTERN int omp_get_device_from_uid(const char *DeviceUid) {
+ TIMESCOPE();
+ OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
+
+ if (!DeviceUid) {
+DP("Call to omp_get_device_from_uid returning omp_invalid_device\n");
+return omp_invalid_device;
+ }
+ if (strcmp(DeviceUid, GenericDeviceTy::getHostDeviceUid()) == 0) {
+DP("Call to omp_get_device_from_uid returning host device number %d\n",
+ omp_get_initial_device());
+return omp_get_initial_device();
+ }
+
+ int DeviceNum = omp_invalid_device;
+
+ auto ExclusiveDevicesAccessor = PM->getExclusiveDevicesAccessor();
+ for (const DeviceTy &Device : PM->devices(ExclusiveDevicesAccessor)) {
+const char *Uid = Device.RTL->getDevice(Device.RTLDeviceID).getDeviceUid();
adurang wrote:
In other plugin calls, we're not calling the GerenricDevice methods directly
from libomptarget but some method in GenericPlugin that receives the DeviceId.
Shouldn't be the same here? (and below)
https://github.com/llvm/llvm-project/pull/164392
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [openmp] [OpenMP] Implement omp_get_uid_from_device() / omp_get_device_from_uid() (PR #164392)
https://github.com/adurang edited https://github.com/llvm/llvm-project/pull/164392 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [openmp] [OpenMP] Implement omp_get_uid_from_device() / omp_get_device_from_uid() (PR #164392)
@@ -91,6 +93,59 @@ EXTERN int omp_get_device_num(void) {
return HostDevice;
}
+EXTERN int omp_get_device_from_uid(const char *DeviceUid) {
+ TIMESCOPE();
+ OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
+
+ if (!DeviceUid) {
+DP("Call to omp_get_device_from_uid returning omp_invalid_device\n");
+return omp_invalid_device;
+ }
+ if (strcmp(DeviceUid, GenericDeviceTy::getHostDeviceUid()) == 0) {
+DP("Call to omp_get_device_from_uid returning host device number %d\n",
+ omp_get_initial_device());
+return omp_get_initial_device();
+ }
+
+ int DeviceNum = omp_invalid_device;
+
+ auto ExclusiveDevicesAccessor = PM->getExclusiveDevicesAccessor();
+ for (const DeviceTy &Device : PM->devices(ExclusiveDevicesAccessor)) {
+const char *Uid = Device.RTL->getDevice(Device.RTLDeviceID).getDeviceUid();
adurang wrote:
Sorry, not following your answer here. What I meant is that following what is
done currently elsewhere it should look like:
`const char *Uid = Device.RTL->getDeviceUid(Device.RTLDeviceId);`
I'm not particularly fond of having the extra indirection but we probably
should be consistent? Plus, you could actually handle the special hostId if
you wanted there.
https://github.com/llvm/llvm-project/pull/164392
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
