Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:13

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2020 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 // SYCL plugin include(s)
0010 #include "Acts/Plugins/Sycl/Utilities/DeviceSelector.hpp"
0011 
0012 // SYCL include
0013 #include <CL/sycl.hpp>
0014 
0015 namespace Acts::Sycl {
0016 DeviceSelector::DeviceSelector(const std::string& deviceName)
0017     : m_defaultSelector(cl::sycl::default_selector()),
0018       m_deviceName(deviceName) {}
0019 
0020 int DeviceSelector::operator()(const cl::sycl::device& d) const {
0021   // Under no circumstances do we accept any NVidia OpenCL devices.
0022   const std::string vendor = d.get_info<cl::sycl::info::device::vendor>();
0023   const std::string version = d.get_info<cl::sycl::info::device::version>();
0024   if ((vendor.find("NVIDIA") != std::string::npos) &&
0025       (version.find("OpenCL") != std::string::npos)) {
0026     return -1;
0027   }
0028 
0029   // If the user provided a substring of the device name, look for that device
0030   if (!m_deviceName.empty()) {
0031     if (d.get_info<cl::sycl::info::device::name>().find(m_deviceName) !=
0032         std::string::npos) {
0033       return 1;
0034     } else {
0035       return -1;
0036     }
0037   }
0038 
0039   // Otherwise return the value defined by the default selector
0040   return m_defaultSelector(d);
0041 };
0042 }  // namespace Acts::Sycl