Skip to content

[SYCL] Remove kernel set id to fix kernel lookup #10551

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 27 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6325f28
draft
KseniyaTikhomirova Jul 11, 2023
04eb19d
fix memory leak
KseniyaTikhomirova Jul 11, 2023
ab4d0ea
return multimap
KseniyaTikhomirova Jul 11, 2023
51a7656
final
KseniyaTikhomirova Jul 13, 2023
19c6b14
add service kernels to search
KseniyaTikhomirova Jul 14, 2023
bd9abdb
draft
KseniyaTikhomirova Jul 25, 2023
43aa741
add universal set back
KseniyaTikhomirova Jul 31, 2023
9a87064
Merge branch 'sycl' into kernel_lookup_failure
KseniyaTikhomirova Jul 31, 2023
0198534
fix tests
KseniyaTikhomirova Aug 3, 2023
278002f
fix gap
KseniyaTikhomirova Aug 3, 2023
9d40069
remove prints
KseniyaTikhomirova Aug 3, 2023
c27e364
fix clang-format
KseniyaTikhomirova Aug 3, 2023
f82268a
move general code to function
KseniyaTikhomirova Aug 3, 2023
1ed4b44
fix warning
KseniyaTikhomirova Aug 3, 2023
2d59ce9
fix mutex lock
KseniyaTikhomirova Aug 7, 2023
db9dce0
fix spv usage
KseniyaTikhomirova Aug 7, 2023
19c8e49
add test as reported issue follow up
KseniyaTikhomirova Aug 9, 2023
5ffb319
add empty lines at the eof
KseniyaTikhomirova Aug 9, 2023
dc81435
fix comment
KseniyaTikhomirova Aug 9, 2023
49c1402
fix code review comments
KseniyaTikhomirova Aug 10, 2023
774f390
fix print text
KseniyaTikhomirova Aug 10, 2023
2b219d6
add container to provide proper memory release for device image wrapper
KseniyaTikhomirova Aug 10, 2023
ddbcbde
disable test on cuda & hip. gen testing is enough
KseniyaTikhomirova Aug 10, 2023
621517c
disable new test
KseniyaTikhomirova Aug 10, 2023
1164c7b
temporary restore universal kernel set
KseniyaTikhomirova Aug 11, 2023
c4ec7fb
fix segfault
KseniyaTikhomirova Aug 11, 2023
477c227
avoid conflict in images used by usit test
KseniyaTikhomirova Aug 11, 2023
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
9 changes: 0 additions & 9 deletions sycl/include/sycl/detail/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,15 +369,6 @@ size_t getLinearIndex(const T<Dims> &Index, const U<Dims> &Range) {
return LinearIndex;
}

// Kernel set ID, used to group kernels (represented by OSModule & kernel name
// pairs) into disjoint sets based on the kernel distribution among device
// images.
using KernelSetId = size_t;
// Kernel set ID for kernels contained within the SPIR-V file specified via
// environment.
constexpr KernelSetId SpvFileKSId = 0;
constexpr KernelSetId LastKSId = SpvFileKSId;

template <typename T> struct InlineVariableHelper {
static constexpr T value{};
};
Expand Down
19 changes: 10 additions & 9 deletions sycl/source/detail/device_global_map_entry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <mutex>
#include <optional>
#include <set>
#include <unordered_set>

#include <detail/pi_utils.hpp>
#include <sycl/detail/defines_elementary.hpp>
Expand Down Expand Up @@ -51,11 +52,11 @@ struct DeviceGlobalMapEntry {
std::string MUniqueId;
// Pointer to the device_global on host.
const void *MDeviceGlobalPtr = nullptr;
// Images device_global are used by.
std::unordered_set<RTDeviceBinaryImage *> MImages;
// The image identifiers for the images using the device_global used by in the
// cache.
std::set<std::uintptr_t> MImageIdentifiers;
// The kernel-set IDs for the images using the device_global.
std::set<KernelSetId> MKSIds;
// Size of the underlying type in the device_global.
std::uint32_t MDeviceGlobalTSize = 0;
// True if the device_global has been decorated with device_image_scope.
Expand All @@ -68,10 +69,11 @@ struct DeviceGlobalMapEntry {

// Constructor for only initializing ID, type size, and device image scope
// flag. The pointer to the device global will be initialized later.
DeviceGlobalMapEntry(std::string UniqueId, std::uintptr_t ImgId,
KernelSetId KSId, std::uint32_t DeviceGlobalTSize,
DeviceGlobalMapEntry(std::string UniqueId, RTDeviceBinaryImage *Img,
std::uint32_t DeviceGlobalTSize,
bool IsDeviceImageScopeDecorated)
: MUniqueId(UniqueId), MImageIdentifiers{ImgId}, MKSIds{KSId},
: MUniqueId(UniqueId), MImages{Img},
MImageIdentifiers{reinterpret_cast<uintptr_t>(Img)},
MDeviceGlobalTSize(DeviceGlobalTSize),
MIsDeviceImageScopeDecorated(IsDeviceImageScopeDecorated) {}

Expand All @@ -85,8 +87,7 @@ struct DeviceGlobalMapEntry {

// Initialize the device_global's element type size and the flag signalling
// if the device_global has the device_image_scope property.
void initialize(std::uintptr_t ImgId, KernelSetId KSId,
std::uint32_t DeviceGlobalTSize,
void initialize(RTDeviceBinaryImage *Img, std::uint32_t DeviceGlobalTSize,
bool IsDeviceImageScopeDecorated) {
if (MDeviceGlobalTSize != 0) {
// The device global entry has already been initialized. This can happen
Expand All @@ -99,8 +100,8 @@ struct DeviceGlobalMapEntry {
"Device global intializations disagree on image scope decoration.");
return;
}
MImageIdentifiers.insert(ImgId);
MKSIds.insert(KSId);
MImages.insert(Img);
MImageIdentifiers.insert(reinterpret_cast<uintptr_t>(Img));
MDeviceGlobalTSize = DeviceGlobalTSize;
MIsDeviceImageScopeDecorated = IsDeviceImageScopeDecorated;
}
Expand Down
10 changes: 5 additions & 5 deletions sycl/source/detail/memory_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1133,13 +1133,13 @@ getOrBuildProgramForDeviceGlobal(QueueImplPtr Queue,
assert(DeviceGlobalEntry->MIsDeviceImageScopeDecorated &&
"device_global is not device image scope decorated.");

// If the device global is used in multiple kernel sets we cannot proceed.
if (DeviceGlobalEntry->MKSIds.size() > 1)
// If the device global is used in multiple device images we cannot proceed.
if (DeviceGlobalEntry->MImageIdentifiers.size() > 1)
throw sycl::exception(make_error_code(errc::invalid),
"More than one image exists with the device_global.");

// If there are no kernels using the device_global we cannot proceed.
if (DeviceGlobalEntry->MKSIds.size() == 0)
if (DeviceGlobalEntry->MImageIdentifiers.size() == 0)
throw sycl::exception(make_error_code(errc::invalid),
"No image exists with the device_global.");

Expand All @@ -1153,9 +1153,9 @@ getOrBuildProgramForDeviceGlobal(QueueImplPtr Queue,

// If there was no cached program, build one.
auto Context = createSyclObjFromImpl<context>(ContextImpl);
KernelSetId KSId = *DeviceGlobalEntry->MKSIds.begin();
ProgramManager &PM = ProgramManager::getInstance();
RTDeviceBinaryImage &Img = PM.getDeviceImage(KSId, Context, Device);
RTDeviceBinaryImage &Img =
PM.getDeviceImage(DeviceGlobalEntry->MImages, Context, Device);
device_image_plain DeviceImage =
PM.getDeviceImageFromBinaryImage(&Img, Context, Device);
device_image_plain BuiltImage = PM.build(DeviceImage, {Device}, {});
Expand Down
Loading