Skip to content

Commit

Permalink
[SYCL] Partially revert "Sort platforms in platform::get_platforms() (#…
Browse files Browse the repository at this point in the history
…12719)" (#12823)

This commit reverts the functional change because device filtering
accesses plugins directly and not through the get_platforms() interface
resulting in inconsistent device numbering. Test bug-fixes from the PR
are not being reverted though.
  • Loading branch information
aelovikov-intel authored Feb 27, 2024
1 parent a452e06 commit 1d61e69
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions sycl/source/detail/platform_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,31 +203,6 @@ std::vector<platform> platform_impl::get_platforms() {
// may be initialized after.
GlobalHandler::registerDefaultContextReleaseHandler();

// Some applications/libraries prefer to implement their own device selection
// and default to just providing the first available device. Make sure that
// the first platform has the most preferrable device.
auto GetPlatformScore = [](const platform &p) {
auto devs = p.get_devices();
auto it =
std::max_element(devs.begin(), devs.end(), [](auto lhs, auto rhs) {
return default_selector_v(lhs) < default_selector_v(rhs);
});
return default_selector_v(*it);
};

std::vector<std::pair<platform, int>> PlatformScores;
PlatformScores.reserve(Platforms.size());
for (auto &p : Platforms)
PlatformScores.emplace_back(p, GetPlatformScore(p));

std::stable_sort(PlatformScores.begin(), PlatformScores.end(), [&](auto lhs, auto rhs) {
return lhs.second > rhs.second;
});

Platforms.clear();
for (auto &e : PlatformScores )
Platforms.push_back(e.first);

return Platforms;
}

Expand Down

0 comments on commit 1d61e69

Please sign in to comment.