38 auto &program_manager = sycl::detail::ProgramManager::getInstance();
39 if (program_manager.hasCompatibleImage(Device))
44 backend::ext_oneapi_level_zero)
51 bool shouldTrace =
false;
58 std::string PlatformName = Device.get_info<info::device::platform>()
59 .get_info<info::platform::name>();
60 std::string DeviceName = Device.get_info<info::device::name>();
61 auto selectionMsg = Chosen ?
"Selected device: -> final score = "
62 :
"Candidate device: -> score = ";
64 std::cout <<
"SYCL_PI_TRACE[all]: " << selectionMsg << Score
65 << ((Score < 0) ?
" (REJECTED)" :
"") << std::endl
66 <<
"SYCL_PI_TRACE[all]: "
67 <<
" platform: " << PlatformName << std::endl
68 <<
"SYCL_PI_TRACE[all]: "
69 <<
" device: " << DeviceName << std::endl;
74 std::vector<device> &Devices) {
76 const device *res =
nullptr;
78 for (
const auto &dev : Devices) {
79 int dev_score = DeviceSelectorInvocable(dev);
94 if ((score < dev_score) ||
95 ((score == dev_score) &&
102 if (res !=
nullptr) {
109 constexpr
const char Prefix[] =
"No device of requested type ";
110 constexpr
const char Cpu[] =
"'info::device_type::cpu' ";
111 constexpr
const char Gpu[] =
"'info::device_type::gpu' ";
112 constexpr
const char Acc[] =
"'info::device_type::accelerator' ";
113 constexpr
const char Suffix[] =
"available.";
114 constexpr
auto ReserveSize =
sizeof(Prefix) +
sizeof(Suffix) +
sizeof(Acc);
115 Message.reserve(ReserveSize);
119 DeviceSelectorInvocable.target<int (*)(
const sycl::device &)>();
121 DeviceSelectorInvocable.target<sycl::gpu_selector>()) {
124 DeviceSelectorInvocable.target<sycl::cpu_selector>()) {
127 DeviceSelectorInvocable.target<sycl::accelerator_selector>()) {
131 throw sycl::runtime_error(Message, PI_ERROR_DEVICE_NOT_FOUND);
137 std::vector<device> Devices = device::get_devices();
149 std::vector<device> Devices = SyclContext.
get_devices();
150 if (std::find(Devices.begin(), Devices.end(), SelectedDevice) ==
153 "Selected device is not in the given context.");
155 return SelectedDevice;
170 bool ShouldTrace =
false;
173 std::cout <<
"SYCL_PI_TRACE[all]: Requested device_type: " << DeviceType
185 if (dev.
get_backend() == backend::ext_intel_esimd_emulator) {
212 if (dev.
get_backend() == backend::ext_intel_esimd_emulator) {
246 int host_selector::operator()(
const device &dev)
const {
256 const std::vector<aspect> &DenyList ) {
257 return [=](
const sycl::device &Dev) {
258 auto DevHas = [&](
const aspect &Asp) ->
bool {
return Dev.has(Asp); };
261 if (!
std::all_of(RequireList.begin(), RequireList.end(), DevHas))
265 if (
std::any_of(DenyList.begin(), DenyList.end(), DevHas))
268 if (RequireList.size() > 0) {
287 int default_selector::operator()(
const device &dev)
const {
291 int gpu_selector::operator()(
const device &dev)
const {
295 int cpu_selector::operator()(
const device &dev)
const {
299 int accelerator_selector::operator()(
const device &dev)
const {
303 namespace ext::oneapi {
305 filter_selector::filter_selector(
const std::string &Input)
306 : impl(
std::make_shared<detail::filter_selector_impl>(Input)) {}
309 return impl->operator()(Dev);
324 std::lock_guard<std::mutex> Guard(
325 sycl::detail::GlobalHandler::instance().getFilterMutex());
337 using namespace ext::oneapi;
338 filter_selector::filter_selector(
const std::string &Input)
339 : ext::oneapi::filter_selector(Input) {}