1#ifndef included_AMP_CSRConfig
2#define included_AMP_CSRConfig
4#include "AMP/AMP_TPLs.h"
6#include "AMP/utils/Memory.h"
9 #include "HYPRE_utilities.h"
32 static constexpr bool host_accessible =
true;
33 static constexpr bool device_accessible =
false;
34 static const char *
name() {
return "host"; }
39 using type = DeviceAllocator<void>;
42 static constexpr bool host_accessible =
false;
43 static constexpr bool device_accessible =
true;
44 static const char *name() {
return "device"; }
48 using type = ManagedAllocator<void>;
51 static constexpr bool host_accessible =
true;
52 static constexpr bool device_accessible =
true;
53 static const char *name() {
return "managed"; }
63 static const char *
name() {
return "int"; }
69 static const char *
name() {
return "size_t"; }
74 using type =
long long int;
76 static const char *
name() {
return "long long"; }
85 static const char *
name() {
return "single precision"; }
91 static const char *
name() {
return "double precision"; }
98 static const char *
name() {
return "long double"; }
108 using I = std::uint16_t;
131 using element = std::tuple_element_t<index, components>;
135template<alloc Alloc, index local, index global, scalar Scalar>
137 using I = std::uint16_t;
141 static constexpr I get( std::integer_sequence<I, Is...> )
145 static constexpr auto value =
get( std::make_integer_sequence<
I,
sizeof...( vs )>{} );
149template<alloc a, index l, index g, scalar s>
152#define AMP_GEN_MODE( i1_name, i1_id, i2_name, i2_id ) \
153 h##i1_name##i2_name##f = make_mode_v<alloc::host, i1_id, i2_id, scalar::f32>, \
154 h##i1_name##i2_name##d = make_mode_v<alloc::host, i1_id, i2_id, scalar::f64>, \
155 d##i1_name##i2_name##f = make_mode_v<alloc::device, i1_id, i2_id, scalar::f32>, \
156 d##i1_name##i2_name##d = make_mode_v<alloc::device, i1_id, i2_id, scalar::f64>, \
157 m##i1_name##i2_name##f = make_mode_v<alloc::managed, i1_id, i2_id, scalar::f32>, \
158 m##i1_name##i2_name##d = make_mode_v<alloc::managed, i1_id, i2_id, scalar::f64>
165 other = std::numeric_limits<std::uint16_t>::max()
169#define DEFER( X ) X EMPTY()
172#if defined( AMP_USE_HYPRE )
175 #define CSR_CONFIG_FORALL_HYPRE_HOST( INST )
176 #ifdef AMP_USE_DEVICE
177 #define CSR_CONFIG_FORALL_HYPRE_DEVICE( INST )
179 #define CSR_CONFIG_CC_FORALL_HYPRE( INST )
180 #define CSR_CONFIG_CC_FORALL0_HYPRE( F, G )
183#define CSR_CONFIG_FORALL_HOST( INST ) \
184 INST( csr_mode::hiIf ) \
185 INST( csr_mode::hiId ) \
186 CSR_CONFIG_FORALL_HYPRE_HOST( INST )
187#define CSR_CONFIG_CC_FORALL_HOST( F, G ) \
188 F( G, csr_mode::hiIf ) \
189 F( G, csr_mode::hiId )
192 #define CSR_CONFIG_FORALL_DEVICE( INST ) \
193 INST( csr_mode::diIf ) \
194 INST( csr_mode::diId ) \
195 INST( csr_mode::miIf ) \
196 INST( csr_mode::miId ) \
197 CSR_CONFIG_FORALL_HYPRE_DEVICE( INST )
199 #define CSR_CONFIG_CC_FORALL_DEVICE( F, G ) \
200 F( G, csr_mode::diIf ) \
201 F( G, csr_mode::diId ) \
202 F( G, csr_mode::miIf ) \
203 F( G, csr_mode::miId )
205 #define CSR_CONFIG_FORALL_DEVICE( INST )
206 #define CSR_CONFIG_CC_FORALL_DEVICE( F, G )
209#define CSR_CONFIG_FORALL( INST ) \
210 CSR_CONFIG_FORALL_HOST( INST ) \
211 CSR_CONFIG_FORALL_DEVICE( INST )
213#define CSR_CONFIG_CC_FORALL0( F, G ) \
214 CSR_CONFIG_CC_FORALL_HOST( F, G ) \
215 CSR_CONFIG_CC_FORALL_DEVICE( F, G )
216#define CSR_CONFIG_CC_FORALL1() CSR_CONFIG_CC_FORALL0
217#define CSR_CONFIG_CC_FORALL2( F, G ) DEFER( CSR_CONFIG_CC_FORALL1 )()( F, G )
218#define CSR_CONFIG_CC_FORALL( INST ) \
219 EXPAND( CSR_CONFIG_CC_FORALL0( CSR_CONFIG_CC_FORALL2, INST ) ) \
220 CSR_CONFIG_CC_FORALL_HYPRE( INST )
249#define CSR_INOUT_CONFIG_MIGRATE_LOOP( mode_in, INST ) \
250 CSR_CONFIG_CC_FORALL0( INST, mode_in ) \
251 CSR_CONFIG_CC_FORALL0_HYPRE( INST, mode_in )
253#define CSR_INOUT_CONFIG_MIGRATE_OUTLIST_HOST( INST ) \
254 CSR_INOUT_CONFIG_MIGRATE_LOOP( csr_mode::hiIf, INST ) \
255 CSR_INOUT_CONFIG_MIGRATE_LOOP( csr_mode::hiId, INST )
257#if defined( AMP_USE_DEVICE )
258 #define CSR_INOUT_CONFIG_MIGRATE_OUTLIST_DEVICE( INST ) \
259 CSR_INOUT_CONFIG_MIGRATE_LOOP( csr_mode::miIf, INST ) \
260 CSR_INOUT_CONFIG_MIGRATE_LOOP( csr_mode::miId, INST ) \
261 CSR_INOUT_CONFIG_MIGRATE_LOOP( csr_mode::diIf, INST ) \
262 CSR_INOUT_CONFIG_MIGRATE_LOOP( csr_mode::diId, INST )
264 #define CSR_INOUT_CONFIG_MIGRATE_OUTLIST_DEVICE( INST )
268 #define CSR_INOUT_CONFIG_MIGRATE_OUTLIST_HYPRE_HOST( INST )
269 #define CSR_INOUT_CONFIG_MIGRATE_OUTLIST_HYPRE_DEVICE( INST )
272#define CSR_INOUT_CONFIG_MIGRATE( INST ) \
273 CSR_INOUT_CONFIG_MIGRATE_OUTLIST_HOST( INST ) \
274 CSR_INOUT_CONFIG_MIGRATE_OUTLIST_DEVICE( INST ) \
275 CSR_INOUT_CONFIG_MIGRATE_OUTLIST_HYPRE_HOST( INST ) \
276 CSR_INOUT_CONFIG_MIGRATE_OUTLIST_HYPRE_DEVICE( INST )
279template<alloc Alloc, index LocalInd, index GlobalInd, scalar Scalar>
287 static_cast<csr_mode>( make_mode_v<allocator, lidx, gidx, scalar_id> );
294 template<alloc new_alloc>
298 template<alloc new_alloc>
301 template<scalar new_scalar>
305 template<scalar new_scalar>
308 template<index new_l
idx>
320template<csr_mode mode,
class L>
322 static constexpr auto value =
static_cast<typename L::type
>(
323 (
static_cast<std::uint16_t
>( mode ) & L::mask ) >> L::shift );
326template<csr_mode mode>
329template<csr_mode mode>
332template<csr_mode mode>
335template<csr_mode mode>
342 return static_cast<typename L::type
>( (
static_cast<std::uint16_t
>( mode ) & L::mask ) >>
346inline auto get_lidx(
csr_mode mode ) {
return get_from_mode<csr_mode_layout::lidx>( mode ); }
347inline auto get_gidx(
csr_mode mode ) {
return get_from_mode<csr_mode_layout::gidx>( mode ); }
350template<csr_mode mode>
355template<csr_mode mode>
363#define X( C ) , config_mode_t<C>
370template<
class Ignore,
class... Cs>
379template<
class C,
class L>
381template<
class C,
class... Cs>
383 static constexpr bool value = ( std::is_same_v<C, Cs> || ... );
406#if defined( AMP_USE_HYPRE )
#define CSR_CONFIG_FORALL(INST)
#define AMP_GEN_MODE(i1_name, i1_id, i2_name, i2_id)
Scalar is a class used to store a scalar variable that may be different types/precision.
typename ignore_first< built_configs_extra_first >::type built_configs
constexpr bool is_config_built
constexpr index get_lidx_v
constexpr scalar get_scalar_v
auto get_gidx(csr_mode mode)
detail::built_configs built_configs
bool is_built(csr_mode mode)
constexpr index get_gidx_v
DefaultCSRConfig< alloc::host > DefaultHostCSRConfig
constexpr alloc get_alloc_v
auto get_lidx(csr_mode mode)
CSRConfig< Alloc, index::i32, index::i64, scalar::f64 > DefaultCSRConfig
constexpr std::uint16_t make_mode_v
auto get_from_mode(csr_mode mode)
auto get_alloc(csr_mode mode)
auto get_scalar(csr_mode mode)
typename config_mode< mode >::type config_mode_t
MemoryType
Enum to store pointer type.
std::allocator< TYPE > HostAllocator
typename set_scalar< new_scalar >::type set_scalar_t
typename alloc_info< Alloc >::type allocator_type
typename scalar_info< scalar_id >::type scalar_t
static constexpr scalar scalar_id
static constexpr index gidx
static constexpr alloc allocator
static constexpr index lidx
typename index_info< gidx >::type gidx_t
typename index_info< lidx >::type lidx_t
static constexpr csr_mode mode
typename set_alloc< new_alloc >::type set_alloc_t
HostAllocator< void > type
static const char * name()
std::tuple_element_t< index, components > element
std::tuple< alloc, lidx, gidx, scalar > components
static constexpr auto value
static const char * name()
static const char * name()
static const char * name()
static constexpr I get(std::integer_sequence< I, Is... >)
static constexpr auto value
static const char * name()
static const char * name()
static const char * name()