Skip to content

[SYCL] Fix dumping of images for multiple targets #8640

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 4 commits into from
Mar 22, 2023
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
14 changes: 12 additions & 2 deletions sycl/source/detail/program_manager/program_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,7 @@ void ProgramManager::addImages(pi_device_binaries DeviceBinary) {
const _pi_offload_entry EntriesB = RawImg->EntriesBegin;
const _pi_offload_entry EntriesE = RawImg->EntriesEnd;
auto Img = make_unique_ptr<RTDeviceBinaryImage>(RawImg, M);
static uint32_t SequenceID = 0;

// Fill the kernel argument mask map
const RTDeviceBinaryImage::PropertyRange &KPOIRange =
Expand Down Expand Up @@ -1257,6 +1258,13 @@ void ProgramManager::addImages(pi_device_binaries DeviceBinary) {
if (KSIdIt != KSIdMap.end()) {
auto &Imgs = m_DeviceImages[KSIdIt->second];
assert(Imgs && "Device image vector should have been already created");
if (DumpImages) {
const bool NeedsSequenceID =
std::any_of(Imgs->begin(), Imgs->end(), [&](auto &I) {
return I->getFormat() == Img->getFormat();
});
dumpImage(*Img, KSIdIt->second, NeedsSequenceID ? ++SequenceID : 0);
}

cacheKernelUsesAssertInfo(M, *Img);

Expand Down Expand Up @@ -1379,12 +1387,14 @@ ProgramManager::getKernelSetId(OSModuleHandle M,
PI_ERROR_INVALID_KERNEL_NAME);
}

void ProgramManager::dumpImage(const RTDeviceBinaryImage &Img,
KernelSetId KSId) const {
void ProgramManager::dumpImage(const RTDeviceBinaryImage &Img, KernelSetId KSId,
uint32_t SequenceID) const {
std::string Fname("sycl_");
const pi_device_binary_struct &RawImg = Img.getRawData();
Fname += RawImg.DeviceTargetSpec;
Fname += std::to_string(KSId);
if (SequenceID)
Fname += '_' + std::to_string(SequenceID);
std::string Ext;

RT::PiDeviceBinaryType Format = Img.getFormat();
Expand Down
3 changes: 2 additions & 1 deletion sycl/source/detail/program_manager/program_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ class ProgramManager {
KernelSetId getKernelSetId(OSModuleHandle M,
const std::string &KernelName) const;
/// Dumps image to current directory
void dumpImage(const RTDeviceBinaryImage &Img, KernelSetId KSId) const;
void dumpImage(const RTDeviceBinaryImage &Img, KernelSetId KSId,
uint32_t SequenceID = 0) const;

/// Add info on kernels using assert into cache
void cacheKernelUsesAssertInfo(OSModuleHandle M, RTDeviceBinaryImage &Img);
Expand Down