Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Morpheus_GenericBackend.hpp
1
24#ifndef MORPHEUS_GENERICBACKEND_HPP
25#define MORPHEUS_GENERICBACKEND_HPP
26
27#include <Morpheus_SpaceTraits.hpp>
28
29namespace Morpheus {
67template <typename Space>
69 static_assert(has_execution_space_v<Space>,
70 "Space needs to have a valid Execution Space!");
71 static_assert(has_memory_space_v<Space>,
72 "Space needs to have a valid Memory Space!");
75 typename Space::execution_space;
77 typename Space::memory_space;
80 backend>;
81};
82
87namespace Generic {
99
100#if defined(MORPHEUS_ENABLE_SERIAL)
105#endif
106
107#if defined(MORPHEUS_ENABLE_OPENMP)
112#endif
113
114#if defined(MORPHEUS_ENABLE_CUDA)
122#endif
123
124#if defined(MORPHEUS_ENABLE_HIP)
131using HIPSpace = Morpheus::GenericSpace<Kokkos::HIPSpace>;
132#endif
133} // namespace Generic
134
139namespace Impl {
140template <typename T>
141struct is_generic_backend_helper : std::false_type {};
142
143template <typename Space>
144struct is_generic_backend_helper<GenericBackend<Space>> : std::true_type {};
145
146template <typename T>
147using is_generic_backend = typename Impl::is_generic_backend_helper<
148 typename std::remove_cv<T>::type>::type;
149} // namespace Impl
150
151// Forward decl
152template <class T>
153class has_backend;
170template <class T>
172 typedef char yes[1];
173 typedef char no[2];
174
175 template <class U>
176 static yes& test(
177 U*,
178 typename std::enable_if<
179 Impl::is_generic_backend<U>::value || is_execution_space<U>::value ||
180 is_memory_space<U>::value || Kokkos::is_device<U>::value>::type* =
181 nullptr);
182
183 template <class U>
184 static no& test(...);
185
186 public:
187 static const bool value = sizeof(test<T>(nullptr)) == sizeof(yes);
188};
194template <class T>
196
204template <class T>
206 typedef char yes[1];
207 typedef char no[2];
208
209 template <class U>
210 static yes& test(
211 U*, typename std::enable_if<is_generic_backend_v<typename U::backend> ||
212 is_generic_backend_v<U>>::type* = nullptr);
213
214 template <class U>
215 static no& test(...);
216
217 public:
218 static const bool value = sizeof(test<T>(nullptr)) == sizeof(yes);
219};
225template <class T>
227
231} // namespace Morpheus
232
233#endif // MORPHEUS_GENERICBACKEND_HPP
Checks if the given type T has a valid generic backend i.e has a GenericBackend container....
Definition: Morpheus_GenericBackend.hpp:205
Checks if the given type T is a valid supported execution space.
Definition: Morpheus_SpaceTraits.hpp:111
Checks if the given type T is a valid generic backend i.e is a GenericBackend container....
Definition: Morpheus_GenericBackend.hpp:171
Checks if the given type T is a valid supported memory space.
Definition: Morpheus_SpaceTraits.hpp:46
constexpr bool has_generic_backend_v
Short-hand to has_generic_backend.
Definition: Morpheus_GenericBackend.hpp:226
constexpr bool is_generic_backend_v
Short-hand to is_generic_backend.
Definition: Morpheus_GenericBackend.hpp:195
Morpheus::GenericSpace< Kokkos::HIPSpace > HIPSpace
The Generic HIP memory space.
Definition: Morpheus_GenericBackend.hpp:131
Generic Morpheus interfaces.
Definition: dummy.cpp:24
A type that binds together the execution, memory space and backend.
Definition: Morpheus_Spaces.hpp:39
A wrapper that converts a valid space into a generic backend.
Definition: Morpheus_GenericBackend.hpp:68
typename Space::memory_space memory_space
Memory space of generic backend.
Definition: Morpheus_GenericBackend.hpp:77
typename Space::execution_space execution_space
Execution space of generic backend.
Definition: Morpheus_GenericBackend.hpp:75