Skip to content

[SYCL] Select a more consistent image ID for caching #7154

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

Merged
merged 2 commits into from
Oct 25, 2022
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
6 changes: 6 additions & 0 deletions sycl/source/detail/device_binary_image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <sycl/detail/os_util.hpp>
#include <sycl/detail/pi.hpp>

#include <atomic>
#include <cstring>
#include <memory>

Expand Down Expand Up @@ -220,6 +221,11 @@ class RTDeviceBinaryImage {
return DeviceRequirements;
}

std::uintptr_t getImageID() const {
assert(Bin && "Image ID is not available without a binary image.");
return reinterpret_cast<std::uintptr_t>(Bin);
}

protected:
void init(pi_device_binary Bin);
pi_device_binary get() const { return Bin; }
Expand Down
4 changes: 2 additions & 2 deletions sycl/source/detail/program_manager/program_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ RT::PiProgram ProgramManager::getBuiltPIProgram(

const RT::PiDevice PiDevice = Dev->getHandleRef();

std::uintptr_t ImgId = reinterpret_cast<uintptr_t>(&Img);
uint32_t ImgId = Img.getImageID();
auto BuildResult = getOrBuild<PiProgramT, compile_program_error>(
Cache,
std::make_pair(std::make_pair(std::move(SpecConsts), ImgId),
Expand Down Expand Up @@ -1996,7 +1996,7 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage,
return BuiltProgram.release();
};

std::uintptr_t ImgId = reinterpret_cast<uintptr_t>(ImgPtr);
uint32_t ImgId = Img.getImageID();
const RT::PiDevice PiDevice = getRawSyclObjImpl(Devs[0])->getHandleRef();
// TODO: Throw SYCL2020 style exception
auto BuildResult = getOrBuild<PiProgramT, compile_program_error>(
Expand Down