Skip to content

Commit 8daaa77

Browse files
authored
[SYCL] Keep the original ordering of devices during uniquifying (#7247)
While it might be a little bit slower in general, in our case the number of elements should be small, so it shouldn't cause any noticeable perf impact. This should help us to get more stable results in our tests.
1 parent b6f61f6 commit 8daaa77

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

sycl/source/kernel_bundle.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ bool kernel_bundle_plain::is_specialization_constant_set(
115115

116116
const std::vector<device>
117117
removeDuplicateDevices(const std::vector<device> &Devs) {
118-
auto compareDevices = [](device a, device b) {
119-
return getSyclObjImpl(a) < getSyclObjImpl(b);
120-
};
121-
std::set<device, decltype(compareDevices)> UniqueDeviceSet(
122-
Devs.begin(), Devs.end(), compareDevices);
123-
std::vector<device> UniqueDevices(UniqueDeviceSet.begin(),
124-
UniqueDeviceSet.end());
118+
std::vector<device> UniqueDevices;
119+
120+
// Building a new vector with unique elements and keep original order
121+
std::unordered_set<device> UniqueDeviceSet;
122+
for (const device &Dev : Devs)
123+
if (UniqueDeviceSet.insert(Dev).second)
124+
UniqueDevices.push_back(Dev);
125125

126126
return UniqueDevices;
127127
}

0 commit comments

Comments
 (0)