16#ifndef CABANA_SLICE_HPP
17#define CABANA_SLICE_HPP
22#include <impl/Cabana_TypeTraits.hpp>
24#include <Kokkos_Core.hpp>
35template <
int SOASTRIDE,
int VLEN,
int DIM0 = 0,
int DIM1 = 0,
int DIM2 = 0,
36 int DIM3 = 0,
int DIM4 = 0,
int DIM5 = 0>
44 is_extent_constructible =
true
48 static constexpr int Stride = SOASTRIDE;
52 static constexpr int D0 = DIM0;
54 static constexpr int D1 = DIM1;
56 static constexpr int D2 = DIM2;
58 static constexpr int D3 = DIM3;
60 static constexpr int D4 = DIM4;
62 static constexpr int D5 = DIM5;
77 KOKKOS_INLINE_FUNCTION
80 size_t d0 =
D0,
size_t d1 =
D1,
81 size_t d2 =
D2,
size_t d3 =
D3,
82 size_t d4 =
D4,
size_t d5 =
D5 )
83 :
dimension{ num_soa, vector_length, d0, d1, d2, d3, d4, d5 }
95template <
class Dimension,
int... LayoutDims>
96struct ViewOffset<Dimension, Kokkos::LayoutCabanaSlice<LayoutDims...>, void>
99 using is_mapping_plugin = std::true_type;
100 using is_regular = std::true_type;
102 typedef size_t size_type;
103 typedef Dimension dimension_type;
106 static constexpr int Stride = array_layout::Stride;
107 static constexpr int VectorLength = array_layout::VectorLength;
108 static constexpr int D0 = array_layout::D0;
109 static constexpr int D1 = array_layout::D1;
110 static constexpr int D2 = array_layout::D2;
111 static constexpr int D3 = array_layout::D3;
112 static constexpr int D4 = array_layout::D4;
113 static constexpr int D5 = array_layout::D5;
115 dimension_type m_dim;
120 template <
typename S>
121 KOKKOS_INLINE_FUNCTION
constexpr size_type operator()( S
const& s )
const
127 template <
typename S,
typename A>
128 KOKKOS_INLINE_FUNCTION
constexpr size_type operator()( S
const& s,
131 return Stride * s + a;
135 template <
typename S,
typename A,
typename I0>
136 KOKKOS_INLINE_FUNCTION
constexpr size_type
137 operator()( S
const& s, A
const& a, I0
const& i0 )
const
139 return Stride * s + a + VectorLength * i0;
143 template <
typename S,
typename A,
typename I0,
typename I1>
144 KOKKOS_INLINE_FUNCTION
constexpr size_type
145 operator()( S
const& s, A
const& a, I0
const& i0, I1
const& i1 )
const
147 return Stride * s + a + VectorLength * ( i1 + D1 * i0 );
151 template <
typename S,
typename A,
typename I0,
typename I1,
typename I2>
152 KOKKOS_INLINE_FUNCTION
constexpr size_type
153 operator()( S
const& s, A
const& a, I0
const& i0, I1
const& i1,
156 return Stride * s + a + VectorLength * ( i2 + D2 * ( i1 + D1 * i0 ) );
160 template <
typename S,
typename A,
typename I0,
typename I1,
typename I2,
162 KOKKOS_INLINE_FUNCTION
constexpr size_type
163 operator()( S
const& s, A
const& a, I0
const& i0, I1
const& i1,
164 I2
const& i2, I3
const& i3 )
const
166 return Stride * s + a +
167 VectorLength * ( i3 + D3 * i2 + D2 * ( i1 + D1 * i0 ) );
171 template <
typename S,
typename A,
typename I0,
typename I1,
typename I2,
172 typename I3,
typename I4>
173 KOKKOS_INLINE_FUNCTION
constexpr size_type
174 operator()( S
const& s, A
const& a, I0
const& i0, I1
const& i1,
175 I2
const& i2, I3
const& i3, I4
const& i4 )
const
177 return Stride * s + a +
179 ( i4 + D4 * ( i3 + D3 * i2 + D2 * ( i1 + D1 * i0 ) ) );
183 template <
typename S,
typename A,
typename I0,
typename I1,
typename I2,
184 typename I3,
typename I4,
typename I5>
185 KOKKOS_INLINE_FUNCTION
constexpr size_type
186 operator()( S
const& s, A
const& a, I0
const& i0, I1
const& i1,
187 I2
const& i2, I3
const& i3, I4
const& i4, I5
const& i5 )
const
189 return Stride * s + a +
191 ( i5 + D5 * ( i4 + D4 * ( i3 + D3 * i2 +
192 D2 * ( i1 + D1 * i0 ) ) ) );
197 KOKKOS_INLINE_FUNCTION
198 constexpr array_layout layout()
const {
return array_layout( m_dim.N0 ); }
200 KOKKOS_INLINE_FUNCTION
constexpr size_type dimension_0()
const
204 KOKKOS_INLINE_FUNCTION
constexpr size_type dimension_1()
const
208 KOKKOS_INLINE_FUNCTION
constexpr size_type dimension_2()
const
212 KOKKOS_INLINE_FUNCTION
constexpr size_type dimension_3()
const
216 KOKKOS_INLINE_FUNCTION
constexpr size_type dimension_4()
const
220 KOKKOS_INLINE_FUNCTION
constexpr size_type dimension_5()
const
224 KOKKOS_INLINE_FUNCTION
constexpr size_type dimension_6()
const
228 KOKKOS_INLINE_FUNCTION
constexpr size_type dimension_7()
const
234 KOKKOS_INLINE_FUNCTION
235 constexpr size_type
size()
const
237 return m_dim.N0 * m_dim.N1 * m_dim.N2 * m_dim.N3 * m_dim.N4 * m_dim.N5 *
242 KOKKOS_INLINE_FUNCTION
243 constexpr size_type span()
const {
return m_dim.N0 * Stride; }
245 KOKKOS_INLINE_FUNCTION
constexpr bool span_is_contiguous()
const
247 return span() ==
size();
251 KOKKOS_INLINE_FUNCTION
constexpr size_type stride_0()
const
256 KOKKOS_INLINE_FUNCTION
constexpr size_type stride_1()
const {
return 1; }
258 KOKKOS_INLINE_FUNCTION
constexpr size_type stride_2()
const
260 return m_dim.N7 * m_dim.N6 * m_dim.N5 * m_dim.N4 * m_dim.N3 *
264 KOKKOS_INLINE_FUNCTION
constexpr size_type stride_3()
const
266 return m_dim.N7 * m_dim.N6 * m_dim.N5 * m_dim.N4 * VectorLength;
269 KOKKOS_INLINE_FUNCTION
constexpr size_type stride_4()
const
271 return m_dim.N7 * m_dim.N6 * m_dim.N5 * VectorLength;
274 KOKKOS_INLINE_FUNCTION
constexpr size_type stride_5()
const
276 return m_dim.N7 * m_dim.N6 * VectorLength;
279 KOKKOS_INLINE_FUNCTION
constexpr size_type stride_6()
const
281 return m_dim.N7 * VectorLength;
284 KOKKOS_INLINE_FUNCTION
constexpr size_type stride_7()
const
290 template <
typename iType>
291 KOKKOS_INLINE_FUNCTION
void stride( iType*
const s )
const
293 if ( 0 < dimension_type::rank )
297 if ( 1 < dimension_type::rank )
301 if ( 2 < dimension_type::rank )
305 if ( 3 < dimension_type::rank )
309 if ( 4 < dimension_type::rank )
313 if ( 5 < dimension_type::rank )
317 if ( 6 < dimension_type::rank )
321 if ( 7 < dimension_type::rank )
325 s[dimension_type::rank] = span();
330 ViewOffset() =
default;
331 ViewOffset(
const ViewOffset& ) =
default;
332 ViewOffset& operator=(
const ViewOffset& ) =
default;
334 KOKKOS_INLINE_FUNCTION
335 constexpr ViewOffset( std::integral_constant<unsigned, 0>
const&,
336 Kokkos::LayoutCabanaSlice<LayoutDims...>
const& rhs )
337 : m_dim( rhs.dimension[0], rhs.dimension[1], rhs.dimension[2],
338 rhs.dimension[3], rhs.dimension[4], rhs.dimension[5],
339 rhs.dimension[6], rhs.dimension[7] )
343 template <
class DimRHS,
class LayoutRHS>
344 KOKKOS_INLINE_FUNCTION
constexpr ViewOffset(
345 const ViewOffset<DimRHS, LayoutRHS, void>& rhs )
346 : m_dim( rhs.m_dim.N0, rhs.m_dim.N1, rhs.m_dim.N2, rhs.m_dim.N3,
347 rhs.m_dim.N4, rhs.m_dim.N5, rhs.m_dim.N6, rhs.m_dim.N7 )
349 static_assert( int( DimRHS::rank ) == int( dimension_type::rank ),
350 "ViewOffset assignment requires equal rank" );
356 template <
class DimRHS,
class LayoutRHS>
357 KOKKOS_INLINE_FUNCTION
constexpr ViewOffset(
358 const ViewOffset<DimRHS, LayoutRHS, void>&,
359 const SubviewExtents<DimRHS::rank, dimension_type::rank>& sub )
360 : m_dim( sub.range_extent( 0 ), sub.range_extent( 1 ),
361 sub.range_extent( 2 ), sub.range_extent( 3 ),
362 sub.range_extent( 4 ), sub.range_extent( 5 ),
363 sub.range_extent( 6 ), sub.range_extent( 7 ) )
387template <
typename T, std::
size_t Rank,
int VectorLength,
int Str
ide>
388struct KokkosDataTypeImpl;
391template <
typename T,
int VectorLength,
int Str
ide>
392struct KokkosDataTypeImpl<T, 0, VectorLength, Stride>
394 using value_type =
typename std::remove_all_extents<T>::type;
395 using data_type = value_type* [VectorLength];
396 using cabana_layout = Kokkos::LayoutCabanaSlice<Stride, VectorLength>;
398 inline static cabana_layout createLayout(
const std::size_t num_soa )
400 return cabana_layout( num_soa );
405template <
typename T,
int VectorLength,
int Str
ide>
406struct KokkosDataTypeImpl<T, 1, VectorLength, Stride>
408 using value_type =
typename std::remove_all_extents<T>::type;
409 static constexpr std::size_t D0 = std::extent<T, 0>::value;
410 using data_type = value_type* [VectorLength][D0];
411 using cabana_layout = Kokkos::LayoutCabanaSlice<Stride, VectorLength, D0>;
413 inline static cabana_layout createLayout(
const std::size_t num_soa )
415 return cabana_layout( num_soa );
420template <
typename T,
int VectorLength,
int Str
ide>
421struct KokkosDataTypeImpl<T, 2, VectorLength, Stride>
423 using value_type =
typename std::remove_all_extents<T>::type;
424 static constexpr std::size_t D0 = std::extent<T, 0>::value;
425 static constexpr std::size_t D1 = std::extent<T, 1>::value;
426 using data_type = value_type* [VectorLength][D0][D1];
427 using cabana_layout =
428 Kokkos::LayoutCabanaSlice<Stride, VectorLength, D0, D1>;
430 inline static cabana_layout createLayout(
const std::size_t num_soa )
432 return cabana_layout( num_soa );
437template <
typename T,
int VectorLength,
int Str
ide>
438struct KokkosDataTypeImpl<T, 3, VectorLength, Stride>
440 using value_type =
typename std::remove_all_extents<T>::type;
441 static constexpr std::size_t D0 = std::extent<T, 0>::value;
442 static constexpr std::size_t D1 = std::extent<T, 1>::value;
443 static constexpr std::size_t D2 = std::extent<T, 2>::value;
444 using data_type = value_type* [VectorLength][D0][D1][D2];
445 using cabana_layout =
446 Kokkos::LayoutCabanaSlice<Stride, VectorLength, D0, D1, D2>;
448 inline static cabana_layout createLayout(
const std::size_t num_soa )
450 return cabana_layout( num_soa );
455template <
typename T,
int VectorLength,
int Str
ide>
458 using kokkos_data_type =
459 KokkosDataTypeImpl<T, std::rank<T>::value, VectorLength, Stride>;
460 using data_type =
typename kokkos_data_type::data_type;
461 using cabana_layout =
typename kokkos_data_type::cabana_layout;
463 inline static cabana_layout createLayout(
const std::size_t num_soa )
465 return kokkos_data_type::createLayout( num_soa );
471template <
typename T,
int VectorLength,
int Stride,
472 typename std::enable_if<
473 Impl::IsVectorLengthValid<VectorLength>::value,
int>::type = 0>
474struct KokkosViewWrapper
477 typename KokkosDataType<T, VectorLength, Stride>::data_type;
479 using cabana_layout =
480 typename KokkosDataType<T, VectorLength, Stride>::cabana_layout;
482 inline static cabana_layout createLayout(
const std::size_t num_soa )
484 return KokkosDataType<T, VectorLength, Stride>::createLayout( num_soa );
499template <
typename DataType,
typename MemorySpace,
typename MemoryAccessType,
500 int VectorLength,
int Stride>
505 static_assert( Impl::IsVectorLengthValid<VectorLength>::value,
506 "Vector length must be valid" );
517 static_assert( Impl::deprecated( Kokkos::is_device<MemorySpace>() ) );
520 using device_type [[deprecated]] =
typename memory_space::device_type;
525 "Slice memory access type must be a Cabana access type" );
549 Impl::KokkosViewWrapper<DataType, vector_length, soa_stride>;
553 Kokkos::View<
typename view_wrapper::data_type,
554 typename view_wrapper::cabana_layout, MemorySpace,
555 typename MemoryAccessType::kokkos_memory_traits>;
591 rank = std::rank<DataType>::value + 1
615 std::strcpy( _label,
label.c_str() );
630 std::strcpy( _label, rhs._label );
648 std::strcpy( _label, rhs._label );
657 std::string
label()
const {
return std::string( _label ); }
663 KOKKOS_INLINE_FUNCTION
670 KOKKOS_INLINE_FUNCTION
678 KOKKOS_INLINE_FUNCTION
681 return (
static_cast<size_type>( s ) < _view.extent( 0 ) - 1 )
690 template <
typename U = DataType>
691 KOKKOS_FORCEINLINE_FUNCTION
692 typename std::enable_if<( 0 == std::rank<U>::value &&
693 std::is_same<U, DataType>::value ),
697 return _view( s, a );
701 template <
typename U = DataType>
702 KOKKOS_FORCEINLINE_FUNCTION
703 typename std::enable_if<( 1 == std::rank<U>::value &&
704 std::is_same<U, DataType>::value ),
708 return _view( s, a, d0 );
712 template <
typename U = DataType>
713 KOKKOS_FORCEINLINE_FUNCTION
714 typename std::enable_if<( 2 == std::rank<U>::value &&
715 std::is_same<U, DataType>::value ),
720 return _view( s, a, d0, d1 );
724 template <
typename U = DataType>
725 KOKKOS_FORCEINLINE_FUNCTION
726 typename std::enable_if<( 3 == std::rank<U>::value &&
727 std::is_same<U, DataType>::value ),
732 return _view( s, a, d0, d1, d2 );
739 template <
typename U = DataType>
740 KOKKOS_FORCEINLINE_FUNCTION
741 typename std::enable_if<( 0 == std::rank<U>::value &&
742 std::is_same<U, DataType>::value ),
750 template <
typename U = DataType>
751 KOKKOS_FORCEINLINE_FUNCTION
752 typename std::enable_if<( 1 == std::rank<U>::value &&
753 std::is_same<U, DataType>::value ),
761 template <
typename U = DataType>
762 KOKKOS_FORCEINLINE_FUNCTION
763 typename std::enable_if<( 2 == std::rank<U>::value &&
764 std::is_same<U, DataType>::value ),
773 template <
typename U = DataType>
774 KOKKOS_FORCEINLINE_FUNCTION
775 typename std::enable_if<( 3 == std::rank<U>::value &&
776 std::is_same<U, DataType>::value ),
791 KOKKOS_INLINE_FUNCTION
800 KOKKOS_INLINE_FUNCTION
810 KOKKOS_INLINE_FUNCTION
819 KOKKOS_INLINE_FUNCTION
825 KOKKOS_INLINE_FUNCTION
843struct is_slice_impl :
public std::false_type
849template <
typename DataType,
typename MemorySpace,
typename MemoryAccessType,
850 int VectorLength,
int Stride>
852 Slice<DataType, MemorySpace, MemoryAccessType, VectorLength, Stride>>
853 :
public std::true_type
860struct is_slice :
public is_slice_impl<typename std::remove_cv<T>::type>::type
869template <
class ExecutionSpace,
class ViewType,
class SliceType>
871 ExecutionSpace exec_space, ViewType& view,
const SliceType&
slice,
872 const std::size_t begin,
const std::size_t end,
873 typename std::enable_if<
874 2 == SliceType::kokkos_view::traits::dimension::rank,
int*>::type = 0 )
876 Kokkos::parallel_for(
877 "Cabana::copySliceToView::Rank0",
878 Kokkos::RangePolicy<ExecutionSpace>( exec_space, begin, end ),
879 KOKKOS_LAMBDA(
const int i ) { view( i - begin ) =
slice( i ); } );
883template <
class ExecutionSpace,
class ViewType,
class SliceType>
885 ExecutionSpace exec_space, ViewType& view,
const SliceType&
slice,
886 const std::size_t begin,
const std::size_t end,
887 typename std::enable_if<
888 3 == SliceType::kokkos_view::traits::dimension::rank,
int*>::type = 0 )
890 Kokkos::parallel_for(
891 "Cabana::copySliceToView::FieldRank1",
892 Kokkos::RangePolicy<ExecutionSpace>( exec_space, begin, end ),
893 KOKKOS_LAMBDA(
const int i ) {
894 for ( std::size_t d0 = 0; d0 <
slice.extent( 2 ); ++d0 )
895 view( i - begin, d0 ) =
slice( i, d0 );
900template <
class ExecutionSpace,
class ViewType,
class SliceType>
902 ExecutionSpace exec_space, ViewType& view,
const SliceType&
slice,
903 const std::size_t begin,
const std::size_t end,
904 typename std::enable_if<
905 4 == SliceType::kokkos_view::traits::dimension::rank,
int*>::type = 0 )
907 Kokkos::parallel_for(
908 "Cabana::copySliceToView::writeFieldRank2",
909 Kokkos::RangePolicy<ExecutionSpace>( exec_space, begin, end ),
910 KOKKOS_LAMBDA(
const int i ) {
911 for ( std::size_t d0 = 0; d0 <
slice.extent( 2 ); ++d0 )
912 for ( std::size_t d1 = 0; d1 <
slice.extent( 3 ); ++d1 )
913 view( i - begin, d0, d1 ) =
slice( i, d0, d1 );
918template <
class ViewType,
class SliceType>
920 const std::size_t begin,
const std::size_t end )
922 using exec_space =
typename SliceType::execution_space;
931template <
class ExecutionSpace,
class SliceType,
class ViewType>
933 ExecutionSpace exec_space, SliceType&
slice,
const ViewType& view,
934 const std::size_t begin,
const std::size_t end,
935 typename std::enable_if<
936 2 == SliceType::kokkos_view::traits::dimension::rank,
int*>::type = 0 )
938 Kokkos::parallel_for(
939 "Cabana::copyViewToSlice::Rank0",
940 Kokkos::RangePolicy<ExecutionSpace>( exec_space, begin, end ),
941 KOKKOS_LAMBDA(
const int i ) {
slice( i - begin ) = view( i ); } );
945template <
class ExecutionSpace,
class SliceType,
class ViewType>
947 ExecutionSpace exec_space, SliceType&
slice,
const ViewType& view,
948 const std::size_t begin,
const std::size_t end,
949 typename std::enable_if<
950 3 == SliceType::kokkos_view::traits::dimension::rank,
int*>::type = 0 )
952 Kokkos::parallel_for(
953 "Cabana::copySliceToView::FieldRank1",
954 Kokkos::RangePolicy<ExecutionSpace>( exec_space, begin, end ),
955 KOKKOS_LAMBDA(
const int i ) {
956 for ( std::size_t d0 = 0; d0 <
slice.extent( 2 ); ++d0 )
957 slice( i - begin, d0 ) = view( i, d0 );
962template <
class ExecutionSpace,
class SliceType,
class ViewType>
964 ExecutionSpace exec_space, SliceType&
slice,
const ViewType& view,
965 const std::size_t begin,
const std::size_t end,
966 typename std::enable_if<
967 4 == SliceType::kokkos_view::traits::dimension::rank,
int*>::type = 0 )
969 Kokkos::parallel_for(
970 "Cabana::copySliceToView::writeFieldRank2",
971 Kokkos::RangePolicy<ExecutionSpace>( exec_space, begin, end ),
972 KOKKOS_LAMBDA(
const int i ) {
973 for ( std::size_t d0 = 0; d0 <
slice.extent( 2 ); ++d0 )
974 for ( std::size_t d1 = 0; d1 <
slice.extent( 3 ); ++d1 )
975 slice( i - begin, d0, d1 ) = view( i, d0, d1 );
980template <
class ViewType,
class SliceType>
982 const std::size_t begin,
const std::size_t end )
984 using exec_space =
typename SliceType::execution_space;
989template <
class SliceType>
991 [[maybe_unused]] SliceType
slice, [[maybe_unused]]
const std::size_t
size,
999template <
class ViewType>
1001 [[maybe_unused]] ViewType view, [[maybe_unused]]
const std::size_t
size,
1002 typename std::enable_if<Kokkos::is_view<ViewType>::value,
int>::type* = 0 )
1005 assert( view.extent( 0 ) ==
size );
1011template <
class SliceType>
1015 return slice.size();
1019template <
class ViewType>
1022 typename std::enable_if<Kokkos::is_view<ViewType>::value,
int>::type* = 0 )
1024 return view.extent( 0 );
Memory access type checking.
Class for converting between 1d and 2d aosoa indices.
Definition Cabana_Index.hpp:38
static KOKKOS_FORCEINLINE_FUNCTION constexpr std::size_t a(const std::size_t i)
Definition Cabana_Index.hpp:77
static KOKKOS_FORCEINLINE_FUNCTION constexpr std::size_t s(const std::size_t i)
Definition Cabana_Index.hpp:62
A slice of an array-of-structs-of-arrays with data access to a single multidimensional member.
Definition Cabana_Slice.hpp:502
KOKKOS_FORCEINLINE_FUNCTION std::enable_if<(3==std::rank< U >::value &&std::is_same< U, DataType >::value), reference_type >::type access(const size_type s, const size_type a, const size_type d0, const size_type d1, const size_type d2) const
2d access for Rank 3
Definition Cabana_Slice.hpp:729
typename kokkos_view::array_layout view_layout
Definition Cabana_Slice.hpp:564
KOKKOS_INLINE_FUNCTION pointer_type data() const
Definition Cabana_Slice.hpp:792
KOKKOS_INLINE_FUNCTION size_type size() const
Definition Cabana_Slice.hpp:664
typename kokkos_view::pointer_type pointer_type
Definition Cabana_Slice.hpp:562
typename kokkos_view::value_type value_type
Definition Cabana_Slice.hpp:560
Slice & operator=(const Slice< DataType, MemorySpace, MAT, VectorLength, Stride > &rhs)
Assignment operator for different memory spaces for assigning new memory access traits to the view.
Definition Cabana_Slice.hpp:643
Slice< member_data_type< M >, memory_space, RandomAccessMemory, VectorLength, Stride > random_access_slice
Definition Cabana_Slice.hpp:573
std::string label() const
Definition Cabana_Slice.hpp:657
KOKKOS_FORCEINLINE_FUNCTION std::enable_if<(0==std::rank< U >::value &&std::is_same< U, DataType >::value), reference_type >::type access(const size_type s, const size_type a) const
2d access for Rank 0
Definition Cabana_Slice.hpp:695
Impl::Index< vector_length > index_type
Definition Cabana_Slice.hpp:539
KOKKOS_INLINE_FUNCTION size_type stride(const size_type d) const
Get the stride of a given raw slice dimension. This includes the struct dimension,...
Definition Cabana_Slice.hpp:820
static constexpr std::size_t max_supported_rank
Definition Cabana_Slice.hpp:542
Slice(const pointer_type data, const size_type size, const size_type num_soa, const std::string &label="")
Constructor.
Definition Cabana_Slice.hpp:610
KOKKOS_INLINE_FUNCTION size_type arraySize(const size_type s) const
Get the size of the data array at a given struct member index.
Definition Cabana_Slice.hpp:679
static constexpr int vector_length
Definition Cabana_Slice.hpp:530
typename kokkos_view::reference_type reference_type
Definition Cabana_Slice.hpp:558
KOKKOS_INLINE_FUNCTION constexpr size_type viewRank() const
Get the rank of the raw data for this slice. This includes the struct dimension, array dimension,...
Definition Cabana_Slice.hpp:801
KOKKOS_FORCEINLINE_FUNCTION std::enable_if<(1==std::rank< U >::value &&std::is_same< U, DataType >::value), reference_type >::type access(const size_type s, const size_type a, const size_type d0) const
2d access for Rank 1
Definition Cabana_Slice.hpp:706
static constexpr int soa_stride
Definition Cabana_Slice.hpp:533
Slice< member_data_type< M >, memory_space, DefaultAccessMemory, VectorLength, Stride > default_access_slice
Definition Cabana_Slice.hpp:567
typename memory_space::size_type size_type
Definition Cabana_Slice.hpp:536
typename memory_space::memory_space memory_space
Definition Cabana_Slice.hpp:515
Slice< member_data_type< M >, memory_space, AtomicAccessMemory, VectorLength, Stride > atomic_access_slice
Definition Cabana_Slice.hpp:570
Slice()
Default constructor.
Definition Cabana_Slice.hpp:598
Slice(const Slice< DataType, MemorySpace, MAT, VectorLength, Stride > &rhs)
Shallow copy constructor for different memory spaces for assigning new memory access traits to the vi...
Definition Cabana_Slice.hpp:626
KOKKOS_FORCEINLINE_FUNCTION std::enable_if<(2==std::rank< U >::value &&std::is_same< U, DataType >::value), reference_type >::type access(const size_type s, const size_type a, const size_type d0, const size_type d1) const
2d access for Rank 2
Definition Cabana_Slice.hpp:717
DefaultAccessMemory memory_access_type
Definition Cabana_Slice.hpp:527
KOKKOS_INLINE_FUNCTION size_type extent(const size_type d) const
Get the extent of a given raw slice data dimension. This includes the struct dimension,...
Definition Cabana_Slice.hpp:811
typename memory_space::execution_space execution_space
Definition Cabana_Slice.hpp:522
KOKKOS_INLINE_FUNCTION kokkos_view view() const
Get the underlying Kokkos View managing the slice data.
Definition Cabana_Slice.hpp:826
KOKKOS_INLINE_FUNCTION size_type numSoA() const
Get the number of structs-of-arrays in the container.
Definition Cabana_Slice.hpp:671
static constexpr std::size_t max_label_length
Definition Cabana_Slice.hpp:545
Slice< member_data_type< M >, memory_space, DefaultAccessMemory, VectorLength, Stride > slice_type
Definition Cabana_Slice.hpp:509
Kokkos::View< typename view_wrapper::data_type, typename view_wrapper::cabana_layout, memory_space, typename DefaultAccessMemory::kokkos_memory_traits > kokkos_view
Definition Cabana_Slice.hpp:552
Impl::KokkosViewWrapper< member_data_type< M >, vector_length, soa_stride > view_wrapper
Definition Cabana_Slice.hpp:548
Core: particle data structures and algorithms.
Definition Cabana_AoSoA.hpp:36
auto size(SliceType slice, typename std::enable_if< is_slice< SliceType >::value, int >::type *=0)
Check slice size (differs from Kokkos View).
Definition Cabana_Slice.hpp:1012
void copyViewToSlice(ExecutionSpace exec_space, SliceType &slice, const ViewType &view, const std::size_t begin, const std::size_t end, typename std::enable_if< 2==SliceType::kokkos_view::traits::dimension::rank, int * >::type=0)
Copy from View to slice. Rank-0.
Definition Cabana_Slice.hpp:932
void copySliceToView(ExecutionSpace exec_space, ViewType &view, const SliceType &slice, const std::size_t begin, const std::size_t end, typename std::enable_if< 2==SliceType::kokkos_view::traits::dimension::rank, int * >::type=0)
Copy from slice to View. Rank-0.
Definition Cabana_Slice.hpp:870
AoSoA_t::template member_slice_type< M > slice(const AoSoA_t &aosoa, const std::string &slice_label="")
Create a slice from an AoSoA.
Definition Cabana_AoSoA.hpp:77
void checkSize(SliceType slice, const std::size_t size, typename std::enable_if< is_slice< SliceType >::value, int >::type *=0)
Check slice size (differs from Kokkos View).
Definition Cabana_Slice.hpp:990
Atomic memory access. All reads and writes are atomic.
Definition Cabana_Types.hpp:70
Definition Cabana_Types.hpp:37
Random access memory. Read-only and const with limited spatial locality.
Definition Cabana_Types.hpp:54
Memory access type checker.
Definition Cabana_Types.hpp:31
Slice static type checker.
Definition Cabana_Slice.hpp:861
Cabana Slice layout.
Definition Cabana_Slice.hpp:38
LayoutCabanaSlice & operator=(LayoutCabanaSlice const &)=default
Const assignment operator.
static constexpr int Stride
Slice SoA stride.
Definition Cabana_Slice.hpp:48
static constexpr int D0
Slice zeroth dimension size.
Definition Cabana_Slice.hpp:52
static constexpr int D4
Slice fourth dimension size.
Definition Cabana_Slice.hpp:60
LayoutCabanaSlice array_layout
Slice array layout.
Definition Cabana_Slice.hpp:40
static constexpr int D5
Slice fifth dimension size.
Definition Cabana_Slice.hpp:62
LayoutCabanaSlice(LayoutCabanaSlice &&)=default
Copy constructor.
static constexpr int D2
Slice second dimension size.
Definition Cabana_Slice.hpp:56
size_t dimension[ARRAY_LAYOUT_MAX_RANK]
Slice dimension.
Definition Cabana_Slice.hpp:65
LayoutCabanaSlice(LayoutCabanaSlice const &)=default
Const copy constructor.
LayoutCabanaSlice & operator=(LayoutCabanaSlice &&)=default
Assignment operator.
static constexpr int VectorLength
Slice vectorlength.
Definition Cabana_Slice.hpp:50
static constexpr int D1
Slice first dimension size.
Definition Cabana_Slice.hpp:54
static constexpr int D3
Slice third dimension size.
Definition Cabana_Slice.hpp:58
KOKKOS_INLINE_FUNCTION constexpr LayoutCabanaSlice(size_t num_soa=0, size_t vector_length=VectorLength, size_t d0=D0, size_t d1=D1, size_t d2=D2, size_t d3=D3, size_t d4=D4, size_t d5=D5)
Constructor.
Definition Cabana_Slice.hpp:78