Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Morpheus_CustomBackend.hpp
1
24#ifndef MORPHEUS_CUSTOMBACKEND_HPP
25#define MORPHEUS_CUSTOMBACKEND_HPP
26
27#include <Morpheus_SpaceTraits.hpp>
28#include <fwd/Morpheus_Fwd_Spaces.hpp>
29
30namespace Morpheus {
74template <typename Space>
76 static_assert(has_execution_space_v<Space>,
77 "Space needs to have a valid Execution Space!");
78 static_assert(has_memory_space_v<Space>,
79 "Space needs to have a valid Memory Space!");
82 typename Space::execution_space;
84 typename Space::memory_space;
86 backend>;
87};
88
93namespace Custom {
105
106#if defined(MORPHEUS_ENABLE_SERIAL)
111
112#endif
113
114#if defined(MORPHEUS_ENABLE_OPENMP)
119
120#endif
121
122#if defined(MORPHEUS_ENABLE_CUDA)
130#endif
131
132#if defined(MORPHEUS_ENABLE_HIP)
137
141#endif
142} // namespace Custom
143
153
154#if defined(MORPHEUS_ENABLE_SERIAL)
158#endif
159
160#if defined(MORPHEUS_ENABLE_OPENMP)
164#endif
165
166#if defined(MORPHEUS_ENABLE_CUDA)
173#endif
174
175#if defined(MORPHEUS_ENABLE_HIP)
182#endif
183
188namespace Impl {
189template <typename T>
190struct is_custom_backend_helper : std::false_type {};
191
192template <typename Space>
193struct is_custom_backend_helper<CustomBackend<Space>> : std::true_type {};
194} // namespace Impl
209template <typename T>
210using is_custom_backend = typename Impl::is_custom_backend_helper<
211 typename std::remove_cv<T>::type>::type;
212
218template <class T>
220
227template <class T>
229 typedef char yes[1];
230 typedef char no[2];
231
232 template <class U>
233 static yes& test(
234 U*, typename std::enable_if<is_custom_backend_v<typename U::backend> ||
235 is_custom_backend_v<U>>::type* = nullptr);
236
237 template <class U>
238 static no& test(...);
239
240 public:
241 static const bool value = sizeof(test<T>(nullptr)) == sizeof(yes);
242};
248template <class T>
250
254} // namespace Morpheus
255
256#endif // MORPHEUS_CUSTOMBACKEND_HPP
Checks if the given type T has a valid custom backend i.e has a CustomBackend container.
Definition: Morpheus_CustomBackend.hpp:228
typename Impl::is_custom_backend_helper< typename std::remove_cv< T >::type >::type is_custom_backend
Checks if the given type T is a valid custom backend i.e is a CustomBackend container.
Definition: Morpheus_CustomBackend.hpp:211
constexpr bool is_custom_backend_v
Short-hand to is_custom_backend.
Definition: Morpheus_CustomBackend.hpp:219
constexpr bool has_custom_backend_v
Short-hand to has_custom_backend.
Definition: Morpheus_CustomBackend.hpp:249
Morpheus::CustomBackend< Kokkos::HIPSpace > HIPSpace
The Custom HIP memory space.
Definition: Morpheus_CustomBackend.hpp:140
Morpheus::CustomBackend< Kokkos::Serial > Serial
A Custom Space that launches kernels in serial using the Serial backend.
Definition: Morpheus_CustomBackend.hpp:110
Morpheus::CustomBackend< Kokkos::DefaultExecutionSpace > DefaultExecutionSpace
A Custom Space that launches kernels in the default Space.
Definition: Morpheus_CustomBackend.hpp:101
Morpheus::CustomBackend< Kokkos::CudaSpace > CudaSpace
The Custom Cuda memory space.
Definition: Morpheus_CustomBackend.hpp:129
Morpheus::CustomBackend< Kokkos::OpenMP > OpenMP
A Custom Space that launches kernels in parallel using the OpenMP backend.
Definition: Morpheus_CustomBackend.hpp:118
Morpheus::CustomBackend< Kokkos::HostSpace > HostSpace
The Custom Host memory space.
Definition: Morpheus_CustomBackend.hpp:104
Morpheus::CustomBackend< Kokkos::HIP > HIP
A Custom Space that launches kernels in parallel using the HIP backend.
Definition: Morpheus_CustomBackend.hpp:136
Morpheus::CustomBackend< Kokkos::Cuda > Cuda
A Custom Space that launches kernels in parallel using the Cuda backend.
Definition: Morpheus_CustomBackend.hpp:126
Morpheus::CustomBackend< Kokkos::DefaultHostExecutionSpace > DefaultHostExecutionSpace
A Custom Space that launches kernels in the default Host Space.
Definition: Morpheus_CustomBackend.hpp:97
Generic Morpheus interfaces.
Definition: dummy.cpp:24
A wrapper that converts a valid space into a custom backend.
Definition: Morpheus_CustomBackend.hpp:75
typename Space::execution_space execution_space
Execution space of custom backend.
Definition: Morpheus_CustomBackend.hpp:82
typename Space::memory_space memory_space
Memory space of the custom backend.
Definition: Morpheus_CustomBackend.hpp:84
A type that binds together the execution, memory space and backend.
Definition: Morpheus_Spaces.hpp:39