Loading src/TNL/Containers/ArrayView.h +10 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,16 @@ public: __cuda_callable__ ArrayView( StaticArray< Size, Element_ >& array ); // these constructors will be used only when Element is const-qualified // (const views are initializable by const references) template< typename Element_ > // template catches both const and non-const qualified Element __cuda_callable__ ArrayView( const Array< Element_, Device, Index >& array ); template< int Size, typename Element_ > // template catches both const and non-const qualified Element __cuda_callable__ ArrayView( const StaticArray< Size, Element_ >& array ); // methods for rebinding (reinitialization) __cuda_callable__ Loading src/TNL/Containers/ArrayView_impl.h +22 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,28 @@ ArrayView( StaticArray< Size, Element_ >& array ) this->bind( array.getData(), Size ); } template< typename Element, typename Device, typename Index > template< typename Element_ > __cuda_callable__ ArrayView< Element, Device, Index >:: ArrayView( const Array< Element_, Device, Index >& array ) { this->bind( array.getData(), array.getSize() ); } template< typename Element, typename Device, typename Index > template< int Size, typename Element_ > __cuda_callable__ ArrayView< Element, Device, Index >:: ArrayView( const StaticArray< Size, Element_ >& array ) { this->bind( array.getData(), Size ); } // methods for rebinding (reinitialization) template< typename Element, typename Device, Loading src/UnitTests/Containers/ArrayViewTest.h +6 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ TYPED_TEST( ArrayViewTest, constructors ) { using ArrayType = typename TestFixture::ArrayType; using ViewType = typename TestFixture::ViewType; using ConstViewType = ArrayView< const typename ArrayType::ElementType, typename ArrayType::DeviceType, typename ArrayType::IndexType >; ArrayType a( 10 ); EXPECT_EQ( a.getSize(), 10 ); Loading @@ -154,6 +155,11 @@ TYPED_TEST( ArrayViewTest, constructors ) EXPECT_EQ( z.getData(), data ); EXPECT_EQ( z.getSize(), 10 ); } // test initialization by const reference const ArrayType& b = a; ConstViewType b_view( b ); ConstViewType const_a_view( a ); } TYPED_TEST( ArrayViewTest, bind ) Loading Loading
src/TNL/Containers/ArrayView.h +10 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,16 @@ public: __cuda_callable__ ArrayView( StaticArray< Size, Element_ >& array ); // these constructors will be used only when Element is const-qualified // (const views are initializable by const references) template< typename Element_ > // template catches both const and non-const qualified Element __cuda_callable__ ArrayView( const Array< Element_, Device, Index >& array ); template< int Size, typename Element_ > // template catches both const and non-const qualified Element __cuda_callable__ ArrayView( const StaticArray< Size, Element_ >& array ); // methods for rebinding (reinitialization) __cuda_callable__ Loading
src/TNL/Containers/ArrayView_impl.h +22 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,28 @@ ArrayView( StaticArray< Size, Element_ >& array ) this->bind( array.getData(), Size ); } template< typename Element, typename Device, typename Index > template< typename Element_ > __cuda_callable__ ArrayView< Element, Device, Index >:: ArrayView( const Array< Element_, Device, Index >& array ) { this->bind( array.getData(), array.getSize() ); } template< typename Element, typename Device, typename Index > template< int Size, typename Element_ > __cuda_callable__ ArrayView< Element, Device, Index >:: ArrayView( const StaticArray< Size, Element_ >& array ) { this->bind( array.getData(), Size ); } // methods for rebinding (reinitialization) template< typename Element, typename Device, Loading
src/UnitTests/Containers/ArrayViewTest.h +6 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ TYPED_TEST( ArrayViewTest, constructors ) { using ArrayType = typename TestFixture::ArrayType; using ViewType = typename TestFixture::ViewType; using ConstViewType = ArrayView< const typename ArrayType::ElementType, typename ArrayType::DeviceType, typename ArrayType::IndexType >; ArrayType a( 10 ); EXPECT_EQ( a.getSize(), 10 ); Loading @@ -154,6 +155,11 @@ TYPED_TEST( ArrayViewTest, constructors ) EXPECT_EQ( z.getData(), data ); EXPECT_EQ( z.getSize(), 10 ); } // test initialization by const reference const ArrayType& b = a; ConstViewType b_view( b ); ConstViewType const_a_view( a ); } TYPED_TEST( ArrayViewTest, bind ) Loading