Skip to content

Commit

Permalink
Stop using hash ordering
Browse files Browse the repository at this point in the history
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
  • Loading branch information
steffenlarsen committed Mar 21, 2024
1 parent 80fd4fb commit 3da0322
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions tests/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -858,17 +858,15 @@ inline sycl::id<3> unlinearize(sycl::range<3> range, size_t id) {
*/
inline bool have_same_devices(std::vector<sycl::device> lhs,
std::vector<sycl::device> rhs) {
auto device_order_f = [](const sycl::device& d1,
const sycl::device& d2) -> bool {
std::hash<sycl::device> h{};
return h(d1) < h(d2);
// TODO: If SYCL devices are given well-defined ordering, this can be
// implemented using std::set_difference.
auto create_check_func = [](const std::vector<sycl::device>& devices) {
return [&devices](const sycl::device& dev) {
return std::find(devices.cbegin(), devices.cend(), dev) != devices.cend();
};
};
std::sort(lhs.begin(), lhs.end(), device_order_f);
std::sort(rhs.begin(), rhs.end(), device_order_f);
std::vector<sycl::device> difference{};
std::set_difference(lhs.begin(), lhs.end(), rhs.begin(), rhs.end(),
std::back_inserter(difference), device_order_f);
return difference.size() == 0;
return std::all_of(lhs.cbegin(), lhs.cend(), create_check_func(rhs)) &&
std::all_of(rhs.cbegin(), rhs.cend(), create_check_func(lhs));
}

#endif // __SYCLCTS_TESTS_COMMON_COMMON_H

0 comments on commit 3da0322

Please sign in to comment.