Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Ensure that RTDeviceBinaryImage instances have a unique image ID #12526

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sycl/source/detail/device_binary_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uintptr_t> RTDeviceBinaryImage::ImageCounter = 1;

DynRTDeviceBinaryImage::DynRTDeviceBinaryImage(
std::unique_ptr<char[]> &&DataPtr, size_t DataSize)
: RTDeviceBinaryImage() {
Expand Down
6 changes: 5 additions & 1 deletion sycl/source/detail/device_binary_image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::uintptr_t>(Bin);
return ImageId;
}

protected:
Expand All @@ -240,6 +240,10 @@ class RTDeviceBinaryImage {
RTDeviceBinaryImage::PropertyRange DeviceGlobals;
RTDeviceBinaryImage::PropertyRange DeviceRequirements;
RTDeviceBinaryImage::PropertyRange HostPipes;

private:
static std::atomic<uintptr_t> ImageCounter;
uintptr_t ImageId;
};

// Dynamically allocated device binary image, which de-allocates its binary
Expand Down
Loading