Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions backends/source/dppl_sycl_queue_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,24 @@ void error_reporter (const std::string & msg)
class QMgrHelper
{
public:
static std::vector<cl::sycl::queue> cpu_queues;
static std::vector<cl::sycl::queue> gpu_queues;
static thread_local std::vector<cl::sycl::queue> active_queues;
static std::vector<cl::sycl::queue>& cpu_queues_()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick. Can you please add a space before the open paren? I usually ffollow the convention of adding a space before the open paren in function declaration. In the long term let us create a common coding style and formatter for VS Code so that everyone can be consistent.

{
static std::vector<cl::sycl::queue>* cpu_queues =
QMgrHelper::init_queues(info::device_type::cpu);
return *cpu_queues;
}
static std::vector<cl::sycl::queue>& gpu_queues_()
{
static std::vector<cl::sycl::queue>* gpu_queues =
QMgrHelper::init_queues(info::device_type::gpu);
return *gpu_queues;
}
static std::vector<cl::sycl::queue>& active_queues_()
{
thread_local static std::vector<cl::sycl::queue>* active_queues =
new std::vector<cl::sycl::queue>({default_selector()});
return *active_queues;
}

static __dppl_give DPPLSyclQueueRef
getQueue (DPPLSyclDeviceType DeviceTy, size_t DNum);
Expand All @@ -122,25 +137,19 @@ class QMgrHelper
static void
popSyclQueue ();

static cl::sycl::vector_class<cl::sycl::queue>
static cl::sycl::vector_class<cl::sycl::queue>*
init_queues (info::device_type device_ty)
{
std::vector<cl::sycl::queue> queues;
auto queues = new std::vector<cl::sycl::queue>();
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<cl::sycl::queue> QMgrHelper::active_queues
= {default_selector()};

std::vector<cl::sycl::queue> QMgrHelper::cpu_queues
= QMgrHelper::init_queues(info::device_type::cpu);

std::vector<cl::sycl::queue> QMgrHelper::gpu_queues
= QMgrHelper::init_queues(info::device_type::gpu);
#define active_queues active_queues_()
#define cpu_queues cpu_queues_()
#define gpu_queues gpu_queues_()

/*!
* Allocates a new copy of the present top of stack queue, which can be the
Expand Down