@@ -32,6 +32,12 @@ __SYCL_INLINE_NAMESPACE(cl) {
32
32
namespace sycl {
33
33
namespace detail {
34
34
35
+ template <class T > struct LessByHash {
36
+ bool operator ()(const T &LHS, const T &RHS) const {
37
+ return getSyclObjImpl (LHS) < getSyclObjImpl (RHS);
38
+ }
39
+ };
40
+
35
41
// The class is impl counterpart for sycl::device_image
36
42
// It can represent a program in different states, kernel_id's it has and state
37
43
// of specialization constants for it
@@ -51,7 +57,8 @@ class device_image_impl {
51
57
52
58
device_image_impl (const RTDeviceBinaryImage *BinImage, context Context,
53
59
std::vector<device> Devices, bundle_state State,
54
- std::vector<kernel_id> KernelIDs, RT::PiProgram Program)
60
+ std::shared_ptr<std::vector<kernel_id>> KernelIDs,
61
+ RT::PiProgram Program)
55
62
: MBinImage(BinImage), MContext(std::move(Context)),
56
63
MDevices (std::move(Devices)), MState(State), MProgram(Program),
57
64
MKernelIDs(std::move(KernelIDs)) {
@@ -60,17 +67,17 @@ class device_image_impl {
60
67
61
68
device_image_impl (const RTDeviceBinaryImage *BinImage, context Context,
62
69
std::vector<device> Devices, bundle_state State,
63
- std::vector<kernel_id> KernelIDs, RT::PiProgram Program ,
64
- const SpecConstMapT &SpecConstMap,
70
+ std::shared_ptr<std:: vector<kernel_id>> KernelIDs,
71
+ RT::PiProgram Program, const SpecConstMapT &SpecConstMap,
65
72
const std::vector<unsigned char > &SpecConstsBlob)
66
73
: MBinImage(BinImage), MContext(std::move(Context)),
67
74
MDevices(std::move(Devices)), MState(State), MProgram(Program),
68
75
MKernelIDs(std::move(KernelIDs)), MSpecConstsBlob(SpecConstsBlob),
69
76
MSpecConstSymMap(SpecConstMap) {}
70
77
71
78
bool has_kernel (const kernel_id &KernelIDCand) const noexcept {
72
- return std::binary_search (MKernelIDs. begin (), MKernelIDs. end (),
73
- KernelIDCand, LessByNameComp {});
79
+ return std::binary_search (MKernelIDs-> begin (), MKernelIDs-> end (),
80
+ KernelIDCand, LessByHash<kernel_id> {});
74
81
}
75
82
76
83
bool has_kernel (const kernel_id &KernelIDCand,
@@ -83,7 +90,7 @@ class device_image_impl {
83
90
}
84
91
85
92
const std::vector<kernel_id> &get_kernel_ids () const noexcept {
86
- return MKernelIDs;
93
+ return * MKernelIDs;
87
94
}
88
95
89
96
bool has_specialization_constants () const noexcept {
@@ -176,7 +183,9 @@ class device_image_impl {
176
183
177
184
const context &get_context () const noexcept { return MContext; }
178
185
179
- std::vector<kernel_id> &get_kernel_ids_ref () noexcept { return MKernelIDs; }
186
+ std::shared_ptr<std::vector<kernel_id>> &get_kernel_ids_ptr () noexcept {
187
+ return MKernelIDs;
188
+ }
180
189
181
190
std::vector<unsigned char > &get_spec_const_blob_ref () noexcept {
182
191
return MSpecConstsBlob;
@@ -312,7 +321,7 @@ class device_image_impl {
312
321
RT::PiProgram MProgram = nullptr ;
313
322
// List of kernel ids available in this image, elements should be sorted
314
323
// according to LessByNameComp
315
- std::vector<kernel_id> MKernelIDs;
324
+ std::shared_ptr<std:: vector<kernel_id> > MKernelIDs;
316
325
317
326
// A mutex for sycnhronizing access to spec constants blob. Mutable because
318
327
// needs to be locked in the const method for getting spec constant value.
0 commit comments