PLSSVM - Parallel Least Squares Support Vector Machine  2.0.0
A Least Squares Support Vector Machine implementation using different backends.
context.hpp
Go to the documentation of this file.
1 
12 #ifndef PLSSVM_BACKENDS_OPENCL_DETAIL_CONTEXT_HPP_
13 #define PLSSVM_BACKENDS_OPENCL_DETAIL_CONTEXT_HPP_
14 #pragma once
15 
16 #include "CL/cl.h" // cl_context, cl_platform_id, cl_device_id
17 
18 #include <vector> // std::vector
19 
20 namespace plssvm::opencl::detail {
21 
26 class context {
27  public:
31  context() = default;
38  context(cl_context device_context, cl_platform_id platform, std::vector<cl_device_id> devices);
39 
43  context(const context &) = delete;
48  context(context &&other) noexcept;
52  context &operator=(const context &) = delete;
59 
64 
69  [[nodiscard]] operator cl_context &() noexcept { return device_context; }
74  [[nodiscard]] operator const cl_context &() const noexcept { return device_context; }
75 
77  cl_context device_context{};
79  cl_platform_id platform{};
81  std::vector<cl_device_id> devices{};
82 };
83 
84 } // namespace plssvm::opencl::detail
85 
86 #endif // PLSSVM_BACKENDS_OPENCL_DETAIL_CONTEXT_HPP_
RAII wrapper class around a cl_context.
Definition: context.hpp:26
cl_context device_context
The OpenCL context associated with the platform containing the respective devices.
Definition: context.hpp:77
context & operator=(context &&other)
Move-assignment-operator as context is a move-only type.
~context()
Release the context resources on destruction.
cl_platform_id platform
The OpenCL platform associated with this context.
Definition: context.hpp:79
context(cl_context device_context, cl_platform_id platform, std::vector< cl_device_id > devices)
Construct a new OpenCL context.
context(const context &)=delete
Delete copy-constructor to make context a move only type.
context & operator=(const context &)=delete
Delete copy-assignment-operator to make context a move only type.
context()=default
Empty default construct context.
std::vector< cl_device_id > devices
All devices associated with this context.
Definition: context.hpp:81
context(context &&other) noexcept
Move-constructor as context is a move-only type.
Namespace containing OpenCL backend specific implementation details. Should not directly be used by u...
Definition: command_queue.hpp:22