12 #ifndef PLSSVM_CSVM_FACTORY_HPP_
13 #define PLSSVM_CSVM_FACTORY_HPP_
26 #if defined(PLSSVM_HAS_OPENMP_BACKEND)
29 #if defined(PLSSVM_HAS_CUDA_BACKEND)
32 #if defined(PLSSVM_HAS_HIP_BACKEND)
35 #if defined(PLSSVM_HAS_OPENCL_BACKEND)
38 #if defined(PLSSVM_HAS_SYCL_BACKEND)
39 #if defined(PLSSVM_SYCL_BACKEND_HAS_DPCPP)
42 #if defined(PLSSVM_SYCL_BACKEND_HAS_HIPSYCL)
48 #include "igor/igor.hpp"
51 #include <type_traits>
67 template <
typename csvm_type,
typename... Args>
70 if constexpr (csvm_backend_exists_v<csvm_type>) {
72 if constexpr (std::is_constructible_v<csvm_type, Args...>) {
73 return std::make_unique<csvm_type>(std::forward<Args>(args)...);
75 throw unsupported_backend_exception{ fmt::format(
"Provided invalid (named) arguments for the {} backend!", csvm_to_backend_type_v<csvm_type>) };
90 template <
typename... Args>
93 igor::parser parser{ args... };
98 if constexpr (parser.has(sycl_implementation_type)) {
106 return make_csvm_default_impl<sycl::csvm>(std::forward<Args>(args)...);
108 return make_csvm_default_impl<dpcpp::csvm>(std::forward<Args>(args)...);
110 return make_csvm_default_impl<hipsycl::csvm>(std::forward<Args>(args)...);
123 template <
typename... Args>
129 return make_csvm_default_impl<openmp::csvm>(std::forward<Args>(args)...);
131 return make_csvm_default_impl<cuda::csvm>(std::forward<Args>(args)...);
133 return make_csvm_default_impl<hip::csvm>(std::forward<Args>(args)...);
135 return make_csvm_default_impl<opencl::csvm>(std::forward<Args>(args)...);
157 template <
typename... Args>
168 template <
typename... Args>
169 [[nodiscard]]
inline std::unique_ptr<csvm>
make_csvm(Args &&...args) {
Defines an enumeration holding all possible backends. Can also include backends not available on the ...
Defines a C-SVM using the CUDA backend.
Defines a C-SVM using the HIP backend.
Defines a C-SVM using the OpenCL backend.
Defines a C-SVM using the OpenMP backend.
Defines a base C-SVM used for the different SYCL backends using DPC++ as SYCL implementation.
Global compile-time constants specific to the SYCL backend.
Defines a base C-SVM used for the different SYCL backends using hipSYCL as SYCL implementation.
Exception type thrown if the requested backend is not supported on the target machine.
Definition: exceptions.hpp:127
Defines the base class for all C-SVM backends and implements the functionality shared by all of them.
Implements custom exception classes derived from std::runtime_error including source location informa...
Defines an enumeration holding all possible SYCL implementations.
std::unique_ptr< csvm > make_csvm_impl(const backend_type backend, Args &&...args)
Create a new C-SVM using the backend type and the additional parameter args.
Definition: csvm_factory.hpp:124
std::remove_cv_t< std::remove_reference_t< T > > remove_cvref_t
Remove the topmost reference- and cv-qualifiers.
Definition: type_traits.hpp:46
std::unique_ptr< csvm > make_csvm_sycl_impl([[maybe_unused]] Args &&...args)
Construct a SYCL C-SVM using the parameters args.
Definition: csvm_factory.hpp:91
std::unique_ptr< csvm > make_csvm_default_impl([[maybe_unused]] Args &&...args)
Construct a C-SVM using the parameters args.
Definition: csvm_factory.hpp:68
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::unique_ptr< csvm > make_csvm(const backend_type backend, Args &&...args)
Create a new C-SVM using the backend type and additional parameter args.
Definition: csvm_factory.hpp:158
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...
Defines some generic type traits used in the PLSSVM library.