Skip to content

Commit e07deff

Browse files
[SYCL] Remove kernel set id to fix kernel lookup (#10551)
Signed-off-by: Tikhomirova, Kseniya <kseniya.tikhomirova@intel.com>
1 parent d269360 commit e07deff

File tree

14 files changed

+269
-239
lines changed

14 files changed

+269
-239
lines changed

sycl/include/sycl/detail/common.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -371,15 +371,6 @@ size_t getLinearIndex(const T<Dims> &Index, const U<Dims> &Range) {
371371
return LinearIndex;
372372
}
373373

374-
// Kernel set ID, used to group kernels (represented by OSModule & kernel name
375-
// pairs) into disjoint sets based on the kernel distribution among device
376-
// images.
377-
using KernelSetId = size_t;
378-
// Kernel set ID for kernels contained within the SPIR-V file specified via
379-
// environment.
380-
constexpr KernelSetId SpvFileKSId = 0;
381-
constexpr KernelSetId LastKSId = SpvFileKSId;
382-
383374
template <typename T> struct InlineVariableHelper {
384375
static constexpr T value{};
385376
};

sycl/source/detail/device_global_map_entry.hpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <mutex>
1515
#include <optional>
1616
#include <set>
17+
#include <unordered_set>
1718

1819
#include <detail/pi_utils.hpp>
1920
#include <sycl/detail/defines_elementary.hpp>
@@ -51,11 +52,11 @@ struct DeviceGlobalMapEntry {
5152
std::string MUniqueId;
5253
// Pointer to the device_global on host.
5354
const void *MDeviceGlobalPtr = nullptr;
55+
// Images device_global are used by.
56+
std::unordered_set<RTDeviceBinaryImage *> MImages;
5457
// The image identifiers for the images using the device_global used by in the
5558
// cache.
5659
std::set<std::uintptr_t> MImageIdentifiers;
57-
// The kernel-set IDs for the images using the device_global.
58-
std::set<KernelSetId> MKSIds;
5960
// Size of the underlying type in the device_global.
6061
std::uint32_t MDeviceGlobalTSize = 0;
6162
// True if the device_global has been decorated with device_image_scope.
@@ -68,10 +69,11 @@ struct DeviceGlobalMapEntry {
6869

6970
// Constructor for only initializing ID, type size, and device image scope
7071
// flag. The pointer to the device global will be initialized later.
71-
DeviceGlobalMapEntry(std::string UniqueId, std::uintptr_t ImgId,
72-
KernelSetId KSId, std::uint32_t DeviceGlobalTSize,
72+
DeviceGlobalMapEntry(std::string UniqueId, RTDeviceBinaryImage *Img,
73+
std::uint32_t DeviceGlobalTSize,
7374
bool IsDeviceImageScopeDecorated)
74-
: MUniqueId(UniqueId), MImageIdentifiers{ImgId}, MKSIds{KSId},
75+
: MUniqueId(UniqueId), MImages{Img},
76+
MImageIdentifiers{reinterpret_cast<uintptr_t>(Img)},
7577
MDeviceGlobalTSize(DeviceGlobalTSize),
7678
MIsDeviceImageScopeDecorated(IsDeviceImageScopeDecorated) {}
7779

@@ -85,8 +87,7 @@ struct DeviceGlobalMapEntry {
8587

8688
// Initialize the device_global's element type size and the flag signalling
8789
// if the device_global has the device_image_scope property.
88-
void initialize(std::uintptr_t ImgId, KernelSetId KSId,
89-
std::uint32_t DeviceGlobalTSize,
90+
void initialize(RTDeviceBinaryImage *Img, std::uint32_t DeviceGlobalTSize,
9091
bool IsDeviceImageScopeDecorated) {
9192
if (MDeviceGlobalTSize != 0) {
9293
// The device global entry has already been initialized. This can happen
@@ -99,8 +100,8 @@ struct DeviceGlobalMapEntry {
99100
"Device global intializations disagree on image scope decoration.");
100101
return;
101102
}
102-
MImageIdentifiers.insert(ImgId);
103-
MKSIds.insert(KSId);
103+
MImages.insert(Img);
104+
MImageIdentifiers.insert(reinterpret_cast<uintptr_t>(Img));
104105
MDeviceGlobalTSize = DeviceGlobalTSize;
105106
MIsDeviceImageScopeDecorated = IsDeviceImageScopeDecorated;
106107
}

sycl/source/detail/memory_manager.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,13 +1133,13 @@ getOrBuildProgramForDeviceGlobal(QueueImplPtr Queue,
11331133
assert(DeviceGlobalEntry->MIsDeviceImageScopeDecorated &&
11341134
"device_global is not device image scope decorated.");
11351135

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

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

@@ -1153,9 +1153,9 @@ getOrBuildProgramForDeviceGlobal(QueueImplPtr Queue,
11531153

11541154
// If there was no cached program, build one.
11551155
auto Context = createSyclObjFromImpl<context>(ContextImpl);
1156-
KernelSetId KSId = *DeviceGlobalEntry->MKSIds.begin();
11571156
ProgramManager &PM = ProgramManager::getInstance();
1158-
RTDeviceBinaryImage &Img = PM.getDeviceImage(KSId, Context, Device);
1157+
RTDeviceBinaryImage &Img =
1158+
PM.getDeviceImage(DeviceGlobalEntry->MImages, Context, Device);
11591159
device_image_plain DeviceImage =
11601160
PM.getDeviceImageFromBinaryImage(&Img, Context, Device);
11611161
device_image_plain BuiltImage = PM.build(DeviceImage, {Device}, {});

0 commit comments

Comments
 (0)