@@ -156,32 +156,36 @@ static void registerImageIntoTranslationTable(TranslationTable &TT,
156
156
void PluginManager::registerLib (__tgt_bin_desc *Desc) {
157
157
PM->RTLsMtx .lock ();
158
158
159
+ llvm::SmallVector<
160
+ std::tuple<__tgt_device_image *, __tgt_image_info *, DeviceImageTy *>>
161
+ RemainingImages;
162
+
159
163
// Extract the exectuable image and extra information if availible.
160
- for (int32_t i = 0 ; i < Desc->NumDeviceImages ; ++i)
164
+ for (int32_t i = 0 ; i < Desc->NumDeviceImages ; ++i) {
161
165
PM->addDeviceImage (*Desc, Desc->DeviceImages [i]);
166
+ }
162
167
163
- // Register the images with the RTLs that understand them, if any.
164
- for (DeviceImageTy &DI : PM->deviceImages ()) {
165
- // Obtain the image and information that was previously extracted.
166
- __tgt_device_image *Img = &DI.getExecutableImage ();
167
- __tgt_image_info *Info = &DI.getImageInfo ();
168
+ for (auto &DI : PM->deviceImages ()) {
169
+ RemainingImages.emplace_back (&DI.getExecutableImage (), &DI.getImageInfo (),
170
+ &DI);
171
+ }
168
172
169
- PluginAdaptorTy *FoundRTL = nullptr ;
173
+ // Scan the RTLs that have associated images until we find one that supports
174
+ // the current image.
175
+ for (auto &R : PM->pluginAdaptors ()) {
170
176
171
- // Scan the RTLs that have associated images until we find one that supports
172
- // the current image.
173
- for (auto &R : PM->pluginAdaptors ()) {
174
- if (R.is_valid_binary_info ) {
175
- if (!R.is_valid_binary_info (Img, Info)) {
176
- DP (" Image " DPxMOD " is NOT compatible with RTL %s!\n " ,
177
- DPxPTR (Img->ImageStart ), R.Name .c_str ());
178
- continue ;
179
- }
180
- } else if (!R.is_valid_binary (Img)) {
181
- DP (" Image " DPxMOD " is NOT compatible with RTL %s!\n " ,
182
- DPxPTR (Img->ImageStart ), R.Name .c_str ());
183
- continue ;
184
- }
177
+ llvm::SmallVector<
178
+ std::tuple<__tgt_device_image *, __tgt_image_info *, DeviceImageTy *>>
179
+ ValidImages;
180
+
181
+ R.exists_valid_binary_for_RTL (&RemainingImages, &ValidImages);
182
+
183
+ for (auto &VI : ValidImages) {
184
+
185
+ // Register the images with the RTLs that understand them, if any.
186
+ // Obtain the image and information that was previously extracted.
187
+ __tgt_device_image *Img = std::get<0 >(VI);
188
+ __tgt_image_info *Info = std::get<1 >(VI);
185
189
186
190
DP (" Image " DPxMOD " is compatible with RTL %s!\n " ,
187
191
DPxPTR (Img->ImageStart ), R.Name .c_str ());
@@ -208,19 +212,24 @@ void PluginManager::registerLib(__tgt_bin_desc *Desc) {
208
212
R.UsedImages .insert (Img);
209
213
210
214
PM->TrlTblMtx .unlock ();
211
- FoundRTL = &R;
212
215
213
216
// Register all offload entries with the devices handled by the plugin.
214
- R.addOffloadEntries (DI);
215
-
216
- // if an RTL was found we are done - proceed to register the next image
217
- break ;
217
+ R.addOffloadEntries (*std::get<2 >(VI));
218
218
}
219
219
220
- if (!FoundRTL) {
221
- DP (" No RTL found for image " DPxMOD " !\n " , DPxPTR (Img->ImageStart ));
222
- }
220
+ #ifdef OMPTARGET_DEBUG
221
+ for (auto Img : RemainingImages)
222
+ DP (" Image " DPxMOD " is NOT compatible with RTL %s!\n " ,
223
+ DPxPTR (std::get<0 >(Img)->ImageStart ), R.Name .c_str ());
224
+ #endif
223
225
}
226
+
227
+ #ifdef OMPTARGET_DEBUG
228
+ for (auto RI : RemainingImages)
229
+ DP (" No RTL found for image " DPxMOD " !\n " ,
230
+ DPxPTR ((std::get<0 >(RI))->ImageStart ));
231
+ #endif
232
+
224
233
PM->RTLsMtx .unlock ();
225
234
226
235
DP (" Done registering entries!\n " );
0 commit comments