Loading src/TNL/Containers/Algorithms/ArrayOperations.h +8 −3 Original line number Diff line number Diff line Loading @@ -53,6 +53,11 @@ class ArrayOperations< Devices::Host > const SourceElement* source, const Index size ); template< typename DestinationElement, typename SourceElement > static void copySTLList( DestinationElement* destination, const std::list< SourceElement >& source ); template< typename Element1, typename Element2, typename Index > Loading Loading @@ -260,6 +265,6 @@ class ArrayOperations< Devices::Host, Devices::MIC > } // namespace Containers } // namespace TNL #include <TNL/Containers/Algorithms/ArrayOperationsHost_impl.h> #include <TNL/Containers/Algorithms/ArrayOperationsCuda_impl.h> #include <TNL/Containers/Algorithms/ArrayOperationsMIC_impl.h> #include <TNL/Containers/Algorithms/ArrayOperationsHost.hpp> #include <TNL/Containers/Algorithms/ArrayOperationsCuda.hpp> #include <TNL/Containers/Algorithms/ArrayOperationsMIC.hpp> src/TNL/Containers/Algorithms/ArrayOperationsCuda_impl.h→src/TNL/Containers/Algorithms/ArrayOperationsCuda.hpp +21 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,27 @@ copyMemory( DestinationElement* destination, #endif } template< typename DestinationElement, typename SourceElement > ArrayOperations< Devices::Cuda >:: void copySTLList( DestinationElement* destination, const std::list< SourceElement >& source ) { const auto size = source.size(); const std::streamsize copy_buffer_size = std::min( Devices::Cuda::TransferBufferSize / (std::streamsize) sizeof(SourceType), size ); using BaseType = typename std::remove_cv< SourceType >::type; std::unique_ptr< BaseType[] > copy_buffer{ new BaseType[ copy_buffer_size ] }; size_t copiedElements = 0; auto it = source.begin(); while( copiedElements < size ) { const auto copySize = std::min( size - copiedElements, copy_buffer_size ); for( size_t i = 0; i < copySize; i++ ) copy_buffer[ copiedElements ++ ] = static_cast< DestinationElement >( * it ++ ); ArrayOperations< Devices::Cuda, Devices::Host >::copyMemory( destination, copy_buffer, copySize ); } } template< typename Element1, typename Element2, typename Index > Loading src/TNL/Containers/Algorithms/ArrayOperationsHost_impl.h→src/TNL/Containers/Algorithms/ArrayOperationsHost.hpp +12 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,18 @@ copyMemory( DestinationElement* destination, destination[ i ] = ( DestinationElement ) source[ i ]; } template< typename DestinationElement, typename SourceElement > ArrayOperations< Devices::Host >:: void copySTLList( DestinationElement* destination, const std::list< SourceElement >& source ) { size_t i = 0; for( SourceElement& e : source ) destination[ i ++ ] = static_cast< DesitnationElement >( e ); } template< typename DestinationElement, typename SourceElement, typename Index > Loading src/TNL/Containers/Algorithms/ArrayOperationsMIC_impl.h→src/TNL/Containers/Algorithms/ArrayOperationsMIC.hpp +9 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,15 @@ copyMemory( DestinationElement* destination, #endif } template< typename DestinationElement, typename SourceElement > ArrayOperations< Devices::MIC >:: void copySTLList( DestinationElement* destination, const std::list< SourceElement >& source ) { TNL_ASSERT( false, std::cerr << "TODO" ); } template< typename Element1, typename Element2, typename Index > Loading src/TNL/Containers/Array.h +25 −11 Original line number Diff line number Diff line Loading @@ -80,33 +80,47 @@ class Array : public Object const IndexType& size = 0 ); /** * \brief Initialize the array from initializer list, i.e. { ... } * * @param list * @param list Initializer list. */ Array( const std::initializer_list< Value >& list ); template< typename InValue > Array( const std::initializer_list< InValue >& list ); /** * \brief Initialize the array from std::list. * * @param list * @param list Input STL list. */ Array( const std::list< Value >& list ); template< typename InValue > Array( const std::list< InValue >& list ); /** * \brief Initialize the array from std::vector. * * @param vector * @param vector Input STL vector. */ Array( const std::vector< Value >& vector ); template< typename InValue > Array( const std::vector< InValue >& vector ); /** \brief Returns type of array Value, Device type and the type of Index. */ /** * \brief Returns type of array Value, Device type and the type of Index. */ static String getType(); /** \brief Returns type of array Value, Device type and the type of Index. */ /** * \brief Returns type of array Value, Device type and the type of Index. */ virtual String getTypeVirtual() const; /** \brief Returns (host) type of array Value, Device type and the type of Index. */ /** * \brief Returns (host) type of array Value, Device type and the type of Index. */ static String getSerializationType(); /** \brief Returns (host) type of array Value, Device type and the type of Index. */ /** * \brief Returns (host) type of array Value, Device type and the type of Index. */ virtual String getSerializationTypeVirtual() const; /** Loading Loading @@ -375,4 +389,4 @@ std::ostream& operator << ( std::ostream& str, const Array< Value, Device, Index } // namespace Containers } // namespace TNL #include <TNL/Containers/Array_impl.h> #include <TNL/Containers/Array.hpp> Loading
src/TNL/Containers/Algorithms/ArrayOperations.h +8 −3 Original line number Diff line number Diff line Loading @@ -53,6 +53,11 @@ class ArrayOperations< Devices::Host > const SourceElement* source, const Index size ); template< typename DestinationElement, typename SourceElement > static void copySTLList( DestinationElement* destination, const std::list< SourceElement >& source ); template< typename Element1, typename Element2, typename Index > Loading Loading @@ -260,6 +265,6 @@ class ArrayOperations< Devices::Host, Devices::MIC > } // namespace Containers } // namespace TNL #include <TNL/Containers/Algorithms/ArrayOperationsHost_impl.h> #include <TNL/Containers/Algorithms/ArrayOperationsCuda_impl.h> #include <TNL/Containers/Algorithms/ArrayOperationsMIC_impl.h> #include <TNL/Containers/Algorithms/ArrayOperationsHost.hpp> #include <TNL/Containers/Algorithms/ArrayOperationsCuda.hpp> #include <TNL/Containers/Algorithms/ArrayOperationsMIC.hpp>
src/TNL/Containers/Algorithms/ArrayOperationsCuda_impl.h→src/TNL/Containers/Algorithms/ArrayOperationsCuda.hpp +21 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,27 @@ copyMemory( DestinationElement* destination, #endif } template< typename DestinationElement, typename SourceElement > ArrayOperations< Devices::Cuda >:: void copySTLList( DestinationElement* destination, const std::list< SourceElement >& source ) { const auto size = source.size(); const std::streamsize copy_buffer_size = std::min( Devices::Cuda::TransferBufferSize / (std::streamsize) sizeof(SourceType), size ); using BaseType = typename std::remove_cv< SourceType >::type; std::unique_ptr< BaseType[] > copy_buffer{ new BaseType[ copy_buffer_size ] }; size_t copiedElements = 0; auto it = source.begin(); while( copiedElements < size ) { const auto copySize = std::min( size - copiedElements, copy_buffer_size ); for( size_t i = 0; i < copySize; i++ ) copy_buffer[ copiedElements ++ ] = static_cast< DestinationElement >( * it ++ ); ArrayOperations< Devices::Cuda, Devices::Host >::copyMemory( destination, copy_buffer, copySize ); } } template< typename Element1, typename Element2, typename Index > Loading
src/TNL/Containers/Algorithms/ArrayOperationsHost_impl.h→src/TNL/Containers/Algorithms/ArrayOperationsHost.hpp +12 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,18 @@ copyMemory( DestinationElement* destination, destination[ i ] = ( DestinationElement ) source[ i ]; } template< typename DestinationElement, typename SourceElement > ArrayOperations< Devices::Host >:: void copySTLList( DestinationElement* destination, const std::list< SourceElement >& source ) { size_t i = 0; for( SourceElement& e : source ) destination[ i ++ ] = static_cast< DesitnationElement >( e ); } template< typename DestinationElement, typename SourceElement, typename Index > Loading
src/TNL/Containers/Algorithms/ArrayOperationsMIC_impl.h→src/TNL/Containers/Algorithms/ArrayOperationsMIC.hpp +9 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,15 @@ copyMemory( DestinationElement* destination, #endif } template< typename DestinationElement, typename SourceElement > ArrayOperations< Devices::MIC >:: void copySTLList( DestinationElement* destination, const std::list< SourceElement >& source ) { TNL_ASSERT( false, std::cerr << "TODO" ); } template< typename Element1, typename Element2, typename Index > Loading
src/TNL/Containers/Array.h +25 −11 Original line number Diff line number Diff line Loading @@ -80,33 +80,47 @@ class Array : public Object const IndexType& size = 0 ); /** * \brief Initialize the array from initializer list, i.e. { ... } * * @param list * @param list Initializer list. */ Array( const std::initializer_list< Value >& list ); template< typename InValue > Array( const std::initializer_list< InValue >& list ); /** * \brief Initialize the array from std::list. * * @param list * @param list Input STL list. */ Array( const std::list< Value >& list ); template< typename InValue > Array( const std::list< InValue >& list ); /** * \brief Initialize the array from std::vector. * * @param vector * @param vector Input STL vector. */ Array( const std::vector< Value >& vector ); template< typename InValue > Array( const std::vector< InValue >& vector ); /** \brief Returns type of array Value, Device type and the type of Index. */ /** * \brief Returns type of array Value, Device type and the type of Index. */ static String getType(); /** \brief Returns type of array Value, Device type and the type of Index. */ /** * \brief Returns type of array Value, Device type and the type of Index. */ virtual String getTypeVirtual() const; /** \brief Returns (host) type of array Value, Device type and the type of Index. */ /** * \brief Returns (host) type of array Value, Device type and the type of Index. */ static String getSerializationType(); /** \brief Returns (host) type of array Value, Device type and the type of Index. */ /** * \brief Returns (host) type of array Value, Device type and the type of Index. */ virtual String getSerializationTypeVirtual() const; /** Loading Loading @@ -375,4 +389,4 @@ std::ostream& operator << ( std::ostream& str, const Array< Value, Device, Index } // namespace Containers } // namespace TNL #include <TNL/Containers/Array_impl.h> #include <TNL/Containers/Array.hpp>