22 #ifndef RAJA_Types_HPP
23 #define RAJA_Types_HPP
25 #include "RAJA/config.hpp"
29 #if defined(RAJA_USE_COMPLEX)
33 #include "camp/helpers.hpp"
71 namespace iteration_mapping
95 template<
size_t t_max_iterations>
170 template<
size_t max_iterations>
173 std::conditional_t<(max_iterations != named_usage::unspecified),
174 SizedLoopSpecifyingBase<max_iterations>,
203 template<
size_t max_iterations>
206 std::conditional_t<(max_iterations != named_usage::unspecified),
207 SizedLoopSpecifyingBase<max_iterations>,
244 template<
typename int_t,
int_t numerator,
int_t denominator>
247 static_assert(denominator != int_t(0),
"denominator must not be zero");
251 template<
typename new_
int_t>
253 Fraction<new_int_t, new_int_t(numerator), new_int_t(denominator)>;
255 static constexpr int_t
multiply(int_t val) noexcept
257 return (val / denominator) * numerator +
258 (val % denominator) * numerator / denominator;
270 #if defined(RAJA_USE_DOUBLE)
272 using Real_type = double;
274 #elif defined(RAJA_USE_FLOAT)
276 using Real_type = float;
279 #error RAJA Real_type is undefined!
283 #if defined(RAJA_USE_COMPLEX)
285 using Complex_type = std::complex<Real_type>;
296 #if defined(RAJA_COMPILER_ICC)
302 Real_type* RAJA_RESTRICT __attribute__((align_value(RAJA::DATA_ALIGN)));
307 #elif defined(RAJA_COMPILER_GNU)
309 #elif defined(RAJA_COMPILER_CLANG)
311 Real_type* RAJA_RESTRICT __attribute__((aligned(RAJA::DATA_ALIGN)));
323 #if defined(RAJA_USE_PTR_CLASS)
331 class ConstRestrictRealPtr
338 constexpr ConstRestrictRealPtr() : dptr(0) { ; }
340 constexpr ConstRestrictRealPtr(
const Real_type* d) : dptr(d) { ; }
342 constexpr ConstRestrictRealPtr& operator=(
const Real_type* d)
344 ConstRestrictRealPtr copy(d);
356 constexpr
operator const Real_type*() {
return dptr; }
362 constexpr
const Real_type*
get()
const {
return dptr; }
367 constexpr
const Real_type& operator[](
Index_type i)
const
369 return ((
const Real_type* RAJA_RESTRICT)dptr)[i];
378 const Real_type* dptr;
388 class RestrictRealPtr
395 constexpr RestrictRealPtr() : dptr(0) { ; }
397 constexpr RestrictRealPtr(Real_type* d) : dptr(d) { ; }
399 constexpr RestrictRealPtr& operator=(Real_type* d)
401 RestrictRealPtr copy(d);
413 constexpr
operator Real_type*() {
return dptr; }
418 constexpr
operator const Real_type*()
const {
return dptr; }
424 constexpr Real_type*
get() {
return dptr; }
430 constexpr
const Real_type*
get()
const {
return dptr; }
436 constexpr
operator ConstRestrictRealPtr()
438 return ConstRestrictRealPtr(dptr);
446 return ((Real_type * RAJA_RESTRICT) dptr)[i];
470 class ConstRestrictAlignedRealPtr
477 constexpr ConstRestrictAlignedRealPtr() : dptr(0) { ; }
479 constexpr ConstRestrictAlignedRealPtr(
const Real_type* d) : dptr(d) { ; }
481 constexpr ConstRestrictAlignedRealPtr& operator=(
const Real_type* d)
483 ConstRestrictAlignedRealPtr copy(d);
495 constexpr
operator const Real_type*() {
return dptr; }
501 constexpr
const Real_type*
get()
const {
return dptr; }
507 #if defined(RAJA_COMPILER_ICC)
509 constexpr
const Real_type& operator[](
Index_type i)
const
512 RAJA_ALIGN_DATA(dptr);
513 return ((
const Real_type* RAJA_RESTRICT)dptr)[i];
519 #elif defined(RAJA_COMPILER_GNU)
521 constexpr
const Real_type& operator[](
Index_type i)
const
524 return ((
const Real_type* RAJA_RESTRICT)RAJA_ALIGN_DATA(dptr))[i];
526 return ((
const Real_type* RAJA_RESTRICT)dptr)[i];
530 #elif defined(RAJA_COMPILER_XLC)
531 constexpr
const Real_type& operator[](
Index_type i)
const
533 RAJA_ALIGN_DATA(dptr);
534 return ((
const Real_type* RAJA_RESTRICT)dptr)[i];
537 #elif defined(RAJA_COMPILER_CLANG)
538 constexpr
const Real_type& operator[](
Index_type i)
const
544 #error RAJA compiler macro is undefined!
554 const Real_type* dptr;
564 class RestrictAlignedRealPtr
571 constexpr RestrictAlignedRealPtr() : dptr(0) { ; }
573 constexpr RestrictAlignedRealPtr(Real_type* d) : dptr(d) { ; }
575 constexpr RestrictAlignedRealPtr& operator=(Real_type* d)
577 RestrictAlignedRealPtr copy(d);
589 constexpr
operator Real_type*() {
return dptr; }
594 constexpr
operator const Real_type*()
const {
return dptr; }
600 constexpr Real_type*
get() {
return dptr; }
606 constexpr
const Real_type*
get()
const {
return dptr; }
612 constexpr
operator ConstRestrictAlignedRealPtr()
614 return ConstRestrictAlignedRealPtr(dptr);
621 #if defined(RAJA_COMPILER_ICC)
626 RAJA_ALIGN_DATA(dptr);
627 return ((Real_type * RAJA_RESTRICT) dptr)[i];
634 constexpr
const Real_type& operator[](
Index_type i)
const
637 RAJA_ALIGN_DATA(dptr);
638 return ((Real_type * RAJA_RESTRICT) dptr)[i];
644 #elif defined(RAJA_COMPILER_GNU)
649 return ((Real_type * RAJA_RESTRICT) RAJA_ALIGN_DATA(dptr))[i];
651 return ((Real_type * RAJA_RESTRICT) dptr)[i];
656 constexpr
const Real_type& operator[](
Index_type i)
const
659 return ((Real_type * RAJA_RESTRICT) RAJA_ALIGN_DATA(dptr))[i];
661 return ((Real_type * RAJA_RESTRICT) dptr)[i];
665 #elif defined(RAJA_COMPILER_XLC)
669 RAJA_ALIGN_DATA(dptr);
670 return ((Real_type * RAJA_RESTRICT) dptr)[i];
674 constexpr
const Real_type& operator[](
Index_type i)
const
676 RAJA_ALIGN_DATA(dptr);
677 return ((Real_type * RAJA_RESTRICT) dptr)[i];
680 #elif defined(RAJA_COMPILER_CLANG)
688 const Real_type& operator[](
Index_type i)
const
694 #error RAJA compiler macro is undefined!
712 #if defined(RAJA_USE_COMPLEX)
720 class ConstRestrictComplexPtr
727 constexpr ConstRestrictComplexPtr() : dptr(0) { ; }
729 constexpr ConstRestrictComplexPtr(
const Complex_type* d) : dptr(d) { ; }
731 constexpr ConstRestrictComplexPtr& operator=(
const Complex_type* d)
733 ConstRestrictComplexPtr copy(d);
745 constexpr
operator const Complex_type*()
const {
return dptr; }
751 constexpr
const Complex_type*
get()
const {
return dptr; }
756 constexpr
const Complex_type& operator[](
Index_type i)
const
758 return ((
const Complex_type* RAJA_RESTRICT)dptr)[i];
770 const Complex_type* dptr;
780 class RestrictComplexPtr
787 constexpr RestrictComplexPtr() : dptr(0) { ; }
789 constexpr RestrictComplexPtr(Complex_type* d) : dptr(d) { ; }
791 constexpr RestrictComplexPtr& operator=(Complex_type* d)
793 RestrictComplexPtr copy(d);
805 constexpr
operator Complex_type*() {
return dptr; }
810 constexpr
operator const Complex_type*()
const {
return dptr; }
816 constexpr Complex_type*
get() {
return dptr; }
822 constexpr
const Complex_type*
get()
const {
return dptr; }
828 constexpr
operator ConstRestrictComplexPtr()
830 return ConstRestrictComplexPtr(dptr);
836 constexpr Complex_type& operator[](
Index_type i)
838 return ((Complex_type * RAJA_RESTRICT) dptr)[i];
844 constexpr
const Complex_type& operator[](
Index_type i)
const
846 return ((Complex_type * RAJA_RESTRICT) dptr)[i];
877 #if defined(RAJA_USE_BARE_PTR)
878 using Real_ptr = Real_type*;
879 using const_Real_ptr =
const Real_type*;
881 #if defined(RAJA_USE_COMPLEX)
882 using Complex_ptr = Complex_type*;
883 using const_Complex_ptr =
const Complex_type*;
886 using UnalignedReal_ptr = Real_type*;
887 using const_UnalignedReal_ptr =
const Real_type*;
889 #elif defined(RAJA_USE_RESTRICT_PTR)
890 using Real_ptr = Real_type* RAJA_RESTRICT;
891 using const_Real_ptr =
const Real_type* RAJA_RESTRICT;
893 #if defined(RAJA_USE_COMPLEX)
894 using Complex_ptr = Complex_type* RAJA_RESTRICT;
895 using const_Complex_ptr =
const Complex_type* RAJA_RESTRICT;
898 using UnalignedReal_ptr = Real_type* RAJA_RESTRICT;
899 using const_UnalignedReal_ptr =
const Real_type* RAJA_RESTRICT;
901 #elif defined(RAJA_USE_RESTRICT_ALIGNED_PTR)
905 #if defined(RAJA_USE_COMPLEX)
906 using Complex_ptr = Complex_type* RAJA_RESTRICT;
907 using const_Complex_ptr =
const Complex_type* RAJA_RESTRICT;
910 using UnalignedReal_ptr = Real_type* RAJA_RESTRICT;
911 using const_UnalignedReal_ptr =
const Real_type* RAJA_RESTRICT;
913 #elif defined(RAJA_USE_PTR_CLASS)
914 using Real_ptr = RestrictAlignedRealPtr;
915 using const_Real_ptr = ConstRestrictAlignedRealPtr;
917 #if defined(RAJA_USE_COMPLEX)
918 using Complex_ptr = RestrictComplexPtr;
919 using const_Complex_ptr = ConstRestrictComplexPtr;
922 using UnalignedReal_ptr = RestrictRealPtr;
923 using const_UnalignedReal_ptr = ConstRestrictRealPtr;
926 #error RAJA pointer type is undefined!
959 size_t min_integer_type_size = 1,
960 size_t max_integer_type_size =
sizeof(
unsigned long long)>
963 static_assert(min_integer_type_size <= max_integer_type_size,
964 "incompatible min and max integer type size");
966 ((
alignof(T) >=
alignof(
unsigned long long) &&
967 sizeof(
unsigned long long) <= max_integer_type_size) ||
968 sizeof(
unsigned long) < min_integer_type_size),
971 ((
alignof(T) >=
alignof(
unsigned long) &&
972 sizeof(
unsigned long) <= max_integer_type_size) ||
973 sizeof(
unsigned int) < min_integer_type_size),
976 ((
alignof(T) >=
alignof(
unsigned int) &&
977 sizeof(
unsigned int) <= max_integer_type_size) ||
978 sizeof(
unsigned short) < min_integer_type_size),
981 ((
alignof(T) >=
alignof(
unsigned short) &&
982 sizeof(
unsigned short) <= max_integer_type_size) ||
983 sizeof(
unsigned char) < min_integer_type_size),
985 std::conditional_t<((
alignof(T) >=
alignof(
unsigned char) &&
986 sizeof(
unsigned char) <=
987 max_integer_type_size)),
990 static_assert(!std::is_same<integer_type, void>::value,
991 "could not find a compatible integer type");
992 static_assert(
sizeof(
integer_type) >= min_integer_type_size,
993 "integer_type smaller than min integer type size");
994 static_assert(
sizeof(
integer_type) <= max_integer_type_size,
995 "integer_type greater than max integer type size");
997 static constexpr
size_t num_integer_type =
1006 return num_integer_type;
1012 memcpy(&value, &array[0],
sizeof(T));
1018 memcpy(&array[0], &value,
sizeof(T));
1026 template<
typename T>
1030 : m_ref_to_val(val),
1031 m_prev_val(
std::move(val))
1033 m_ref_to_val = new_val;
1037 : m_ref_to_val(val),
1038 m_prev_val(
std::move(val))
1040 m_ref_to_val = std::move(new_val);
Header file for common RAJA internal macro definitions.
#define RAJA_HOST_DEVICE
Definition: macros.hpp:65
RAJA_INLINE RAJA_HOST_DEVICE auto operator+(LEFT_OPERAND const &left, RIGHT_OPERAND const &right) -> TensorAdd< typename NormalizeOperandHelper< LEFT_OPERAND >::return_type, RIGHT_OPERAND >
Definition: BinaryOperator.hpp:122
Definition: AlignedRangeIndexSetBuilders.cpp:35
IndexOwnership
Definition: types.hpp:218
@ Owned
Definition: types.hpp:220
@ Unowned
Definition: types.hpp:219
named_dim
Definition: types.hpp:53
const int UndefinedValue
Definition: types.hpp:232
std::ptrdiff_t Index_type
Definition: types.hpp:226
RAJA_HOST_DEVICE constexpr RAJA_INLINE RAJA::zip_tuple_element_t< I, zip_tuple< is_val, Ts... > > & get(zip_tuple< is_val, Ts... > &z) noexcept
Definition: zip_tuple.hpp:56
kernel_sync_requirement
Definition: types.hpp:63
named_usage
Definition: types.hpp:44
@ ignored
Definition: types.hpp:45
@ unspecified
Definition: types.hpp:46
const TDRAReal_ptr const_TDRAReal_ptr
Definition: types.hpp:319
Real_type *RAJA_RESTRICT TDRAReal_ptr
RAJA scalar type definitions.
Definition: types.hpp:317
Definition: ListSegment.hpp:416
RAJA_INLINE void swap(RAJA::TypedListSegment< StorageT > &a, RAJA::TypedListSegment< StorageT > &b)
Specialization of std::swap for TypedListSegment.
Definition: ListSegment.hpp:420
Definition: types.hpp:246
static constexpr int_t multiply(int_t val) noexcept
Definition: types.hpp:255
Definition: types.hpp:239
Abstracts T into an equal or greater size array of integers whose size is between min_integer_type_si...
Definition: types.hpp:962
RAJA_HOST_DEVICE T get_value() const
Definition: types.hpp:1009
std::conditional_t<((alignof(T) >=alignof(unsigned long long) &&sizeof(unsigned long long)<=max_integer_type_size)||sizeof(unsigned long)< min_integer_type_size), unsigned long long, std::conditional_t<((alignof(T) >=alignof(unsigned long) &&sizeof(unsigned long)<=max_integer_type_size)||sizeof(unsigned int)< min_integer_type_size), unsigned long, std::conditional_t<((alignof(T) >=alignof(unsigned int) &&sizeof(unsigned int)<=max_integer_type_size)||sizeof(unsigned short)< min_integer_type_size), unsigned int, std::conditional_t<((alignof(T) >=alignof(unsigned short) &&sizeof(unsigned short)<=max_integer_type_size)||sizeof(unsigned char)< min_integer_type_size), unsigned short, std::conditional_t<((alignof(T) >=alignof(unsigned char) &&sizeof(unsigned char)<=max_integer_type_size)), unsigned char, void > >> >> integer_type
Definition: types.hpp:989
RAJA_HOST_DEVICE void set_value(T value)
Definition: types.hpp:1016
constexpr RAJA_HOST_DEVICE size_t array_size() const
Definition: types.hpp:1004
Abstracts access to memory using normal memory accesses.
Definition: types.hpp:938
static RAJA_HOST_DEVICE constexpr RAJA_INLINE T get(T *ptr, size_t i)
Definition: types.hpp:940
static RAJA_HOST_DEVICE constexpr RAJA_INLINE void set(T *ptr, size_t i, T val)
Definition: types.hpp:946
Assign a new value to an object and restore the object's previous value at the end of the current sco...
Definition: types.hpp:1028
~ScopedAssignment()
Definition: types.hpp:1049
constexpr ScopedAssignment(T &val, T const &new_val)
Definition: types.hpp:1029
ScopedAssignment(ScopedAssignment const &)=delete
constexpr ScopedAssignment(T &val, T &&new_val)
Definition: types.hpp:1036
ScopedAssignment(ScopedAssignment &&)=delete
ScopedAssignment & operator=(ScopedAssignment &&)=delete
ScopedAssignment & operator=(ScopedAssignment const &)=delete
Definition: types.hpp:176
Definition: types.hpp:119
Definition: types.hpp:143
static constexpr size_t max_iterations
Definition: types.hpp:98
Definition: types.hpp:209