EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DeviceSelector.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DeviceSelector.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 // SYCL plugin include(s)
11 
12 // SYCL include
13 #include <CL/sycl.hpp>
14 
15 namespace Acts::Sycl {
16 DeviceSelector::DeviceSelector(const std::string& deviceName)
17  : m_defaultSelector(cl::sycl::default_selector()),
18  m_deviceName(deviceName){};
19 
20 int DeviceSelector::operator()(const cl::sycl::device& d) const {
21  // Under no circumstances do we accept any NVidia OpenCL devices.
22  const std::string vendor = d.get_info<cl::sycl::info::device::vendor>();
23  const std::string version = d.get_info<cl::sycl::info::device::version>();
24  if ((vendor.find("NVIDIA") != std::string::npos) &&
25  (version.find("OpenCL") != std::string::npos)) {
26  return -1;
27  }
28 
29  // If the user provided a substring of the device name, look for that device
30  if (!m_deviceName.empty()) {
31  if (d.get_info<cl::sycl::info::device::name>().find(m_deviceName) !=
32  std::string::npos) {
33  return 1;
34  } else {
35  return -1;
36  }
37  }
38 
39  // Otherwise return the value defined by the default selector
40  return m_defaultSelector(d);
41 };
42 } // namespace Acts::Sycl