Cabana 0.8.99-dev
Loading...
Searching...
No Matches
Cabana_Slice.hpp
Go to the documentation of this file.
1/****************************************************************************
2 * Copyright (c) 2018-2023 by the Cabana authors *
3 * All rights reserved. *
4 * *
5 * This file is part of the Cabana library. Cabana is distributed under a *
6 * BSD 3-clause license. For the licensing terms see the LICENSE file in *
7 * the top-level directory. *
8 * *
9 * SPDX-License-Identifier: BSD-3-Clause *
10 ****************************************************************************/
11
16#ifndef CABANA_SLICE_HPP
17#define CABANA_SLICE_HPP
18
19#include <Cabana_Types.hpp>
20#include <Cabana_Utils.hpp>
21#include <impl/Cabana_Index.hpp>
22#include <impl/Cabana_TypeTraits.hpp>
23
24#include <Kokkos_Core.hpp>
25
26#include <cassert>
27#include <cstdlib>
28#include <cstring>
29#include <string>
30#include <type_traits>
31
32//---------------------------------------------------------------------------//
33namespace Cabana
34{
35namespace Impl
36{
38
39//---------------------------------------------------------------------------//
40// Given a tuple member type T of the given rank get the Kokkos view
41// data layout parameters. The tuple index effectively introduces 2 new
42// dimensions to the problem on top of the member dimensions - one for the
43// struct index and one for the vector index.
44template <typename T, std::size_t Rank, int VectorLength, int Stride>
45struct KokkosDataTypeImpl;
46
47// Rank-0
48template <typename T, int VectorLength, int Stride>
49struct KokkosDataTypeImpl<T, 0, VectorLength, Stride>
50{
51 using value_type = typename std::remove_all_extents<T>::type;
52 using data_type = value_type* [VectorLength];
53 using array_layout = Kokkos::LayoutStride;
54
55 inline static array_layout createLayout( const std::size_t num_soa )
56 {
57 return array_layout( num_soa, Stride, VectorLength, 1 );
58 }
59};
60
61// Rank-1
62template <typename T, int VectorLength, int Stride>
63struct KokkosDataTypeImpl<T, 1, VectorLength, Stride>
64{
65 using value_type = typename std::remove_all_extents<T>::type;
66 static constexpr std::size_t D0 = std::extent<T, 0>::value;
67 using data_type = value_type* [VectorLength][D0];
68 using array_layout = Kokkos::LayoutStride;
69
70 inline static array_layout createLayout( const std::size_t num_soa )
71 {
72 return array_layout( num_soa, Stride, VectorLength, 1, D0,
73 VectorLength );
74 }
75};
76
77// Rank-2
78template <typename T, int VectorLength, int Stride>
79struct KokkosDataTypeImpl<T, 2, VectorLength, Stride>
80{
81 using value_type = typename std::remove_all_extents<T>::type;
82 static constexpr std::size_t D0 = std::extent<T, 0>::value;
83 static constexpr std::size_t D1 = std::extent<T, 1>::value;
84 using data_type = value_type* [VectorLength][D0][D1];
85 using array_layout = Kokkos::LayoutStride;
86
87 inline static array_layout createLayout( const std::size_t num_soa )
88 {
89 return array_layout( num_soa, Stride, VectorLength, 1, D0,
90 VectorLength * D1, D1, VectorLength );
91 }
92};
93
94// Rank-3
95template <typename T, int VectorLength, int Stride>
96struct KokkosDataTypeImpl<T, 3, VectorLength, Stride>
97{
98 using value_type = typename std::remove_all_extents<T>::type;
99 static constexpr std::size_t D0 = std::extent<T, 0>::value;
100 static constexpr std::size_t D1 = std::extent<T, 1>::value;
101 static constexpr std::size_t D2 = std::extent<T, 2>::value;
102 using data_type = value_type* [VectorLength][D0][D1][D2];
103 using array_layout = Kokkos::LayoutStride;
104
105 inline static array_layout createLayout( const std::size_t num_soa )
106 {
107 return array_layout( num_soa, Stride, VectorLength, 1, D0,
108 VectorLength * D1 * D2, D1, VectorLength * D2, D2,
109 VectorLength );
110 }
111};
112
113// Data type specialization.
114template <typename T, int VectorLength, int Stride>
115struct KokkosDataType
116{
117 using kokkos_data_type =
118 KokkosDataTypeImpl<T, std::rank<T>::value, VectorLength, Stride>;
119 using data_type = typename kokkos_data_type::data_type;
120 using array_layout = typename kokkos_data_type::array_layout;
121
122 inline static array_layout createLayout( const std::size_t num_soa )
123 {
124 return kokkos_data_type::createLayout( num_soa );
125 }
126};
127
128//---------------------------------------------------------------------------//
129// Kokkos view wrapper for tuple members
130template <typename T, int VectorLength, int Stride,
131 typename std::enable_if<
132 Impl::IsVectorLengthValid<VectorLength>::value, int>::type = 0>
133struct KokkosViewWrapper
134{
135 using data_type =
136 typename KokkosDataType<T, VectorLength, Stride>::data_type;
137
138 using array_layout =
139 typename KokkosDataType<T, VectorLength, Stride>::array_layout;
140
141 inline static array_layout createLayout( const std::size_t num_soa )
142 {
143 return KokkosDataType<T, VectorLength, Stride>::createLayout( num_soa );
144 }
145};
146
147//---------------------------------------------------------------------------//
148
150} // end namespace Impl
151
152//---------------------------------------------------------------------------//
157//---------------------------------------------------------------------------//
158template <typename DataType, typename MemorySpace, typename MemoryAccessType,
159 int VectorLength, int Stride>
160class Slice
161{
162 public:
163 // Ensure the vector length is valid.
164 static_assert( Impl::IsVectorLengthValid<VectorLength>::value,
165 "Vector length must be valid" );
166
170
172 using memory_space = MemorySpace;
173 static_assert( Kokkos::is_memory_space<MemorySpace>() );
174
176 using execution_space = typename memory_space::execution_space;
177
179 "Slice memory access type must be a Cabana access type" );
181 using memory_access_type = MemoryAccessType;
182
184 static constexpr int vector_length = VectorLength;
185
187 static constexpr int soa_stride = Stride;
188
191
193 static constexpr std::size_t max_supported_rank = 3;
194
196 static constexpr std::size_t max_label_length = 128;
197
200 Impl::KokkosViewWrapper<DataType, vector_length, soa_stride>;
201
204 Kokkos::View<typename view_wrapper::data_type,
205 typename view_wrapper::array_layout, MemorySpace,
206 typename MemoryAccessType::kokkos_memory_traits>;
207
209 using size_type = typename kokkos_view::size_type;
210
212 using reference_type = typename kokkos_view::reference_type;
214 using value_type = typename kokkos_view::value_type;
216 using pointer_type = typename kokkos_view::pointer_type;
218 using view_layout = typename kokkos_view::array_layout;
219
221 static constexpr std::size_t data_rank = std::rank<DataType>::value;
223 static constexpr std::size_t view_rank = data_rank + 2;
224
234
235 // Declare slices of different memory access types to be friends.
236 friend class Slice<DataType, MemorySpace, DefaultAccessMemory, VectorLength,
237 Stride>;
238 friend class Slice<DataType, MemorySpace, AtomicAccessMemory, VectorLength,
239 Stride>;
240 friend class Slice<DataType, MemorySpace, RandomAccessMemory, VectorLength,
241 Stride>;
242
243 // Equivalent Kokkos view rank. This rank assumes that the struct and
244 // array dimension are merged. For the true rank of the raw AoSoA data use
245 // the rank() function below which will account for the extra dimension
246 // from separate struct and array indices. This enumeration is for
247 // compatibility with Kokkos views.
248 enum
249 {
250 rank = data_rank + 1
251 };
252
253 public:
258 : _size( 0 )
259 {
260 }
261
270 const size_type num_soa, const std::string& label = "" )
271 : _view( data, view_wrapper::createLayout( num_soa ) )
272 , _size( size )
273 {
274 std::strcpy( _label, label.c_str() );
275 }
276
284 template <class MAT>
286 : _view( rhs._view )
287 , _size( rhs._size )
288 {
289 std::strcpy( _label, rhs._label );
290 }
291
301 template <class MAT>
304 {
305 _view = rhs._view;
306 _size = rhs._size;
307 std::strcpy( _label, rhs._label );
308 return *this;
309 }
310
316 std::string label() const { return std::string( _label ); }
317
322 KOKKOS_INLINE_FUNCTION
323 size_type size() const { return _size; }
324
329 KOKKOS_INLINE_FUNCTION
330 size_type numSoA() const { return _view.extent( 0 ); }
331
337 KOKKOS_INLINE_FUNCTION
339 {
340 // Check if this is not the last struct index.
341 // If it isn't, the data array is guaranteed to be full.
342 if ( static_cast<size_type>( s ) < _view.extent( 0 ) - 1 )
343 {
344 return vector_length;
345 }
346 else
347 {
348 // This is the last struct index, which may be partially full.
349 // We calculate the remainder to see how many elements it holds.
350 const size_type rem = _size % vector_length;
351 // If rem is 0 and size is positive, the last chunk is full.
352 // Otherwise, the remainder is the correct size (e.g., for _size=0).
353 return ( rem == 0 && _size > 0 ) ? vector_length : rem;
354 }
355 }
356
357 // ------------
358 // 2-D accessor
359
361 template <typename U = DataType>
362 KOKKOS_FORCEINLINE_FUNCTION
363 typename std::enable_if<( 0 == std::rank<U>::value &&
364 std::is_same<U, DataType>::value ),
365 reference_type>::type
366 access( const size_type s, const size_type a ) const
367 {
368 return _view( s, a );
369 }
370
372 template <typename U = DataType>
373 KOKKOS_FORCEINLINE_FUNCTION
374 typename std::enable_if<( 1 == std::rank<U>::value &&
375 std::is_same<U, DataType>::value ),
376 reference_type>::type
377 access( const size_type s, const size_type a, const size_type d0 ) const
378 {
379 return _view( s, a, d0 );
380 }
381
383 template <typename U = DataType>
384 KOKKOS_FORCEINLINE_FUNCTION
385 typename std::enable_if<( 2 == std::rank<U>::value &&
386 std::is_same<U, DataType>::value ),
387 reference_type>::type
388 access( const size_type s, const size_type a, const size_type d0,
389 const size_type d1 ) const
390 {
391 return _view( s, a, d0, d1 );
392 }
393
395 template <typename U = DataType>
396 KOKKOS_FORCEINLINE_FUNCTION
397 typename std::enable_if<( 3 == std::rank<U>::value &&
398 std::is_same<U, DataType>::value ),
399 reference_type>::type
400 access( const size_type s, const size_type a, const size_type d0,
401 const size_type d1, const size_type d2 ) const
402 {
403 return _view( s, a, d0, d1, d2 );
404 }
405
406 // ------------
407 // 1-D accessor
408
410 template <typename U = DataType>
411 KOKKOS_FORCEINLINE_FUNCTION
412 typename std::enable_if<( 0 == std::rank<U>::value &&
413 std::is_same<U, DataType>::value ),
414 reference_type>::type
415 operator()( const size_type i ) const
416 {
417 return access( index_type::s( i ), index_type::a( i ) );
418 }
419
421 template <typename U = DataType>
422 KOKKOS_FORCEINLINE_FUNCTION
423 typename std::enable_if<( 1 == std::rank<U>::value &&
424 std::is_same<U, DataType>::value ),
425 reference_type>::type
426 operator()( const size_type i, const size_type d0 ) const
427 {
428 return access( index_type::s( i ), index_type::a( i ), d0 );
429 }
430
432 template <typename U = DataType>
433 KOKKOS_FORCEINLINE_FUNCTION
434 typename std::enable_if<( 2 == std::rank<U>::value &&
435 std::is_same<U, DataType>::value ),
436 reference_type>::type
437 operator()( const size_type i, const size_type d0,
438 const size_type d1 ) const
439 {
440 return access( index_type::s( i ), index_type::a( i ), d0, d1 );
441 }
442
444 template <typename U = DataType>
445 KOKKOS_FORCEINLINE_FUNCTION
446 typename std::enable_if<( 3 == std::rank<U>::value &&
447 std::is_same<U, DataType>::value ),
448 reference_type>::type
449 operator()( const size_type i, const size_type d0, const size_type d1,
450 const size_type d2 ) const
451 {
452 return access( index_type::s( i ), index_type::a( i ), d0, d1, d2 );
453 }
454
455 // -------------------------------
456 // Raw data access.
457
462 KOKKOS_INLINE_FUNCTION
463 pointer_type data() const { return _view.data(); }
464
471 KOKKOS_INLINE_FUNCTION
472 constexpr size_type viewRank() const { return _view.rank; }
473
481 KOKKOS_INLINE_FUNCTION
482 size_type extent( const size_type d ) const { return _view.extent( d ); }
483
490 KOKKOS_INLINE_FUNCTION
491 size_type stride( const size_type d ) const { return _view.stride( d ); }
492
496 KOKKOS_INLINE_FUNCTION
497 kokkos_view view() const { return _view; }
498
499 private:
500 // The data view. This view is unmanaged and has access traits specified
501 // by the template parameters of this class.
502 kokkos_view _view;
503
504 // Number of tuples in the slice.
505 size_type _size;
506
507 // Slice label.
508 char _label[max_label_length];
509};
510
511//---------------------------------------------------------------------------//
513template <typename>
514struct is_slice_impl : public std::false_type
515{
516};
517
518// True only if the type is a member slice *AND* the member slice is templated
519// on an AoSoA type.
520template <typename DataType, typename MemorySpace, typename MemoryAccessType,
521 int VectorLength, int Stride>
522struct is_slice_impl<
523 Slice<DataType, MemorySpace, MemoryAccessType, VectorLength, Stride>>
524 : public std::true_type
525{
526};
528
530template <class T>
531struct is_slice : public is_slice_impl<typename std::remove_cv<T>::type>::type
532{
533};
534
535//---------------------------------------------------------------------------//
536// Copy to View.
537//---------------------------------------------------------------------------//
538
540template <class ExecutionSpace, class ViewType, class SliceType>
542 ExecutionSpace exec_space, ViewType& view, const SliceType& slice,
543 const std::size_t begin, const std::size_t end,
544 typename std::enable_if<( SliceType::view_rank == 2 ), int*>::type = 0 )
545{
546 Kokkos::parallel_for(
547 "Cabana::copySliceToView::Rank0",
548 Kokkos::RangePolicy<ExecutionSpace>( exec_space, begin, end ),
549 KOKKOS_LAMBDA( const int i ) { view( i - begin ) = slice( i ); } );
550}
551
553template <class ExecutionSpace, class ViewType, class SliceType>
555 ExecutionSpace exec_space, ViewType& view, const SliceType& slice,
556 const std::size_t begin, const std::size_t end,
557 typename std::enable_if<( SliceType::view_rank == 3 ), int*>::type = 0 )
558{
559 Kokkos::parallel_for(
560 "Cabana::copySliceToView::Rank1",
561 Kokkos::RangePolicy<ExecutionSpace>( exec_space, begin, end ),
562 KOKKOS_LAMBDA( const int i ) {
563 for ( std::size_t d0 = 0; d0 < slice.extent( 2 ); ++d0 )
564 view( i - begin, d0 ) = slice( i, d0 );
565 } );
566}
567
569template <class ExecutionSpace, class ViewType, class SliceType>
571 ExecutionSpace exec_space, ViewType& view, const SliceType& slice,
572 const std::size_t begin, const std::size_t end,
573 typename std::enable_if<( SliceType::view_rank == 4 ), int*>::type = 0 )
574{
575 Kokkos::parallel_for(
576 "Cabana::copySliceToView::Rank2",
577 Kokkos::RangePolicy<ExecutionSpace>( exec_space, begin, end ),
578 KOKKOS_LAMBDA( const int i ) {
579 for ( std::size_t d0 = 0; d0 < slice.extent( 2 ); ++d0 )
580 for ( std::size_t d1 = 0; d1 < slice.extent( 3 ); ++d1 )
581 view( i - begin, d0, d1 ) = slice( i, d0, d1 );
582 } );
583}
584
586template <class ViewType, class SliceType>
587void copySliceToView( ViewType& view, const SliceType& slice,
588 const std::size_t begin, const std::size_t end )
589{
590 using exec_space = typename SliceType::execution_space;
591 copySliceToView( exec_space{}, view, slice, begin, end );
592}
593
594//---------------------------------------------------------------------------//
595// Copy from View.
596//---------------------------------------------------------------------------//
597
599template <class ExecutionSpace, class SliceType, class ViewType>
601 ExecutionSpace exec_space, SliceType& slice, const ViewType& view,
602 const std::size_t begin, const std::size_t end,
603 typename std::enable_if<( SliceType::view_rank == 2 ), int*>::type = 0 )
604{
605 Kokkos::parallel_for(
606 "Cabana::copyViewToSlice::Rank0",
607 Kokkos::RangePolicy<ExecutionSpace>( exec_space, begin, end ),
608 KOKKOS_LAMBDA( const int i ) { slice( i - begin ) = view( i ); } );
609}
610
612template <class ExecutionSpace, class SliceType, class ViewType>
614 ExecutionSpace exec_space, SliceType& slice, const ViewType& view,
615 const std::size_t begin, const std::size_t end,
616 typename std::enable_if<( SliceType::view_rank == 3 ), int*>::type = 0 )
617{
618 Kokkos::parallel_for(
619 "Cabana::copyViewToSlice::Rank1",
620 Kokkos::RangePolicy<ExecutionSpace>( exec_space, begin, end ),
621 KOKKOS_LAMBDA( const int i ) {
622 for ( std::size_t d0 = 0; d0 < slice.extent( 2 ); ++d0 )
623 slice( i - begin, d0 ) = view( i, d0 );
624 } );
625}
626
628template <class ExecutionSpace, class SliceType, class ViewType>
630 ExecutionSpace exec_space, SliceType& slice, const ViewType& view,
631 const std::size_t begin, const std::size_t end,
632 typename std::enable_if<( SliceType::view_rank == 4 ), int*>::type = 0 )
633{
634 Kokkos::parallel_for(
635 "Cabana::copyViewToSlice::Rank2",
636 Kokkos::RangePolicy<ExecutionSpace>( exec_space, begin, end ),
637 KOKKOS_LAMBDA( const int i ) {
638 for ( std::size_t d0 = 0; d0 < slice.extent( 2 ); ++d0 )
639 for ( std::size_t d1 = 0; d1 < slice.extent( 3 ); ++d1 )
640 slice( i - begin, d0, d1 ) = view( i, d0, d1 );
641 } );
642}
643
645template <class ViewType, class SliceType>
646void copyViewToSlice( SliceType& slice, const ViewType& view,
647 const std::size_t begin, const std::size_t end )
648{
649 using exec_space = typename SliceType::execution_space;
650 copyViewToSlice( exec_space{}, slice, view, begin, end );
651}
652
654template <class SliceType>
656 [[maybe_unused]] SliceType slice, [[maybe_unused]] const std::size_t size,
657 typename std::enable_if<is_slice<SliceType>::value, int>::type* = 0 )
658{
659 // Allow unused for release builds.
660 assert( slice.size() == size );
661}
662
664template <class ViewType>
666 [[maybe_unused]] ViewType view, [[maybe_unused]] const std::size_t size,
667 typename std::enable_if<Kokkos::is_view<ViewType>::value, int>::type* = 0 )
668{
669 // Allow unused for release builds.
670 assert( view.extent( 0 ) == size );
671}
672
673//---------------------------------------------------------------------------//
674
676template <class SliceType>
677KOKKOS_INLINE_FUNCTION auto
678size( SliceType slice,
679 typename std::enable_if<is_slice<SliceType>::value, int>::type* = 0 )
680{
681 return slice.size();
682}
683
685template <class ViewType>
686KOKKOS_INLINE_FUNCTION auto size(
687 ViewType view,
688 typename std::enable_if<Kokkos::is_view<ViewType>::value, int>::type* = 0 )
689{
690 return view.extent( 0 );
691}
692
693} // end namespace Cabana
694
695//---------------------------------------------------------------------------//
696
697#endif // end CABANA_SLICE_HPP
AoSoA indexing.
Memory access type checking.
Cabana utilities.
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:161
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:400
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:302
Slice< member_data_type< M >, memory_space, RandomAccessMemory, VectorLength, Stride > random_access_slice
Definition Cabana_Slice.hpp:232
Kokkos::View< typename view_wrapper::data_type, typename view_wrapper::array_layout, memory_space, typename DefaultAccessMemory::kokkos_memory_traits > kokkos_view
Definition Cabana_Slice.hpp:203
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:366
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:491
Slice(const pointer_type data, const size_type size, const size_type num_soa, const std::string &label="")
Constructor.
Definition Cabana_Slice.hpp:269
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:338
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:472
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:377
Slice< member_data_type< M >, memory_space, DefaultAccessMemory, VectorLength, Stride > default_access_slice
Definition Cabana_Slice.hpp:226
Slice< member_data_type< M >, memory_space, AtomicAccessMemory, VectorLength, Stride > atomic_access_slice
Definition Cabana_Slice.hpp:229
Slice()
Default constructor.
Definition Cabana_Slice.hpp:257
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:285
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:388
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:482
KOKKOS_INLINE_FUNCTION kokkos_view view() const
Get the underlying Kokkos View managing the slice data.
Definition Cabana_Slice.hpp:497
KOKKOS_INLINE_FUNCTION size_type numSoA() const
Get the number of structs-of-arrays in the container.
Definition Cabana_Slice.hpp:330
Slice< member_data_type< M >, memory_space, DefaultAccessMemory, VectorLength, Stride > slice_type
Definition Cabana_Slice.hpp:168
Impl::KokkosViewWrapper< member_data_type< M >, vector_length, soa_stride > view_wrapper
Definition Cabana_Slice.hpp:199
Core: particle data structures and algorithms.
Definition Cabana_AoSoA.hpp:36
void copySliceToView(ExecutionSpace exec_space, ViewType &view, const SliceType &slice, const std::size_t begin, const std::size_t end, typename std::enable_if<(SliceType::view_rank==2), int * >::type=0)
Copy from slice to View. Rank-0.
Definition Cabana_Slice.hpp:541
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 copyViewToSlice(ExecutionSpace exec_space, SliceType &slice, const ViewType &view, const std::size_t begin, const std::size_t end, typename std::enable_if<(SliceType::view_rank==2), int * >::type=0)
Copy from View to slice. Rank-0.
Definition Cabana_Slice.hpp:600
KOKKOS_INLINE_FUNCTION 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:678
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:655
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:532