PLSSVM - Parallel Least Squares Support Vector Machine  2.0.0
A Least Squares Support Vector Machine implementation using different backends.
backend_types.hpp
Go to the documentation of this file.
1 
13 #ifndef PLSSVM_BACKEND_TYPES_HPP_
14 #define PLSSVM_BACKEND_TYPES_HPP_
15 #pragma once
16 
17 #include "plssvm/backends/SYCL/implementation_type.hpp" // plssvm::sycl::implementation_type
18 #include "plssvm/detail/type_traits.hpp" // plssvm::detail::remove_cvref_t
19 #include "plssvm/target_platforms.hpp" // plssvm::list_available_target_platforms
20 
21 #include <iosfwd> // forward declare std::ostream and std::istream
22 #include <vector> // std::vector
23 
24 namespace plssvm {
25 
30 enum class backend_type {
32  automatic,
34  openmp,
36  cuda,
38  hip,
40  opencl,
42  sycl
43 };
44 
50 [[nodiscard]] std::vector<backend_type> list_available_backends();
51 
58 [[nodiscard]] backend_type determine_default_backend(const std::vector<backend_type> &available_backends = list_available_backends(),
59  const std::vector<target_platform> &available_target_platforms = list_available_target_platforms());
60 
67 std::ostream &operator<<(std::ostream &out, backend_type backend);
68 
75 std::istream &operator>>(std::istream &in, backend_type &backend);
76 
78 // clang-format off
79 // Forward declare all possible C-SVMs.
80 namespace openmp { class csvm; }
81 namespace cuda { class csvm; }
82 namespace hip { class csvm; }
83 namespace opencl { class csvm; }
84 namespace hipsycl { class csvm; }
85 namespace dpcpp { class csvm; }
86 // clang-format on
87 
88 namespace detail {
89 
93 template <typename T>
94 struct csvm_to_backend_type {};
95 
99 template <>
100 struct csvm_to_backend_type<openmp::csvm> {
102  static constexpr backend_type value = backend_type::openmp;
103 };
107 template <>
108 struct csvm_to_backend_type<cuda::csvm> {
110  static constexpr backend_type value = backend_type::cuda;
111 };
115 template <>
116 struct csvm_to_backend_type<hip::csvm> {
118  static constexpr backend_type value = backend_type::hip;
119 };
123 template <>
124 struct csvm_to_backend_type<opencl::csvm> {
126  static constexpr backend_type value = backend_type::opencl;
127 };
132 template <>
133 struct csvm_to_backend_type<hipsycl::csvm> {
135  static constexpr backend_type value = backend_type::sycl;
138 };
143 template <>
144 struct csvm_to_backend_type<dpcpp::csvm> {
146  static constexpr backend_type value = backend_type::sycl;
149 };
150 
151 } // namespace detail
153 
160 template <typename T>
161 struct csvm_to_backend_type : detail::csvm_to_backend_type<detail::remove_cvref_t<T>> {};
166 template <typename T>
168 
169 } // namespace plssvm
170 
171 #endif // PLSSVM_BACKEND_TYPES_HPP_
Base class for all C-SVM backends.
Definition: csvm.hpp:50
Defines an enumeration holding all possible SYCL implementations.
implementation_type
Enum class for all possible SYCL implementation types.
Definition: implementation_type.hpp:24
The main namespace containing all public API functions.
Definition: backend_types.hpp:24
std::istream & operator>>(std::istream &in, backend_type &backend)
Use the input-stream in to initialize the backend type.
std::vector< backend_type > list_available_backends()
Return a list of all currently available backends.
constexpr backend_type csvm_to_backend_type_v
Get the plssvm::backend_type of the C-SVM class of type T. Ignores all top-level const,...
Definition: backend_types.hpp:167
std::ostream & operator<<(std::ostream &out, backend_type backend)
Output the backend to the given output-stream out.
std::vector< target_platform > list_available_target_platforms()
Return a list of all currently available target platforms.
backend_type
Enum class for all possible backend types.
Definition: backend_types.hpp:30
backend_type determine_default_backend(const std::vector< backend_type > &available_backends=list_available_backends(), const std::vector< target_platform > &available_target_platforms=list_available_target_platforms())
Returns the default backend (if plssvm::backend_type::automatic is used) given the backend and target...
Get the plssvm::backend_type of the C-SVM class of type T. Ignores all top-level const,...
Definition: backend_types.hpp:161
Defines an enumeration holding all possible target platforms. Can also include targets not available ...
Defines some generic type traits used in the PLSSVM library.