/usr/include/trilinos/Kokkos_View_MP_Vector_Interlaced.hpp is in libtrilinos-stokhos-dev 12.10.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 | // @HEADER
// ***********************************************************************
//
// Stokhos Package
// Copyright (2009) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
//
// ***********************************************************************
// @HEADER
#ifndef KOKKOS_VIEW_MP_VECTOR_INTERLACED_HPP
#define KOKKOS_VIEW_MP_VECTOR_INTERLACED_HPP
#include "Sacado_MP_Vector.hpp"
#include "Sacado_MP_VectorTraits.hpp"
#include "Stokhos_ViewStorage.hpp"
#include <Kokkos_Core.hpp>
#include "Kokkos_View_Utils.hpp"
#include "Kokkos_View_MP_Vector_Utils.hpp"
/*
* Specialization for Kokkos::View<Sacado::MP::Vector<Storage>...>
* where the Sacado dimension is interlaced for LayoutLeft.
*
* Currently it can't be used at the same time as other such View
* specializations due to conflicting specializations of AnalyzeShape.
*/
namespace Kokkos {
namespace Impl {
struct ViewMPVectorInterlaced {};
template< class ValueType , class MemorySpace , class MemoryTraits >
struct ViewSpecialize
< ValueType
, ViewMPVectorInterlaced
, LayoutLeft
, MemorySpace
, MemoryTraits >
{
typedef ViewMPVectorInterlaced type ;
};
template< class ValueType , class MemorySpace , class MemoryTraits >
struct ViewSpecialize
< ValueType
, ViewMPVectorInterlaced
, LayoutRight
, MemorySpace
, MemoryTraits >
{
typedef ViewMPVectorInterlaced type ;
};
} // namespace Impl
} // namespace Kokkos
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
namespace Kokkos {
namespace Impl {
namespace ViewError {
struct sacado_mp_vector_partition_constructor_requires_unmanaged_view {};
} // namespace ViewError
} // namespace Impl
} // namespace Kokkos
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
namespace Kokkos {
/**\brief View::value_type == Sacado::MP::Vector< Stokhos::StorageType<...> > */
template< class DataType ,
class Arg1Type ,
class Arg2Type ,
class Arg3Type >
class View< DataType , Arg1Type , Arg2Type , Arg3Type , Impl::ViewMPVectorInterlaced >
: public ViewTraits< DataType
, typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::array_layout
, typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::device_type
, typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::memory_traits
>
{
public:
typedef ViewTraits< DataType
, typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::array_layout
, typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::device_type
, typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::memory_traits
> traits ;
// Type of const views with same value type
typedef View< typename traits::const_data_type ,
typename traits::array_layout ,
typename traits::device_type ,
typename traits::memory_traits > const_type ;
// Type of non-const views with same value type
typedef View< typename traits::non_const_data_type ,
typename traits::array_layout ,
typename traits::device_type ,
typename traits::memory_traits > non_const_type ;
// Host mirror
typedef View< typename Impl::RebindStokhosStorageDevice<
typename traits::data_type ,
typename traits::host_mirror_space::memory_space >::type ,
typename traits::array_layout ,
typename traits::host_mirror_space ,
void > HostMirror ;
// Equivalent array type for this view.
typedef View< typename traits::array_type ,
typename traits::array_layout ,
typename traits::device_type ,
typename traits::memory_traits > array_type ;
// Equivalent const array type for this view.
typedef View< typename traits::const_array_type ,
typename traits::array_layout ,
typename traits::device_type ,
typename traits::memory_traits > const_array_type ;
// Equivalent host array type for this view.
typedef View< typename traits::array_type ,
typename traits::array_layout ,
typename traits::host_mirror_space ,
typename traits::memory_traits > host_array_type ;
// Equivalent const host array type for this view.
typedef View< typename traits::const_array_type ,
typename traits::array_layout ,
typename traits::host_mirror_space ,
typename traits::memory_traits > host_const_array_type ;
typedef typename traits::value_type sacado_mp_vector_type ;
typedef typename sacado_mp_vector_type::storage_type stokhos_storage_type ;
typedef typename stokhos_storage_type::value_type intrinsic_scalar_type ;
private:
// Assignment of compatible views requirement:
template< class , class , class , class , class > friend class View ;
// Assignment of compatible subview requirement:
template< class , class , class > friend struct Impl::ViewAssignment ;
enum { StokhosStorageStaticDimension = stokhos_storage_type::static_size };
typedef integral_nonzero_constant< unsigned , StokhosStorageStaticDimension > sacado_size_type;
typedef Impl::LayoutStride< typename traits::shape_type ,
typename traits::array_layout > stride_type ;
typedef typename array_type::traits::shape_type array_shape_type;
typename stokhos_storage_type::value_type * m_ptr_on_device ;
typename traits::shape_type m_shape ;
array_shape_type m_array_shape ; // Shape of intrinsic array
stride_type m_stride ;
typename traits::execution_space::size_type m_storage_size ; // Storage size of sacado dimension
sacado_size_type m_sacado_size ; // Size of sacado dimension
Impl::ViewDataManagement< traits > m_management ;
Impl::AllocationTracker m_tracker ;
// Note: if the view is partitioned, m_sacado_size != m_storage_size.
// We always have m_storage_size >= m_sacado_size
typedef Stokhos::ViewStorage<
typename stokhos_storage_type::ordinal_type ,
typename stokhos_storage_type::value_type ,
StokhosStorageStaticDimension ,
/* LayoutRight has stride-one stokhos storage */
( Impl::is_same< typename traits::array_layout , LayoutRight >::value ? 1 : 0 ) ,
typename traits::device_type > stokhos_view_storage_type ;
public:
// This needs to be public so that we know what the return type of () is
typedef Sacado::MP::Vector< stokhos_view_storage_type > reference_type ;
// Whether the storage type is statically sized
static const bool is_static = stokhos_storage_type::is_static;
// Whether sacado dimension is contiguous
static const bool is_contiguous =
Impl::is_same< typename traits::array_layout , LayoutRight >::value;
//------------------------------------
// Shape for the Sacado::MP::Vector value_type ignores the internal static array length.
enum { Rank = traits::rank };
// Rank corresponding to the sacado dimension
enum { Sacado_Rank = Rank+1 };
KOKKOS_FORCEINLINE_FUNCTION typename traits::shape_type shape() const { return m_shape ; }
KOKKOS_FORCEINLINE_FUNCTION typename traits::size_type dimension_0() const { return m_shape.N0 ; }
KOKKOS_FORCEINLINE_FUNCTION typename traits::size_type dimension_1() const { return m_shape.N1 ; }
KOKKOS_FORCEINLINE_FUNCTION typename traits::size_type dimension_2() const { return m_shape.N2 ; }
KOKKOS_FORCEINLINE_FUNCTION typename traits::size_type dimension_3() const { return m_shape.N3 ; }
KOKKOS_FORCEINLINE_FUNCTION typename traits::size_type dimension_4() const { return m_shape.N4 ; }
KOKKOS_FORCEINLINE_FUNCTION typename traits::size_type dimension_5() const { return m_shape.N5 ; }
KOKKOS_FORCEINLINE_FUNCTION typename traits::size_type dimension_6() const { return m_shape.N6 ; }
KOKKOS_FORCEINLINE_FUNCTION typename traits::size_type dimension_7() const { return m_shape.N7 ; }
KOKKOS_FORCEINLINE_FUNCTION typename traits::size_type size() const
{
return m_shape.N0
* m_shape.N1
* m_shape.N2
* m_shape.N3
* m_shape.N4
* m_shape.N5
* m_shape.N6
* m_shape.N7
;
}
template< typename iType >
KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type dimension( const iType & i ) const
{ return Impl::dimension( m_shape , i ); }
//------------------------------------
private:
// Restrict allocation to 'StokhosStorageStaticDimension'
inline
void verify_dimension_storage_static_size() const
{
if ( dimension( unsigned(Rank) ) % ( StokhosStorageStaticDimension ? StokhosStorageStaticDimension : 1 ) ) {
std::ostringstream msg ;
msg << "Kokkos::View< Sacado::MP::Vector<StorageType , ... > allocation dimension ("
<< dimension( unsigned(Rank) )
<< ") must be a multiple of StorageType::static_size ("
<< StokhosStorageStaticDimension
<< ")" ;
Impl::throw_runtime_exception( msg.str() );
}
}
#if defined( KOKKOS_EXPRESSION_CHECK )
KOKKOS_INLINE_FUNCTION
void verify_dimension_storage_size( const typename traits::execution_space & dev ) const
{
const int length = dimension( Rank );
const Impl::integral_nonzero_constant< int , StokhosStorageStaticDimension >
per_thread( ! StokhosStorageStaticDimension ? length / dev.team_size() : 0 );
if ( per_thread.value * dev.team_size() != length ) {
Kokkos::abort("Kokkos::View< Sacado::MP::Vector ... > incompatible vector-size : team-size");
}
}
#else
KOKKOS_INLINE_FUNCTION
void verify_dimension_storage_size( const typename traits::execution_space & ) const {}
#endif
public:
//------------------------------------
// Destructor, constructors, assignment operators:
KOKKOS_INLINE_FUNCTION
~View() { }
KOKKOS_INLINE_FUNCTION
View() : m_ptr_on_device(0), m_storage_size(0), m_sacado_size(0)
{
traits::shape_type::assign(m_shape,0,0,0,0,0,0,0,0);
array_shape_type::assign(m_array_shape,0,0,0,0,0,0,0,0);
stride_type::assign(m_stride,0);
}
KOKKOS_INLINE_FUNCTION
View( const View & rhs ) : m_ptr_on_device(0), m_storage_size(0), m_sacado_size(0)
{
(void) Impl::ViewAssignment<
typename traits::specialize ,
typename traits::specialize >( *this , rhs );
}
KOKKOS_INLINE_FUNCTION
View & operator = ( const View & rhs )
{
(void) Impl::ViewAssignment<
typename traits::specialize ,
typename traits::specialize >( *this , rhs );
return *this ;
}
//------------------------------------
// Construct or assign compatible view:
template< class RT , class RL , class RD , class RM >
KOKKOS_INLINE_FUNCTION
View( const View<RT,RL,RD,RM,typename traits::specialize> & rhs )
: m_ptr_on_device(0)
{
(void) Impl::ViewAssignment<
typename traits::specialize ,
typename traits::specialize >( *this , rhs );
}
template< class RT , class RL , class RD , class RM >
KOKKOS_INLINE_FUNCTION
View & operator = ( const View<RT,RL,RD,RM,typename traits::specialize> & rhs )
{
(void) Impl::ViewAssignment<
typename traits::specialize ,
typename traits::specialize >( *this , rhs );
return *this ;
}
//------------------------------------
// Allocation of a managed view with possible alignment padding.
typedef Impl::if_c< traits::is_managed ,
std::string ,
Impl::ViewError::allocation_constructor_requires_managed >
if_allocation_constructor ;
template< class AllocationProperties >
explicit inline
View( const AllocationProperties & prop ,
// Impl::ViewAllocProp::size_type exists when the traits and allocation properties
// are valid for allocating viewed memory.
const typename Impl::ViewAllocProp< traits , AllocationProperties >::size_type n0 = 0 ,
const size_t n1 = 0 ,
const size_t n2 = 0 ,
const size_t n3 = 0 ,
const size_t n4 = 0 ,
const size_t n5 = 0 ,
const size_t n6 = 0 ,
const size_t n7 = 0 )
: m_ptr_on_device(0)
{
typedef Impl::ViewAllocProp< traits , AllocationProperties > Alloc ;
typedef typename traits::memory_space memory_space ;
typedef typename traits::shape_type shape_type ;
typedef typename stokhos_storage_type::value_type scalar_type ;
shape_type::assign( m_shape, n0, n1, n2, n3, n4, n5, n6, n7 );
array_shape_type::assign( m_array_shape, n0, n1, n2, n3, n4, n5, n6, n7 );
stride_type::assign_with_padding( m_stride , m_array_shape );
m_storage_size = Impl::dimension( m_array_shape , unsigned(Rank) );
m_sacado_size = m_storage_size;
verify_dimension_storage_static_size();
m_tracker = memory_space::allocate_and_track( Alloc::label( prop ) , sizeof(scalar_type) * Impl::capacity( m_array_shape , m_stride ) );
m_ptr_on_device = (scalar_type *) m_tracker.alloc_ptr();
(void) Kokkos::Impl::ViewDefaultConstruct< typename traits::execution_space , scalar_type , Alloc::Initialize >
( m_ptr_on_device , Impl::capacity( m_array_shape , m_stride ) );
}
//------------------------------------
// Assign an unmanaged View from pointer, can be called in functors.
// No alignment padding is performed.
template< typename T >
View( T * ptr ,
const size_t n0 = 0 ,
const size_t n1 = 0 ,
const size_t n2 = 0 ,
const size_t n3 = 0 ,
const size_t n4 = 0 ,
const size_t n5 = 0 ,
const size_t n6 = 0 ,
typename Impl::enable_if<(
( Impl::is_same<T,typename traits::value_type>::value ||
Impl::is_same<T,typename traits::const_value_type>::value ) &&
! traits::is_managed ),
const size_t >::type n7 = 0 )
: m_ptr_on_device(ptr)
{
typedef typename traits::shape_type shape_type ;
shape_type::assign( m_shape, n0, n1, n2, n3, n4, n5, n6, n7 );
array_shape_type::assign( m_array_shape, n0, n1, n2, n3, n4, n5, n6, n7 );
stride_type::assign_no_padding( m_stride , m_shape );
m_storage_size = Impl::dimension( m_array_shape , unsigned(Rank) );
m_sacado_size = m_storage_size;
m_management.set_unmanaged();
verify_dimension_storage_static_size();
}
//------------------------------------
// Is not allocated
KOKKOS_FORCEINLINE_FUNCTION
bool is_null() const { return 0 == m_ptr_on_device ; }
//------------------------------------
//------------------------------------
// Scalar operator on traits::rank == 1
typedef Impl::if_c< ( traits::rank == 1 ),
reference_type ,
Impl::ViewError::scalar_operator_called_from_non_scalar_view >
if_scalar_operator ;
KOKKOS_FORCEINLINE_FUNCTION
typename if_scalar_operator::type
operator()() const
{
KOKKOS_RESTRICT_EXECUTION_TO_DATA( typename traits::memory_space , m_ptr_on_device );
return reference_type( stokhos_view_storage_type(
m_ptr_on_device ,
m_shape.N0 , 1 ) );
}
//------------------------------------
//------------------------------------
// Array operators, traits::rank 2:
template< typename iType0 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type , traits, LayoutLeft, 2, iType0 >::type
operator() ( const iType0 & i0 ) const
{
KOKKOS_ASSERT_SHAPE_BOUNDS_2( m_shape, i0, 0 );
KOKKOS_RESTRICT_EXECUTION_TO_DATA( typename traits::memory_space , m_ptr_on_device );
// Strided storage
return reference_type( stokhos_view_storage_type(
m_ptr_on_device + i0 ,
m_shape.N1 ,
m_stride.value ) );
}
template< typename iType0 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, LayoutRight, 2, iType0 >::type
operator() ( const iType0 & i0 ) const
{
KOKKOS_ASSERT_SHAPE_BOUNDS_2( m_shape, i0, 0 );
KOKKOS_RESTRICT_EXECUTION_TO_DATA( typename traits::memory_space , m_ptr_on_device );
// Contiguous storage with right-most index as the stokhos dimension
return reference_type( stokhos_view_storage_type(
m_ptr_on_device + ( m_stride.value * i0 ) ,
m_shape.N1 , 1 ) );
}
template< typename iType0 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type , traits, typename traits::array_layout, 2, iType0 >::type
operator[] ( const iType0 & i0 ) const
{ return operator()( i0 ); }
template< typename iType0 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, typename traits::array_layout, 2,
iType0 >::type
at( const iType0 & i0 , int , int , int , int , int , int , int ) const
{ return operator()(i0); }
//------------------------------------
//------------------------------------
// Array operators, traits::rank 3:
template< typename iType0 , typename iType1 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, LayoutLeft, 3, iType0, iType1 >::type
operator() ( const iType0 & i0 , const iType1 & i1 ) const
{
KOKKOS_ASSERT_SHAPE_BOUNDS_3( m_shape, i0, i1, 0 );
KOKKOS_RESTRICT_EXECUTION_TO_DATA( typename traits::memory_space , m_ptr_on_device );
// Strided storage with right-most index as the stokhos dimension
return reference_type( stokhos_view_storage_type(
m_ptr_on_device + ( i0 + m_stride.value * ( i1 )),
m_shape.N2 ,
m_stride.value * m_shape.N1 ) );
}
template< typename iType0 , typename iType1 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, LayoutRight, 3, iType0, iType1 >::type
operator() ( const iType0 & i0 , const iType1 & i1 ) const
{
KOKKOS_ASSERT_SHAPE_BOUNDS_3( m_shape, i0, i1, 0);
KOKKOS_RESTRICT_EXECUTION_TO_DATA( typename traits::memory_space , m_ptr_on_device );
// Contiguous storage with right-most index as the stokhos dimension
return reference_type( stokhos_view_storage_type(
m_ptr_on_device + ( m_storage_size * ( i1 ) + m_stride.value * i0 ) ,
m_shape.N2 , 1 ) );
}
template< typename iType0 , typename iType1 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, typename traits::array_layout, 3,
iType0, iType1 >::type
at( const iType0 & i0 , const iType1 & i1 , int , int , int , int , int , int ) const
{ return operator()(i0,i1); }
//------------------------------------
//------------------------------------
// Array operators, traits::rank 4:
template< typename iType0 , typename iType1 , typename iType2 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, LayoutLeft, 4, iType0, iType1, iType2 >::type
operator() ( const iType0 & i0 , const iType1 & i1 , const iType2 & i2 ) const
{
KOKKOS_ASSERT_SHAPE_BOUNDS_4( m_shape, i0, i1, i2, 0 );
KOKKOS_RESTRICT_EXECUTION_TO_DATA( typename traits::memory_space , m_ptr_on_device );
// Strided storage with right-most index as the stokhos dimension
return reference_type( stokhos_view_storage_type(
m_ptr_on_device + ( i0 + m_stride.value * (
i1 + m_shape.N1 * (
i2 ))),
m_shape.N3 ,
m_stride.value * m_shape.N1 * m_shape.N2 ) );
}
template< typename iType0 , typename iType1 , typename iType2 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, LayoutRight, 4, iType0, iType1, iType2 >::type
operator() ( const iType0 & i0 , const iType1 & i1 , const iType2 & i2 ) const
{
KOKKOS_ASSERT_SHAPE_BOUNDS_4( m_shape, i0, i1, i2, 0 );
KOKKOS_RESTRICT_EXECUTION_TO_DATA( typename traits::memory_space , m_ptr_on_device );
// Contiguous storage with right-most index as the stokhos dimension
return reference_type( stokhos_view_storage_type(
m_ptr_on_device + ( m_storage_size * ( i2 +
m_shape.N2 * ( i1 )) +
m_stride.value * i0 ) ,
m_shape.N3 , 1 ) );
}
template< typename iType0 , typename iType1 , typename iType2 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, typename traits::array_layout, 4,
iType0, iType1, iType2 >::type
at( const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , int , int , int , int , int ) const
{ return operator()(i0,i1,i2); }
//------------------------------------
//------------------------------------
// Array operators, traits::rank 5:
template< typename iType0 , typename iType1 , typename iType2 , typename iType3 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, LayoutLeft, 5, iType0, iType1, iType2, iType3 >::type
operator() ( const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 ) const
{
KOKKOS_ASSERT_SHAPE_BOUNDS_5( m_shape, i0, i1, i2, i3, 0 );
KOKKOS_RESTRICT_EXECUTION_TO_DATA( typename traits::memory_space , m_ptr_on_device );
// Strided storage with right-most index as the stokhos dimension
return reference_type( stokhos_view_storage_type(
m_ptr_on_device + ( i0 + m_stride.value * (
i1 + m_shape.N1 * (
i2 + m_shape.N2 * (
i3 )))),
m_shape.N4 ,
m_stride.value * m_shape.N1 * m_shape.N2 * m_shape.N3 ) );
}
template< typename iType0 , typename iType1 , typename iType2 , typename iType3 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, LayoutRight, 5, iType0, iType1, iType2, iType3 >::type
operator() ( const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 ) const
{
KOKKOS_ASSERT_SHAPE_BOUNDS_5( m_shape, i0, i1, i2, i3, 0 );
KOKKOS_RESTRICT_EXECUTION_TO_DATA( typename traits::memory_space , m_ptr_on_device );
// Contiguous storage with right-most index as the stokhos dimension
return reference_type( stokhos_view_storage_type(
m_ptr_on_device + ( m_storage_size * ( i3 +
m_shape.N3 * ( i2 +
m_shape.N2 * ( i1 ))) +
m_stride.value * i0 ) ,
m_shape.N4 , 1 ) );
}
template< typename iType0 , typename iType1 , typename iType2 , typename iType3 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, typename traits::array_layout, 5,
iType0, iType1, iType2, iType3 >::type
at( const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 , int , int , int , int ) const
{ return operator()(i0,i1,i2,i3); }
//------------------------------------
//------------------------------------
// Array operators, traits::rank 6:
template< typename iType0 , typename iType1 , typename iType2 , typename iType3 , typename iType4 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, LayoutLeft, 6, iType0, iType1, iType2, iType3, iType4 >::type
operator() ( const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 , const iType4 & i4 ) const
{
KOKKOS_ASSERT_SHAPE_BOUNDS_6( m_shape, i0, i1, i2, i3, i4, 0 );
KOKKOS_RESTRICT_EXECUTION_TO_DATA( typename traits::memory_space , m_ptr_on_device );
// Strided storage with right-most index as the stokhos dimension
return reference_type( stokhos_view_storage_type(
m_ptr_on_device + ( i0 + m_stride.value * (
i1 + m_shape.N1 * (
i2 + m_shape.N2 * (
i3 + m_shape.N3 * (
i4 ))))),
m_shape.N5 ,
m_stride.value * m_shape.N1 * m_shape.N2 * m_shape.N3 * m_shape.N4 ) );
}
template< typename iType0 , typename iType1 , typename iType2 ,
typename iType3 , typename iType4 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, LayoutRight, 6, iType0, iType1, iType2, iType3, iType4 >::type
operator() ( const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 ,
const iType4 & i4 ) const
{
KOKKOS_ASSERT_SHAPE_BOUNDS_6( m_shape, i0, i1, i2, i3, i4, 0 );
KOKKOS_RESTRICT_EXECUTION_TO_DATA( typename traits::memory_space , m_ptr_on_device );
// Contiguous storage with right-most index as the stokhos dimension
return reference_type( stokhos_view_storage_type(
m_ptr_on_device + ( m_storage_size * ( i4 +
m_shape.N4 * ( i3 +
m_shape.N3 * ( i2 +
m_shape.N2 * ( i1 )))) +
m_stride.value * i0 ) ,
m_shape.N5 , 1 ) );
}
template< typename iType0 , typename iType1 , typename iType2 ,
typename iType3 , typename iType4 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, typename traits::array_layout, 6,
iType0, iType1, iType2, iType3, iType4 >::type
at( const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 ,
const iType4 & i4 , int , int , int ) const
{ return operator()(i0,i1,i2,i3,i4); }
//------------------------------------
//------------------------------------
// Array operators, traits::rank 7:
template< typename iType0 , typename iType1 , typename iType2 , typename iType3 , typename iType4 , typename iType5 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, LayoutLeft, 7, iType0, iType1, iType2, iType3, iType4, iType5 >::type
operator() ( const iType0 & i0 , const iType1 & i1 , const iType2 & i2 ,
const iType3 & i3 , const iType4 & i4 , const iType5 & i5 ) const
{
KOKKOS_ASSERT_SHAPE_BOUNDS_7( m_shape, i0, i1, i2, i3, i4, i5, 0 );
KOKKOS_RESTRICT_EXECUTION_TO_DATA( typename traits::memory_space , m_ptr_on_device );
// Strided storage with right-most index as the stokhos dimension
return reference_type( stokhos_view_storage_type(
m_ptr_on_device + ( i0 + m_stride.value * (
i1 + m_shape.N1 * (
i2 + m_shape.N2 * (
i3 + m_shape.N3 * (
i4 + m_shape.N4 * (
i5 )))))),
m_shape.N6 ,
m_stride.value * m_shape.N1 * m_shape.N2 * m_shape.N3 * m_shape.N4 * m_shape.N5 ) );
}
template< typename iType0 , typename iType1 , typename iType2 ,
typename iType3 , typename iType4 , typename iType5 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, LayoutRight, 7, iType0, iType1, iType2, iType3, iType4, iType5 >::type
operator() ( const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 ,
const iType4 & i4 , const iType5 & i5 ) const
{
KOKKOS_ASSERT_SHAPE_BOUNDS_7( m_shape, i0, i1, i2, i3, i4, i5, 0 );
KOKKOS_RESTRICT_EXECUTION_TO_DATA( typename traits::memory_space , m_ptr_on_device );
// Contiguous storage with right-most index as the stokhos dimension
return reference_type( stokhos_view_storage_type(
m_ptr_on_device + ( m_storage_size * ( i5 +
m_shape.N5 * ( i4 +
m_shape.N4 * ( i3 +
m_shape.N3 * ( i2 +
m_shape.N2 * ( i1 ))))) +
m_stride.value * i0 ) ,
m_shape.N6 , 1 ) );
}
template< typename iType0 , typename iType1 , typename iType2 ,
typename iType3 , typename iType4 , typename iType5 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, typename traits::array_layout, 7,
iType0, iType1, iType2, iType3, iType4, iType5 >::type
at( const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 ,
const iType4 & i4 , const iType5 & i5 , int , int ) const
{ return operator()(i0,i1,i2,i3,i4,i5); }
//------------------------------------
//------------------------------------
// Array operators, traits::rank 8:
template< typename iType0 , typename iType1 , typename iType2 , typename iType3 ,
typename iType4 , typename iType5 , typename iType6 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, LayoutLeft, 8, iType0, iType1, iType2, iType3, iType4, iType5, iType6 >::type
operator() ( const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 ,
const iType4 & i4 , const iType5 & i5 , const iType6 & i6 ) const
{
KOKKOS_RESTRICT_EXECUTION_TO_DATA( typename traits::memory_space , m_ptr_on_device );
KOKKOS_ASSERT_SHAPE_BOUNDS_8( m_shape, i0, i1, i2, i3, i4, i5, i6, 0 );
// Strided storage with right-most index as the stokhos dimension
return reference_type( stokhos_view_storage_type(
m_ptr_on_device + ( i0 + m_stride.value * (
i1 + m_shape.N1 * (
i2 + m_shape.N2 * (
i3 + m_shape.N3 * (
i4 + m_shape.N4 * (
i5 + m_shape.N5 * (
i6 ))))))),
m_shape.N7 ,
m_stride.value * m_shape.N1 * m_shape.N2 * m_shape.N3 * m_shape.N4 * m_shape.N5 * m_shape.N6 ) );
}
template< typename iType0 , typename iType1 , typename iType2 ,
typename iType3 , typename iType4 , typename iType5, typename iType6 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, LayoutRight, 8, iType0, iType1, iType2, iType3, iType4, iType5, iType6 >::type
operator() ( const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 ,
const iType4 & i4 , const iType5 & i5 , const iType6 & i6 ) const
{
KOKKOS_ASSERT_SHAPE_BOUNDS_8( m_shape, i0, i1, i2, i3, i4, i5, i6, 0 );
KOKKOS_RESTRICT_EXECUTION_TO_DATA( typename traits::memory_space , m_ptr_on_device );
// Contiguous storage with right-most index as the stokhos dimension
return reference_type( stokhos_view_storage_type(
m_ptr_on_device + ( m_storage_size * ( i6 +
m_shape.N6 * ( i5 +
m_shape.N5 * ( i4 +
m_shape.N4 * ( i3 +
m_shape.N3 * ( i2 +
m_shape.N2 * ( i1 )))))) +
m_stride.value * i0 ) ,
m_shape.N7 , 1 ) );
}
template< typename iType0 , typename iType1 , typename iType2 ,
typename iType3 , typename iType4 , typename iType5, typename iType6 >
KOKKOS_FORCEINLINE_FUNCTION
typename Impl::ViewEnableArrayOper< reference_type ,
traits, typename traits::array_layout, 8,
iType0, iType1, iType2, iType3, iType4, iType5, iType6 >::type
at( const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 ,
const iType4 & i4 , const iType5 & i5 , const iType6 & i6 , int ) const
{ return operator()(i0,i1,i2,i3,i4,i5,i6); }
//------------------------------------
// Access to the underlying contiguous storage of this view specialization.
// These methods are specific to specialization of a view.
KOKKOS_FORCEINLINE_FUNCTION
typename traits::value_type::storage_type::value_type *
ptr_on_device() const { return m_ptr_on_device ; }
// Stride of physical storage, dimensioned to at least Rank
template< typename iType >
KOKKOS_FORCEINLINE_FUNCTION
void stride( iType * const s ) const
{ Impl::stride( s , m_array_shape , m_stride ); }
// Count of contiguously allocated data members including padding.
KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type capacity() const
{ return Impl::capacity( m_array_shape , m_stride ); }
// Static storage size
KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type sacado_size() const
{ return m_sacado_size.value; }
};
/** \brief A deep copy between views of the same specialization, compatible type,
* same rank, same layout are handled by that specialization.
*/
template< class DT , class DL , class DD , class DM ,
class ST , class SL , class SD , class SM >
inline
void deep_copy( const View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced> & dst ,
const View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced> & src ,
typename Impl::enable_if<(
Impl::is_same< typename View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced>::intinsic_scalar_type ,
typename View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced>::intinsic_scalar_type >::value
&&
Impl::is_same< typename View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced>::array_layout ,
typename View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced>::array_layout >::value
&&
( unsigned(View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced>::rank) ==
unsigned(View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced>::rank) )
)>::type * = 0 )
{
typedef View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced> dst_type ;
typedef View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced> src_type ;
typedef typename dst_type::memory_space dst_memory_space ;
typedef typename src_type::memory_space src_memory_space ;
if ( dst.ptr_on_device() != src.ptr_on_device() ) {
Impl::assert_shapes_are_equal( dst.shape() , src.shape() );
const size_t nbytes = sizeof(typename dst_type::value_type::storage_type::value_type) * dst.capacity();
Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.ptr_on_device() , src.ptr_on_device() , nbytes );
}
}
} // namespace Kokkos
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
namespace Kokkos {
namespace Impl {
/** \brief Analyze the array shape of a Sacado::MP::Vector.
*
* This specialization is required so that the array shape of
* Kokkos::View< Sacado::MP::Vector< StorageType > , ... >
* can be determined at compile-time.
*/
template< class StorageType >
struct AnalyzeShape< Sacado::MP::Vector< StorageType > >
: Shape< sizeof(Sacado::MP::Vector< StorageType >) , 0 > // Treat as a scalar
{
private:
typedef AnalyzeShape< typename StorageType::value_type > nested ;
public:
typedef typename ViewMPVectorInterlaced specialize ;
typedef Shape< sizeof(Sacado::MP::Vector< StorageType >) , 0 > shape ;
// If ( ! StorageType::is_static ) then 0 == StorageType::static_size and the first array declaration is not used.
// However, the compiler will still generate this type declaration and it must not have a zero length.
typedef typename
if_c< StorageType::is_static
, typename nested::array_intrinsic_type [ StorageType::is_static ? StorageType::static_size : 1 ]
, typename nested::array_intrinsic_type *
>::type array_intrinsic_type ;
typedef typename
if_c< StorageType::is_static
, typename nested::const_array_intrinsic_type [ StorageType::is_static ? StorageType::static_size : 1 ]
, typename nested::const_array_intrinsic_type *
>::type const_array_intrinsic_type ;
typedef array_intrinsic_type non_const_array_intrinsic_type ;
typedef Sacado::MP::Vector< StorageType > type ;
typedef const Sacado::MP::Vector< StorageType > const_type ;
typedef Sacado::MP::Vector< StorageType > non_const_type ;
typedef Sacado::MP::Vector< StorageType > value_type ;
typedef const Sacado::MP::Vector< StorageType > const_value_type ;
typedef Sacado::MP::Vector< StorageType > non_const_value_type ;
};
//----------------------------------------------------------------------------
template<>
struct ViewAssignment< ViewMPVectorInterlaced , ViewMPVectorInterlaced , void >
{
typedef ViewMPVectorContiguous specialize ;
//------------------------------------
/** \brief Compatible value and shape */
template< class DT , class DL , class DD , class DM ,
class ST , class SL , class SD , class SM >
KOKKOS_INLINE_FUNCTION
ViewAssignment( View<DT,DL,DD,DM,specialize> & dst
, const View<ST,SL,SD,SM,specialize> & src
, const typename enable_if<(
ViewAssignable< ViewTraits<DT,DL,DD,DM> ,
ViewTraits<ST,SL,SD,SM> >::value
)>::type * = 0
)
{
typedef ViewTraits<DT,DL,DD,DM> dst_traits ;
typedef View<DT,DL,DD,DM,specialize> dst_type ;
typedef typename dst_type::shape_type shape_type ;
typedef typename dst_type::array_shape_type array_shape_type ;
typedef typename dst_type::stride_type stride_type ;
shape_type::assign( dst.m_shape,
src.m_shape.N0 , src.m_shape.N1 , src.m_shape.N2 , src.m_shape.N3 ,
src.m_shape.N4 , src.m_shape.N5 , src.m_shape.N6 , src.m_shape.N7 );
array_shape_type::assign( dst.m_array_shape,
src.m_array_shape.N0 , src.m_array_shape.N1 , src.m_array_shape.N2 , src.m_array_shape.N3 ,
src.m_array_shape.N4 , src.m_array_shape.N5 , src.m_array_shape.N6 , src.m_array_shape.N7 );
stride_type::assign( dst.m_stride , src.m_stride.value );
dst.m_ptr_on_device = src.m_ptr_on_device ;
dst.m_storage_size = src.m_storage_size ;
dst.m_sacado_size = src.m_sacado_size ;
dst.m_tracker = src.m_tracker ;
}
//------------------------------------
/** \brief Partition of compatible value and shape */
template< class DT , class DL , class DD , class DM ,
class ST , class SL , class SD , class SM >
KOKKOS_INLINE_FUNCTION
ViewAssignment( View<DT,DL,DD,DM,specialize> & dst
, const View<ST,SL,SD,SM,specialize> & src
, typename enable_if<(
// Same intrinsic scalar type
is_same< typename View<DT,DL,DD,DM,specialize>::intrinsic_scalar_type ,
typename View<ST,SL,SD,SM,specialize>::intrinsic_scalar_type >::value
&&
// Same memory space
is_same< typename View<DT,DL,DD,DM,specialize>::memory_space ,
typename View<ST,SL,SD,SM,specialize>::memory_space >::value
&&
// Same layout
is_same< typename View<DT,DL,DD,DM,specialize>::array_layout ,
typename View<ST,SL,SD,SM,specialize>::array_layout >::value
&&
// Same rank
( unsigned(View<DT,DL,DD,DM,specialize>::Rank) ==
unsigned(View<ST,SL,SD,SM,specialize>::Rank) )
&&
// Destination is not managed
! View<DT,DL,DD,DM,specialize>::is_managed
), const Sacado::MP::VectorPartition & >::type part )
{
typedef ViewTraits<DT,DL,DD,DM> dst_traits ;
typedef View<DT,DL,DD,DM,specialize> dst_type ;
typedef typename dst_type::shape_type dst_shape_type ;
typedef typename dst_type::array_shape_type dst_array_shape_type ;
typedef typename dst_type::stride_type dst_stride_type ;
typedef typename dst_traits::value_type dst_sacado_mp_vector_type ;
typedef typename dst_sacado_mp_vector_type::storage_type dst_stokhos_storage_type ;
enum { DstRank = dst_type::Rank };
enum { DstStaticLength = dst_stokhos_storage_type::static_size };
const int length = part.end - part.begin ;
if ( DstStaticLength && DstStaticLength != length ) {
Kokkos::abort("Kokkos::View< Sacado::MP::Vector ... > incompatible partitioning");
}
unsigned dims[8];
dims[0] = src.m_array_shape.N0;
dims[1] = src.m_array_shape.N1;
dims[2] = src.m_array_shape.N2;
dims[3] = src.m_array_shape.N3;
dims[4] = src.m_array_shape.N4;
dims[5] = src.m_array_shape.N5;
dims[6] = src.m_array_shape.N6;
dims[7] = src.m_array_shape.N7;
unsigned rank = dst_type::Rank;
dst_shape_type::assign( dst.m_shape,
dims[0] , dims[1] , dims[2] , dims[3] ,
dims[4] , dims[5] , dims[6] , dims[7] );
dims[rank] = length;
dst_array_shape_type::assign( dst.m_array_shape,
dims[0] , dims[1] , dims[2] , dims[3] ,
dims[4] , dims[5] , dims[6] , dims[7] );
dst_stride_type::assign( dst.m_stride , src.m_stride.value );
// Original Sacado::MP::Vector length
dst.m_storage_size = src.m_storage_size ;
dst.m_sacado_size = length;
if ( Impl::is_same< typename dst_traits::array_layout , LayoutLeft >::value ) {
dst.m_ptr_on_device = src.m_ptr_on_device + part.begin *
( 0 == DstRank ? 1 : dst.m_stride.value * (
( 1 == DstRank ? 1 : dst.m_shape.N1 * (
( 2 == DstRank ? 1 : dst.m_shape.N2 * (
( 3 == DstRank ? 1 : dst.m_shape.N3 * (
( 4 == DstRank ? 1 : dst.m_shape.N4 * (
( 5 == DstRank ? 1 : dst.m_shape.N5 * (
( 6 == DstRank ? 1 : dst.m_shape.N6 )))))))))))));
}
else { // if ( Impl::is_same< typename traits::array_layout , LayoutRight >::value )
dst.m_ptr_on_device = src.m_ptr_on_device + part.begin ;
}
dst.m_tracker = src.m_tracker ;
}
};
template<>
struct ViewAssignment< ViewDefault , ViewMPVectorInterlaced , void >
{
//------------------------------------
/** \brief Compatible value and shape */
template< class ST , class SL , class SD , class SM >
KOKKOS_INLINE_FUNCTION
ViewAssignment( typename View<ST,SL,SD,SM,ViewMPVectorInterlaced>::array_type & dst
, const View<ST,SL,SD,SM,ViewMPVectorInterlaced> & src )
{
typedef View<ST,SL,SD,SM,ViewMPVectorInterlaced> src_type ;
typedef typename src_type::value_type src_sacado_mp_vector_type ;
typedef typename src_sacado_mp_vector_type::storage_type src_stokhos_storage_type ;
typedef typename src_type::array_type dst_type ;
typedef typename dst_type::shape_type dst_shape_type ;
typedef typename dst_type::stride_type dst_stride_type ;
dst_shape_type::assign( dst.m_shape,
src.m_array_shape.N0 , src.m_array_shape.N1 , src.m_array_shape.N2 , src.m_arrat_shape.N3 ,
src.m_array_shape.N4 , src.m_array_shape.N5 , src.m_arrat_shape.N6 , src.m_arrat_shape.N7 );
dst_stride_type::assign( dst.m_stride , src.m_stride.value );
dst.m_ptr_on_device = reinterpret_cast< typename dst_type::value_type *>( src.m_ptr_on_device );
dst.m_tracker = src.m_tracker ;
}
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
} // namespace Impl
} // namespace Kokkos
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
#endif /* #ifndef KOKKOS_VIEW_MP_VECTOR_HPP */
|