|
28 | 28 |
|
29 | 29 | EXTERN int omp_get_num_devices(void) {
|
30 | 30 | TIMESCOPE();
|
31 |
| - PM->RTLsMtx.lock(); |
32 |
| - size_t DevicesSize = PM->Devices.size(); |
33 |
| - PM->RTLsMtx.unlock(); |
| 31 | + size_t NumDevices = PM->getNumDevices(); |
34 | 32 |
|
35 |
| - DP("Call to omp_get_num_devices returning %zd\n", DevicesSize); |
| 33 | + DP("Call to omp_get_num_devices returning %zd\n", NumDevices); |
36 | 34 |
|
37 |
| - return DevicesSize; |
| 35 | + return NumDevices; |
38 | 36 | }
|
39 | 37 |
|
40 | 38 | EXTERN int omp_get_device_num(void) {
|
@@ -112,10 +110,8 @@ EXTERN int omp_target_is_present(const void *Ptr, int DeviceNum) {
|
112 | 110 | return true;
|
113 | 111 | }
|
114 | 112 |
|
115 |
| - PM->RTLsMtx.lock(); |
116 |
| - size_t DevicesSize = PM->Devices.size(); |
117 |
| - PM->RTLsMtx.unlock(); |
118 |
| - if (DevicesSize <= (size_t)DeviceNum) { |
| 113 | + size_t NumDevices = PM->getNumDevices(); |
| 114 | + if (NumDevices <= (size_t)DeviceNum) { |
119 | 115 | DP("Call to omp_target_is_present with invalid device ID, returning "
|
120 | 116 | "false\n");
|
121 | 117 | return false;
|
@@ -562,18 +558,14 @@ EXTERN void *omp_get_mapped_ptr(const void *Ptr, int DeviceNum) {
|
562 | 558 | return nullptr;
|
563 | 559 | }
|
564 | 560 |
|
565 |
| - if (DeviceNum == omp_get_initial_device()) { |
| 561 | + size_t NumDevices = omp_get_initial_device(); |
| 562 | + if (DeviceNum == NumDevices) { |
566 | 563 | REPORT("Device %d is initial device, returning Ptr " DPxMOD ".\n",
|
567 | 564 | DeviceNum, DPxPTR(Ptr));
|
568 | 565 | return const_cast<void *>(Ptr);
|
569 | 566 | }
|
570 | 567 |
|
571 |
| - int DevicesSize = omp_get_initial_device(); |
572 |
| - { |
573 |
| - std::lock_guard<std::mutex> LG(PM->RTLsMtx); |
574 |
| - DevicesSize = PM->Devices.size(); |
575 |
| - } |
576 |
| - if (DevicesSize <= DeviceNum) { |
| 568 | + if (NumDevices <= DeviceNum) { |
577 | 569 | DP("DeviceNum %d is invalid, returning nullptr.\n", DeviceNum);
|
578 | 570 | return nullptr;
|
579 | 571 | }
|
|
0 commit comments