@@ -182,34 +182,6 @@ class InfoQueueTy {
182
182
// / specific device. This class is responsible for storing and managing
183
183
// / the offload entries for an image on a device.
184
184
class DeviceImageTy {
185
-
186
- // / Class representing the offload entry table. The class stores the
187
- // / __tgt_target_table and a map to search in the table faster.
188
- struct OffloadEntryTableTy {
189
- // / Add new entry to the table.
190
- void addEntry (const __tgt_offload_entry &Entry) {
191
- Entries.push_back (Entry);
192
- TTTablePtr.EntriesBegin = &Entries[0 ];
193
- TTTablePtr.EntriesEnd = TTTablePtr.EntriesBegin + Entries.size ();
194
- }
195
-
196
- // / Get the raw pointer to the __tgt_target_table.
197
- operator __tgt_target_table *() {
198
- if (Entries.empty ())
199
- return nullptr ;
200
- return &TTTablePtr;
201
- }
202
-
203
- private:
204
- __tgt_target_table TTTablePtr;
205
- llvm::SmallVector<__tgt_offload_entry> Entries;
206
-
207
- public:
208
- using const_iterator = decltype (Entries)::const_iterator;
209
- const_iterator begin () const { return Entries.begin (); }
210
- const_iterator end () const { return Entries.end (); }
211
- };
212
-
213
185
// / Image identifier within the corresponding device. Notice that this id is
214
186
// / not unique between different device; they may overlap.
215
187
int32_t ImageId;
@@ -218,25 +190,29 @@ class DeviceImageTy {
218
190
const __tgt_device_image *TgtImage;
219
191
const __tgt_device_image *TgtImageBitcode;
220
192
193
+ // / Reference to the device this image is loaded on.
194
+ GenericDeviceTy &Device;
195
+
221
196
// / If this image has any global destructors that much be called.
222
197
// / FIXME: This is only required because we currently have no invariants
223
198
// / towards the lifetime of the underlying image. We should either copy
224
199
// / the image into memory locally or erase the pointers after init.
225
200
bool PendingGlobalDtors;
226
201
227
- // / Table of offload entries.
228
- OffloadEntryTableTy OffloadEntryTable;
229
-
230
202
public:
231
- DeviceImageTy (int32_t Id, const __tgt_device_image *Image)
232
- : ImageId(Id), TgtImage(Image), TgtImageBitcode(nullptr ),
203
+ DeviceImageTy (int32_t Id, GenericDeviceTy &Device,
204
+ const __tgt_device_image *Image)
205
+ : ImageId(Id), TgtImage(Image), TgtImageBitcode(nullptr ), Device(Device),
233
206
PendingGlobalDtors (false ) {
234
207
assert (TgtImage && " Invalid target image" );
235
208
}
236
209
237
210
// / Get the image identifier within the device.
238
211
int32_t getId () const { return ImageId; }
239
212
213
+ // / Get the device that this image is loaded onto.
214
+ GenericDeviceTy &getDevice () const { return Device; }
215
+
240
216
// / Get the pointer to the raw __tgt_device_image.
241
217
const __tgt_device_image *getTgtImage () const { return TgtImage; }
242
218
@@ -261,13 +237,9 @@ class DeviceImageTy {
261
237
return MemoryBufferRef (StringRef ((const char *)getStart (), getSize ()),
262
238
" Image" );
263
239
}
264
-
265
240
// / Accessors to the boolean value
266
241
bool setPendingGlobalDtors () { return PendingGlobalDtors = true ; }
267
242
bool hasPendingGlobalDtors () const { return PendingGlobalDtors; }
268
-
269
- // / Get a reference to the offload entry table for the image.
270
- OffloadEntryTableTy &getOffloadEntryTable () { return OffloadEntryTable; }
271
243
};
272
244
273
245
// / Class implementing common functionalities of offload kernels. Each plugin
@@ -661,8 +633,8 @@ struct GenericDeviceTy : public DeviceAllocatorTy {
661
633
virtual Error deinitImpl () = 0;
662
634
663
635
// / Load the binary image into the device and return the target table.
664
- Expected<__tgt_target_table *> loadBinary (GenericPluginTy &Plugin,
665
- const __tgt_device_image *TgtImage);
636
+ Expected<DeviceImageTy *> loadBinary (GenericPluginTy &Plugin,
637
+ const __tgt_device_image *TgtImage);
666
638
virtual Expected<DeviceImageTy *>
667
639
loadBinaryImpl (const __tgt_device_image *TgtImage, int32_t ImageId) = 0 ;
668
640
@@ -680,9 +652,6 @@ struct GenericDeviceTy : public DeviceAllocatorTy {
680
652
// up to the target to override this using the shouldSetupRPCServer function.
681
653
Error setupRPCServer (GenericPluginTy &Plugin, DeviceImageTy &Image);
682
654
683
- // / Register the offload entries for a specific image on the device.
684
- Error registerOffloadEntries (DeviceImageTy &Image);
685
-
686
655
// / Synchronize the current thread with the pending operations on the
687
656
// / __tgt_async_info structure.
688
657
Error synchronize (__tgt_async_info *AsyncInfo);
@@ -888,21 +857,10 @@ struct GenericDeviceTy : public DeviceAllocatorTy {
888
857
bool useAutoZeroCopy ();
889
858
virtual bool useAutoZeroCopyImpl () { return false ; }
890
859
891
- private:
892
- // / Register offload entry for global variable.
893
- Error registerGlobalOffloadEntry (DeviceImageTy &DeviceImage,
894
- const __tgt_offload_entry &GlobalEntry,
895
- __tgt_offload_entry &DeviceEntry);
896
-
897
- // / Register offload entry for kernel function.
898
- Error registerKernelOffloadEntry (DeviceImageTy &DeviceImage,
899
- const __tgt_offload_entry &KernelEntry,
900
- __tgt_offload_entry &DeviceEntry);
901
-
902
860
// / Allocate and construct a kernel object.
903
- virtual Expected<GenericKernelTy &>
904
- constructKernel (const __tgt_offload_entry &KernelEntry) = 0 ;
861
+ virtual Expected<GenericKernelTy &> constructKernel (const char *Name) = 0;
905
862
863
+ private:
906
864
// / Get and set the stack size and heap size for the device. If not used, the
907
865
// / plugin can implement the setters as no-op and setting the output
908
866
// / value to zero for the getters.
0 commit comments