diff --git a/backends/source/dppl_sycl_queue_interface.cpp b/backends/source/dppl_sycl_queue_interface.cpp index 2c359c6abe..cf215c6795 100644 --- a/backends/source/dppl_sycl_queue_interface.cpp +++ b/backends/source/dppl_sycl_queue_interface.cpp @@ -103,9 +103,29 @@ void error_reporter (const std::string & msg) class QMgrHelper { public: - static std::vector cpu_queues; - static std::vector gpu_queues; - static thread_local std::vector active_queues; + static std::vector& + cpu_queues_ () + { + static std::vector* cpu_queues = + QMgrHelper::init_queues(info::device_type::cpu); + return *cpu_queues; + } + + static std::vector& + gpu_queues_ () + { + static std::vector* gpu_queues = + QMgrHelper::init_queues(info::device_type::gpu); + return *gpu_queues; + } + + static std::vector& + active_queues_ () + { + thread_local static std::vector* active_queues = + new std::vector({default_selector()}); + return *active_queues; + } static __dppl_give DPPLSyclQueueRef getQueue (DPPLSyclDeviceType DeviceTy, size_t DNum); @@ -122,25 +142,23 @@ class QMgrHelper static void popSyclQueue (); - static cl::sycl::vector_class + static cl::sycl::vector_class* init_queues (info::device_type device_ty) { - std::vector queues; + auto queues = new std::vector(); for(auto d : device::get_devices(device_ty)) - queues.emplace_back(d); + queues->emplace_back(d); return queues; } }; -// Initialize the active_queue with the default queue -thread_local std::vector QMgrHelper::active_queues - = {default_selector()}; - -std::vector QMgrHelper::cpu_queues - = QMgrHelper::init_queues(info::device_type::cpu); - -std::vector QMgrHelper::gpu_queues - = QMgrHelper::init_queues(info::device_type::gpu); +// make function call like access to variable +// it is for minimizing code changes during replacing static vars with functions +// it could be refactored by replacing variable with function call +// scope of this variables is only this file +#define cpu_queues cpu_queues_() +#define gpu_queues gpu_queues_() +#define active_queues active_queues_() /*! * Allocates a new copy of the present top of stack queue, which can be the