@@ -403,33 +403,30 @@ void RTLsTy::registerRequires(int64_t Flags) {
403
403
404
404
void RTLsTy::initRTLonce (RTLInfoTy &R) {
405
405
// If this RTL is not already in use, initialize it.
406
- if (!R.IsUsed && R.NumberOfDevices != 0 ) {
407
- // Initialize the device information for the RTL we are about to use.
408
- const size_t Start = PM->Devices .size ();
409
- PM->Devices .reserve (Start + R.NumberOfDevices );
410
- for (int32_t DeviceId = 0 ; DeviceId < R.NumberOfDevices ; DeviceId++) {
411
- PM->Devices .push_back (std::make_unique<DeviceTy>(&R));
412
- // global device ID
413
- PM->Devices [Start + DeviceId]->DeviceID = Start + DeviceId;
414
- // RTL local device ID
415
- PM->Devices [Start + DeviceId]->RTLDeviceID = DeviceId;
416
- }
406
+ if (R.IsUsed || !R.NumberOfDevices )
407
+ return ;
417
408
418
- // Initialize the index of this RTL and save it in the used RTLs.
419
- R.Idx = (UsedRTLs.empty ())
420
- ? 0
421
- : UsedRTLs.back ()->Idx + UsedRTLs.back ()->NumberOfDevices ;
422
- assert ((size_t )R.Idx == Start &&
423
- " RTL index should equal the number of devices used so far." );
424
- R.IsUsed = true ;
425
- UsedRTLs.push_back (&R);
409
+ // Initialize the device information for the RTL we are about to use.
410
+ const size_t Start = PM->Devices .size ();
411
+ PM->Devices .reserve (Start + R.NumberOfDevices );
412
+ for (int32_t DeviceId = 0 ; DeviceId < R.NumberOfDevices ; DeviceId++) {
413
+ PM->Devices .push_back (std::make_unique<DeviceTy>(&R));
414
+ // global device ID
415
+ PM->Devices [Start + DeviceId]->DeviceID = Start + DeviceId;
416
+ // RTL local device ID
417
+ PM->Devices [Start + DeviceId]->RTLDeviceID = DeviceId;
418
+ }
426
419
427
- // If possible, set the device identifier offset
428
- if (R.set_device_offset )
429
- R.set_device_offset (Start);
420
+ // Initialize the index of this RTL and save it in the used RTLs.
421
+ R.Idx = Start;
422
+ R.IsUsed = true ;
423
+ UsedRTLs.push_back (&R);
430
424
431
- DP (" RTL " DPxMOD " has index %d!\n " , DPxPTR (R.LibraryHandler .get ()), R.Idx );
432
- }
425
+ // If possible, set the device identifier offset
426
+ if (R.set_device_offset )
427
+ R.set_device_offset (Start);
428
+
429
+ DP (" RTL " DPxMOD " has index %d!\n " , DPxPTR (R.LibraryHandler .get ()), R.Idx );
433
430
}
434
431
435
432
void RTLsTy::initAllRTLs () {
0 commit comments