@@ -207,196 +207,6 @@ void emitFunctionWithArgsEndTrace(uint64_t CorrelationID, uint32_t FuncID,
207
207
const char *FName, unsigned char *ArgsData,
208
208
pi_result Result, pi_plugin Plugin);
209
209
210
- // A wrapper for passing around byte array properties
211
- class ByteArray {
212
- public:
213
- using ConstIterator = const std::uint8_t *;
214
-
215
- ByteArray (const std::uint8_t *Ptr, std::size_t Size) : Ptr{Ptr}, Size{Size} {}
216
- const std::uint8_t &operator [](std::size_t Idx) const { return Ptr[Idx]; }
217
- std::size_t size () const { return Size; }
218
- ConstIterator begin () const { return Ptr; }
219
- ConstIterator end () const { return Ptr + Size; }
220
-
221
- private:
222
- const std::uint8_t *Ptr;
223
- const std::size_t Size;
224
- };
225
-
226
- // C++ wrapper over the _pi_device_binary_property_struct structure.
227
- class DeviceBinaryProperty {
228
- public:
229
- DeviceBinaryProperty (const _pi_device_binary_property_struct *Prop)
230
- : Prop(Prop) {}
231
-
232
- pi_uint32 asUint32 () const ;
233
- ByteArray asByteArray () const ;
234
- const char *asCString () const ;
235
-
236
- protected:
237
- friend std::ostream &operator <<(std::ostream &Out,
238
- const DeviceBinaryProperty &P);
239
- const _pi_device_binary_property_struct *Prop;
240
- };
241
-
242
- std::ostream &operator <<(std::ostream &Out, const DeviceBinaryProperty &P);
243
-
244
- // C++ convenience wrapper over the pi_device_binary_struct structure.
245
- class DeviceBinaryImage {
246
- public:
247
- // Represents a range of properties to enable iteration over them.
248
- // Implements the standard C++ STL input iterator interface.
249
- class PropertyRange {
250
- public:
251
- using ValTy = std::remove_pointer<pi_device_binary_property>::type;
252
-
253
- class ConstIterator {
254
- pi_device_binary_property Cur;
255
-
256
- public:
257
- using iterator_category = std::input_iterator_tag;
258
- using value_type = ValTy;
259
- using difference_type = ptrdiff_t ;
260
- using pointer = const pi_device_binary_property;
261
- using reference = pi_device_binary_property;
262
-
263
- ConstIterator (pi_device_binary_property Cur = nullptr ) : Cur(Cur) {}
264
- ConstIterator &operator ++() {
265
- Cur++;
266
- return *this ;
267
- }
268
- ConstIterator operator ++(int ) {
269
- ConstIterator Ret = *this ;
270
- ++(*this );
271
- return Ret;
272
- }
273
- bool operator ==(ConstIterator Other) const { return Cur == Other.Cur ; }
274
- bool operator !=(ConstIterator Other) const { return !(*this == Other); }
275
- reference operator *() const { return Cur; }
276
- };
277
- ConstIterator begin () const { return ConstIterator (Begin); }
278
- ConstIterator end () const { return ConstIterator (End); }
279
- friend class DeviceBinaryImage ;
280
- bool isAvailable () const { return !(Begin == nullptr ); }
281
-
282
- private:
283
- PropertyRange () : Begin(nullptr ), End(nullptr ) {}
284
- // Searches for a property set with given name and constructs a
285
- // PropertyRange spanning all its elements. If property set is not found,
286
- // the range will span zero elements.
287
- PropertyRange (pi_device_binary Bin, const char *PropSetName)
288
- : PropertyRange() {
289
- init (Bin, PropSetName);
290
- };
291
- void init (pi_device_binary Bin, const char *PropSetName);
292
- pi_device_binary_property Begin;
293
- pi_device_binary_property End;
294
- };
295
-
296
- public:
297
- DeviceBinaryImage (pi_device_binary Bin) { init (Bin); }
298
- DeviceBinaryImage () : Bin(nullptr ){};
299
-
300
- virtual void print () const ;
301
- virtual void dump (std::ostream &Out) const ;
302
-
303
- size_t getSize () const {
304
- assert (Bin && " binary image data not set" );
305
- return static_cast <size_t >(Bin->BinaryEnd - Bin->BinaryStart );
306
- }
307
-
308
- const char *getCompileOptions () const {
309
- assert (Bin && " binary image data not set" );
310
- return Bin->CompileOptions ;
311
- }
312
-
313
- const char *getLinkOptions () const {
314
- assert (Bin && " binary image data not set" );
315
- return Bin->LinkOptions ;
316
- }
317
-
318
- // / Returns the format of the binary image
319
- pi::PiDeviceBinaryType getFormat () const {
320
- assert (Bin && " binary image data not set" );
321
- return Format;
322
- }
323
-
324
- // / Returns a single property from SYCL_MISC_PROP category.
325
- pi_device_binary_property getProperty (const char *PropName) const ;
326
-
327
- // / Gets the iterator range over specialization constants in this binary
328
- // / image. For each property pointed to by an iterator within the
329
- // / range, the name of the property is the specialization constant symbolic ID
330
- // / and the value is a list of 3-element tuples of 32-bit unsigned integers,
331
- // / describing the specialization constant.
332
- // / This is done in order to unify representation of both scalar and composite
333
- // / specialization constants: composite specialization constant is represented
334
- // / by its leaf elements, so for scalars the list contains only a single
335
- // / tuple, while for composite there might be more of them.
336
- // / Each tuple consists of ID of scalar specialization constant, its location
337
- // / within a composite (offset in bytes from the beginning or 0 if it is not
338
- // / an element of a composite specialization constant) and its size.
339
- // / For example, for the following structure:
340
- // / struct A { int a; float b; };
341
- // / struct POD { A a[2]; int b; };
342
- // / List of tuples will look like:
343
- // / { ID0, 0, 4 }, // .a[0].a
344
- // / { ID1, 4, 4 }, // .a[0].b
345
- // / { ID2, 8, 4 }, // .a[1].a
346
- // / { ID3, 12, 4 }, // .a[1].b
347
- // / { ID4, 16, 4 }, // .b
348
- // / And for an interger specialization constant, the list of tuples will look
349
- // / like:
350
- // / { ID5, 0, 4 }
351
- const PropertyRange &getSpecConstants () const { return SpecConstIDMap; }
352
- const PropertyRange getSpecConstantsDefaultValues () const {
353
- // We can't have this variable as a class member, since it would break
354
- // the ABI backwards compatibility.
355
- DeviceBinaryImage::PropertyRange SpecConstDefaultValuesMap;
356
- SpecConstDefaultValuesMap.init (
357
- Bin, __SYCL_PI_PROPERTY_SET_SPEC_CONST_DEFAULT_VALUES_MAP);
358
- return SpecConstDefaultValuesMap;
359
- }
360
- const PropertyRange &getDeviceLibReqMask () const { return DeviceLibReqMask; }
361
- const PropertyRange &getKernelParamOptInfo () const {
362
- return KernelParamOptInfo;
363
- }
364
- const PropertyRange getAssertUsed () const {
365
- // We can't have this variable as a class member, since it would break
366
- // the ABI backwards compatibility.
367
- PropertyRange AssertUsed;
368
- AssertUsed.init (Bin, __SYCL_PI_PROPERTY_SET_SYCL_ASSERT_USED);
369
- return AssertUsed;
370
- }
371
- const PropertyRange &getProgramMetadata () const { return ProgramMetadata; }
372
- const PropertyRange getExportedSymbols () const {
373
- // We can't have this variable as a class member, since it would break
374
- // the ABI backwards compatibility.
375
- DeviceBinaryImage::PropertyRange ExportedSymbols;
376
- ExportedSymbols.init (Bin, __SYCL_PI_PROPERTY_SET_SYCL_EXPORTED_SYMBOLS);
377
- return ExportedSymbols;
378
- }
379
- const PropertyRange getDeviceGlobals () const {
380
- // We can't have this variable as a class member, since it would break
381
- // the ABI backwards compatibility.
382
- DeviceBinaryImage::PropertyRange DeviceGlobals;
383
- DeviceGlobals.init (Bin, __SYCL_PI_PROPERTY_SET_SYCL_DEVICE_GLOBALS);
384
- return DeviceGlobals;
385
- }
386
- virtual ~DeviceBinaryImage () {}
387
-
388
- protected:
389
- void init (pi_device_binary Bin);
390
- pi_device_binary get () const { return Bin; }
391
-
392
- pi_device_binary Bin;
393
- pi::PiDeviceBinaryType Format = PI_DEVICE_BINARY_TYPE_NONE;
394
- DeviceBinaryImage::PropertyRange SpecConstIDMap;
395
- DeviceBinaryImage::PropertyRange DeviceLibReqMask;
396
- DeviceBinaryImage::PropertyRange KernelParamOptInfo;
397
- DeviceBinaryImage::PropertyRange ProgramMetadata;
398
- };
399
-
400
210
// / Tries to determine the device binary image foramat. Returns
401
211
// / PI_DEVICE_BINARY_TYPE_NONE if unsuccessful.
402
212
PiDeviceBinaryType getBinaryImageFormat (const unsigned char *ImgData,
0 commit comments