diff --git a/sycl/source/detail/device_binary_image.cpp b/sycl/source/detail/device_binary_image.cpp index 3610f22d8519c..1899fcd3db989 100644 --- a/sycl/source/detail/device_binary_image.cpp +++ b/sycl/source/detail/device_binary_image.cpp @@ -176,8 +176,13 @@ void RTDeviceBinaryImage::init(pi_device_binary Bin) { DeviceGlobals.init(Bin, __SYCL_PI_PROPERTY_SET_SYCL_DEVICE_GLOBALS); DeviceRequirements.init(Bin, __SYCL_PI_PROPERTY_SET_SYCL_DEVICE_REQUIREMENTS); HostPipes.init(Bin, __SYCL_PI_PROPERTY_SET_SYCL_HOST_PIPES); + + if (Bin) + ImageId = ImageCounter++; } +std::atomic RTDeviceBinaryImage::ImageCounter = 1; + DynRTDeviceBinaryImage::DynRTDeviceBinaryImage( std::unique_ptr &&DataPtr, size_t DataSize) : RTDeviceBinaryImage() { diff --git a/sycl/source/detail/device_binary_image.hpp b/sycl/source/detail/device_binary_image.hpp index b2a74febe392f..d8974b4142071 100644 --- a/sycl/source/detail/device_binary_image.hpp +++ b/sycl/source/detail/device_binary_image.hpp @@ -220,7 +220,7 @@ class RTDeviceBinaryImage { std::uintptr_t getImageID() const { assert(Bin && "Image ID is not available without a binary image."); - return reinterpret_cast(Bin); + return ImageId; } protected: @@ -240,6 +240,10 @@ class RTDeviceBinaryImage { RTDeviceBinaryImage::PropertyRange DeviceGlobals; RTDeviceBinaryImage::PropertyRange DeviceRequirements; RTDeviceBinaryImage::PropertyRange HostPipes; + +private: + static std::atomic ImageCounter; + uintptr_t ImageId; }; // Dynamically allocated device binary image, which de-allocates its binary