PLSSVM - Parallel Least Squares Support Vector Machine  2.0.0
A Least Squares Support Vector Machine implementation using different backends.
command_queue.hpp
Go to the documentation of this file.
1 
12 #ifndef PLSSVM_BACKENDS_OPENCL_DETAIL_COMMAND_QUEUE_HPP_
13 #define PLSSVM_BACKENDS_OPENCL_DETAIL_COMMAND_QUEUE_HPP_
14 #pragma once
15 
16 #include "plssvm/backends/OpenCL/detail/kernel.hpp" // plssvm::opencl::detail::kernel
17 
18 #include "CL/cl.h" // cl_context, cl_command_queue, cl_device_id
19 
20 #include <map> // std::map
21 
23 
29  public:
33  command_queue() = default;
39  command_queue(cl_context context, cl_device_id device);
40 
44  command_queue(const command_queue &) = delete;
49  command_queue(command_queue &&other) noexcept;
60 
65 
70  [[nodiscard]] operator cl_command_queue &() noexcept { return queue; }
75  [[nodiscard]] operator const cl_command_queue &() const noexcept { return queue; }
76 
83  template <typename real_type>
84  void add_kernel(compute_kernel_name name, kernel &&compute_kernel);
85 
93  template <typename real_type>
94  [[nodiscard]] const kernel &get_kernel(compute_kernel_name name) const;
95 
97  cl_command_queue queue{};
99  std::map<compute_kernel_name, kernel> float_kernels{};
101  std::map<compute_kernel_name, kernel> double_kernels{};
102 };
103 
104 } // namespace plssvm::opencl::detail
105 
106 #endif // PLSSVM_BACKENDS_OPENCL_DETAIL_COMMAND_QUEUE_HPP_
RAII wrapper class around a cl_command_queue.
Definition: command_queue.hpp:28
command_queue(const command_queue &)=delete
Delete copy-constructor to make command_queue a move only type.
command_queue & operator=(command_queue &&other) noexcept
Move-assignment-operator as command_queue is a move-only type.
~command_queue()
Release the cl_command_queue resources on destruction.
void add_kernel(compute_kernel_name name, kernel &&compute_kernel)
Add a new OpenCL compute_kernel used for name to this command queue.
command_queue & operator=(const command_queue &)=delete
Delete copy-assignment-operator to make command_queue a move only type.
std::map< compute_kernel_name, kernel > float_kernels
All OpenCL device kernel associated with the device corresponding to this command queue using float a...
Definition: command_queue.hpp:99
command_queue(command_queue &&other) noexcept
Move-constructor as command_queue is a move-only type.
cl_command_queue queue
The wrapped cl_command_queue.
Definition: command_queue.hpp:97
std::map< compute_kernel_name, kernel > double_kernels
All OpenCL device kernel associated with the device corresponding to this command queue using double ...
Definition: command_queue.hpp:101
const kernel & get_kernel(compute_kernel_name name) const
Get the OpenCL kernel used for name.
command_queue(cl_context context, cl_device_id device)
Construct a command queue with the provided information.
command_queue()=default
Empty default construct a command queue.
RAII wrapper class around a cl_context.
Definition: context.hpp:26
RAII wrapper class around a cl_kernel.
Definition: kernel.hpp:38
Defines a very small RAII wrapper around a cl_kernel.
Namespace containing OpenCL backend specific implementation details. Should not directly be used by u...
Definition: command_queue.hpp:22
compute_kernel_name
Enum class for all different OpenCL compute kernels.
Definition: kernel.hpp:24
constexpr std::string_view name
The name of the library.
Definition: version.hpp:26