From 24f8cd3aab16a2fb5f88ae275e7227c1b61fcac9 Mon Sep 17 00:00:00 2001 From: Attila Krasznahorkay Date: Tue, 1 Nov 2022 15:19:09 +0100 Subject: [PATCH] Removed vecmem::sycl::device_selector. The class was not compatible with the latest update of SYCL2020 anymore, and it was not worth it to update it to be compatible. Since this class was not useful ever since the SYCL_DEVICE_FILTER environment variable became a thing in oneAPI. Updated all clients to account for this change. --- sycl/CMakeLists.txt | 4 +- .../sycl/details/memory_resource_base.hpp | 4 +- sycl/include/vecmem/utils/sycl/copy.hpp | 4 +- .../vecmem/utils/sycl/queue_wrapper.hpp | 14 +++++-- sycl/src/utils/sycl/device_selector.hpp | 36 ---------------- sycl/src/utils/sycl/device_selector.sycl | 42 ------------------- sycl/src/utils/sycl/queue_wrapper.sycl | 6 +-- tests/sycl/CMakeLists.txt | 2 - tests/sycl/test_sycl_containers.sycl | 11 +++-- tests/sycl/test_sycl_jagged_containers.sycl | 3 +- 10 files changed, 23 insertions(+), 103 deletions(-) delete mode 100644 sycl/src/utils/sycl/device_selector.hpp delete mode 100644 sycl/src/utils/sycl/device_selector.sycl diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index b08713c2..82ae4268 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -1,6 +1,6 @@ # VecMem project, part of the ACTS project (R&D line) # -# (c) 2021 CERN for the benefit of the ACTS project +# (c) 2021-2022 CERN for the benefit of the ACTS project # # Mozilla Public License Version 2.0 @@ -28,8 +28,6 @@ vecmem_add_library( vecmem_sycl sycl "src/utils/sycl/copy.sycl" "include/vecmem/utils/sycl/queue_wrapper.hpp" "src/utils/sycl/queue_wrapper.sycl" - "src/utils/sycl/device_selector.hpp" - "src/utils/sycl/device_selector.sycl" "src/utils/sycl/get_queue.hpp" "src/utils/sycl/get_queue.sycl" "src/utils/sycl/opaque_queue.hpp" ) diff --git a/sycl/include/vecmem/memory/sycl/details/memory_resource_base.hpp b/sycl/include/vecmem/memory/sycl/details/memory_resource_base.hpp index ce6a77cc..d2d90d76 100644 --- a/sycl/include/vecmem/memory/sycl/details/memory_resource_base.hpp +++ b/sycl/include/vecmem/memory/sycl/details/memory_resource_base.hpp @@ -1,6 +1,6 @@ /** VecMem project, part of the ACTS project (R&D line) * - * (c) 2021 CERN for the benefit of the ACTS project + * (c) 2021-2022 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ @@ -23,7 +23,7 @@ class VECMEM_SYCL_EXPORT memory_resource_base public: /// Constructor on top of a user-provided queue - memory_resource_base(const queue_wrapper& queue = {""}); + memory_resource_base(const queue_wrapper& queue = {}); protected: /// The queue that the allocations are made for/on diff --git a/sycl/include/vecmem/utils/sycl/copy.hpp b/sycl/include/vecmem/utils/sycl/copy.hpp index be06c530..0c8960f2 100644 --- a/sycl/include/vecmem/utils/sycl/copy.hpp +++ b/sycl/include/vecmem/utils/sycl/copy.hpp @@ -1,7 +1,7 @@ /* * VecMem project, part of the ACTS project (R&D line) * - * (c) 2021 CERN for the benefit of the ACTS project + * (c) 2021-2022 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ @@ -25,7 +25,7 @@ class VECMEM_SYCL_EXPORT copy : public vecmem::copy { public: /// Constructor on top of a user-provided queue - copy(const queue_wrapper& queue = {""}); + copy(const queue_wrapper& queue = {}); protected: /// Perform a memory copy using SYCL diff --git a/sycl/include/vecmem/utils/sycl/queue_wrapper.hpp b/sycl/include/vecmem/utils/sycl/queue_wrapper.hpp index 8f4136b7..e065b05e 100644 --- a/sycl/include/vecmem/utils/sycl/queue_wrapper.hpp +++ b/sycl/include/vecmem/utils/sycl/queue_wrapper.hpp @@ -1,6 +1,6 @@ /** VecMem project, part of the ACTS project (R&D line) * - * (c) 2021 CERN for the benefit of the ACTS project + * (c) 2021-2022 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ @@ -11,7 +11,6 @@ // System include(s). #include -#include namespace vecmem::sycl { @@ -35,8 +34,8 @@ class opaque_queue; class VECMEM_SYCL_EXPORT queue_wrapper { public: - /// Construct a queue for a device with a specific name - queue_wrapper(const std::string& deviceName = ""); + /// Construct a queue for the default device + queue_wrapper(); /// Wrap an existing @c cl::sycl::queue object /// /// Without taking ownership of it! @@ -49,6 +48,13 @@ class VECMEM_SYCL_EXPORT queue_wrapper { queue_wrapper(queue_wrapper&& parent); /// Destructor + /// + /// The destructor is declared and implemented explicitly as an empty + /// function to make sure that client code would not try to generate it + /// itself. Leading to problems about the symbols of + /// @c vecmem::sycl::details::opaque_queue not being available in + /// client code. + /// ~queue_wrapper(); /// Copy assignment diff --git a/sycl/src/utils/sycl/device_selector.hpp b/sycl/src/utils/sycl/device_selector.hpp deleted file mode 100644 index 52462f9c..00000000 --- a/sycl/src/utils/sycl/device_selector.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/** VecMem project, part of the ACTS project (R&D line) - * - * (c) 2021 CERN for the benefit of the ACTS project - * - * Mozilla Public License Version 2.0 - */ -#pragma once - -// SYCL include(s). -#include - -// System include(s) -#include - -namespace vecmem::sycl { - -/// Device selector used by the VecMem SYCL library by default -class device_selector : public cl::sycl::device_selector { - -public: - /// Constructor, with an optional device name - device_selector(const std::string& deviceName = ""); - - /// Operator used to "grade" the available devices - int operator()(const cl::sycl::device& device) const override; - -private: - /// Default device selector used internally - cl::sycl::default_selector m_defaultSelector; - - /// The preferred device's name - std::string m_deviceName; - -}; // class device_selector - -} // namespace vecmem::sycl diff --git a/sycl/src/utils/sycl/device_selector.sycl b/sycl/src/utils/sycl/device_selector.sycl deleted file mode 100644 index 4a7b96ac..00000000 --- a/sycl/src/utils/sycl/device_selector.sycl +++ /dev/null @@ -1,42 +0,0 @@ -/** VecMem project, part of the ACTS project (R&D line) - * - * (c) 2021 CERN for the benefit of the ACTS project - * - * Mozilla Public License Version 2.0 - */ - -// Local include(s). -#include "device_selector.hpp" - -namespace vecmem::sycl { - -device_selector::device_selector(const std::string& deviceName) - : m_defaultSelector(), m_deviceName(deviceName) {} - -int device_selector::operator()(const cl::sycl::device& device) const { - - // Under no circumstances do we accept any NVidia or AMD OpenCL devices. - const std::string vendor = - device.get_info(); - const std::string version = - device.get_info(); - if (((vendor.find("NVIDIA") != std::string::npos) || - (vendor.find("Advanced Micro Devices") != std::string::npos)) && - (version.find("OpenCL") != std::string::npos)) { - return -1; - } - - // If the user provided a device name, look for that device. - // And give it a very high score. - using info = cl::sycl::info::device; - if ((!m_deviceName.empty()) && - (device.get_info() == m_deviceName)) { - return 1000; - } - - // But even if a particular device was requested, but not found, still - // return something at least... - return m_defaultSelector(device); -} - -} // namespace vecmem::sycl diff --git a/sycl/src/utils/sycl/queue_wrapper.sycl b/sycl/src/utils/sycl/queue_wrapper.sycl index be0044e9..7c0635b0 100644 --- a/sycl/src/utils/sycl/queue_wrapper.sycl +++ b/sycl/src/utils/sycl/queue_wrapper.sycl @@ -6,7 +6,6 @@ */ // Local include(s). -#include "device_selector.hpp" #include "get_queue.hpp" #include "opaque_queue.hpp" #include "vecmem/utils/debug.hpp" @@ -17,10 +16,9 @@ namespace vecmem::sycl { -queue_wrapper::queue_wrapper(const std::string& deviceName) +queue_wrapper::queue_wrapper() : m_queue(nullptr), - m_managedQueue(std::make_unique( - device_selector(deviceName))) { + m_managedQueue(std::make_unique()) { m_queue = m_managedQueue.get(); VECMEM_DEBUG_MSG(1, diff --git a/tests/sycl/CMakeLists.txt b/tests/sycl/CMakeLists.txt index 57274c0f..4477834c 100644 --- a/tests/sycl/CMakeLists.txt +++ b/tests/sycl/CMakeLists.txt @@ -23,7 +23,5 @@ endif() vecmem_add_test( sycl "test_sycl_memory_resources.cpp" "test_sycl_containers.sycl" "test_sycl_jagged_containers.sycl" - "${CMAKE_CURRENT_SOURCE_DIR}/../../sycl/src/utils/sycl/device_selector.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/../../sycl/src/utils/sycl/device_selector.sycl" LINK_LIBRARIES vecmem::core vecmem::sycl GTest::gtest_main vecmem_testing_common ) diff --git a/tests/sycl/test_sycl_containers.sycl b/tests/sycl/test_sycl_containers.sycl index 5c70b028..256febc6 100644 --- a/tests/sycl/test_sycl_containers.sycl +++ b/tests/sycl/test_sycl_containers.sycl @@ -9,7 +9,6 @@ #include // Local include(s). -#include "../../sycl/src/utils/sycl/device_selector.hpp" #include "vecmem/containers/array.hpp" #include "vecmem/containers/const_device_array.hpp" #include "vecmem/containers/const_device_vector.hpp" @@ -33,7 +32,7 @@ class sycl_containers_test : public testing::Test {}; TEST_F(sycl_containers_test, shared_memory) { // Create the SYCL queue that we'll be using in the test. - cl::sycl::queue queue{vecmem::sycl::device_selector()}; + cl::sycl::queue queue; // The shared memory resource. vecmem::sycl::shared_memory_resource resource(&queue); @@ -90,7 +89,7 @@ TEST_F(sycl_containers_test, shared_memory) { TEST_F(sycl_containers_test, device_memory) { // Create the SYCL queue that we'll be using in the test. - cl::sycl::queue queue{vecmem::sycl::device_selector()}; + cl::sycl::queue queue; // The memory resources. vecmem::sycl::host_memory_resource host_resource(&queue); @@ -163,7 +162,7 @@ TEST_F(sycl_containers_test, device_memory) { TEST_F(sycl_containers_test, atomic_memory) { // Create the SYCL queue that we'll be using in the test. - cl::sycl::queue queue{vecmem::sycl::device_selector()}; + cl::sycl::queue queue; // The memory resources. vecmem::sycl::shared_memory_resource resource(&queue); @@ -216,7 +215,7 @@ TEST_F(sycl_containers_test, atomic_memory) { TEST_F(sycl_containers_test, extendable_memory) { // Create the SYCL queue that we'll be using in the test. - cl::sycl::queue queue{vecmem::sycl::device_selector()}; + cl::sycl::queue queue; // The memory resources. vecmem::sycl::host_memory_resource host_resource(&queue); @@ -277,7 +276,7 @@ TEST_F(sycl_containers_test, extendable_memory) { TEST_F(sycl_containers_test, array_memory) { // Create the SYCL queue that we'll be using in the test. - cl::sycl::queue queue{vecmem::sycl::device_selector()}; + cl::sycl::queue queue; // The memory resource(s). vecmem::sycl::shared_memory_resource shared_resource(&queue); diff --git a/tests/sycl/test_sycl_jagged_containers.sycl b/tests/sycl/test_sycl_jagged_containers.sycl index 74362578..81a1927b 100644 --- a/tests/sycl/test_sycl_jagged_containers.sycl +++ b/tests/sycl/test_sycl_jagged_containers.sycl @@ -9,7 +9,6 @@ #include // VecMem include(s). -#include "../../sycl/src/utils/sycl/device_selector.hpp" #include "vecmem/containers/array.hpp" #include "vecmem/containers/data/jagged_vector_buffer.hpp" #include "vecmem/containers/device_array.hpp" @@ -35,7 +34,7 @@ class sycl_jagged_containers_test : public testing::Test { public: /// Constructor, setting up the input data for the tests. sycl_jagged_containers_test() - : m_queue(vecmem::sycl::device_selector()), + : m_queue(), m_mem(&m_queue), m_vec({vecmem::vector({1, 2, 3, 4}, &m_mem), vecmem::vector({5, 6}, &m_mem),