Loading Documentation/Examples/Containers/ArrayExample_reduceElements.cpp→Documentation/Examples/Algorithms/reduceArrayExample.cpp +0 −0 File moved. View file Documentation/Examples/Containers/ArrayExample_reduceElements.cu→Documentation/Examples/Algorithms/reduceArrayExample.cu +0 −0 File moved. View file Documentation/Examples/Containers/ArrayViewExample_reduceElements.cppdeleted 100644 → 0 +0 −45 Original line number Diff line number Diff line #include <iostream> #include <functional> #include <TNL/Containers/Array.h> #include <TNL/Containers/ArrayView.h> using namespace TNL; template< typename Device > void reduceElementsExample() { /**** * Create new arrays */ const int size = 10; Containers::Array< float, Device > a( size ); auto a_view = a.getView(); /**** * Initiate the elements of array `a` */ a_view.forAllElements( [] __cuda_callable__ ( int i, float& value ) { value = i; } ); /**** * Sum all elements of array `a` */ auto fetch = [=] __cuda_callable__ ( int i, float& value ) { return value; }; auto sum = a_view.reduceEachElement( fetch, std::plus<>{}, 0.0 ); /**** * Print the results */ std::cout << " a = " << a << std::endl; std::cout << " sum = " << sum << std::endl; } int main( int argc, char* argv[] ) { std::cout << "Running example on the host system: " << std::endl; reduceElementsExample< Devices::Host >(); #ifdef HAVE_CUDA std::cout << "Running example on the CUDA device: " << std::endl; reduceElementsExample< Devices::Cuda >(); #endif } Documentation/Examples/Containers/ArrayViewExample_reduceElements.cudeleted 120000 → 0 +0 −1 Original line number Diff line number Diff line ArrayViewExample_reduceElements.cpp No newline at end of file src/TNL/Containers/Expressions/DistributedExpressionTemplates.h +4 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ template< typename T1, struct DistributedBinaryExpressionTemplate< T1, T2, Operation, VectorExpressionVariable, VectorExpressionVariable > { using RealType = decltype( Operation::evaluate( std::declval<T1>()[0], std::declval<T2>()[0] ) ); using ValueType = RealType; using DeviceType = typename T1::DeviceType; using IndexType = typename T1::IndexType; using LocalRangeType = typename T1::LocalRangeType; Loading Loading @@ -155,6 +156,7 @@ template< typename T1, struct DistributedBinaryExpressionTemplate< T1, T2, Operation, VectorExpressionVariable, ArithmeticVariable > { using RealType = decltype( Operation::evaluate( std::declval<T1>()[0], std::declval<T2>() ) ); using ValueType = RealType; using DeviceType = typename T1::DeviceType; using IndexType = typename T1::IndexType; using LocalRangeType = typename T1::LocalRangeType; Loading Loading @@ -236,6 +238,7 @@ template< typename T1, struct DistributedBinaryExpressionTemplate< T1, T2, Operation, ArithmeticVariable, VectorExpressionVariable > { using RealType = decltype( Operation::evaluate( std::declval<T1>(), std::declval<T2>()[0] ) ); using ValueType = RealType; using DeviceType = typename T2::DeviceType; using IndexType = typename T2::IndexType; using LocalRangeType = typename T2::LocalRangeType; Loading Loading @@ -318,6 +321,7 @@ template< typename T1, struct DistributedUnaryExpressionTemplate { using RealType = decltype( Operation::evaluate( std::declval<T1>()[0] ) ); using ValueType = RealType; using DeviceType = typename T1::DeviceType; using IndexType = typename T1::IndexType; using LocalRangeType = typename T1::LocalRangeType; Loading Loading
Documentation/Examples/Containers/ArrayExample_reduceElements.cpp→Documentation/Examples/Algorithms/reduceArrayExample.cpp +0 −0 File moved. View file
Documentation/Examples/Containers/ArrayExample_reduceElements.cu→Documentation/Examples/Algorithms/reduceArrayExample.cu +0 −0 File moved. View file
Documentation/Examples/Containers/ArrayViewExample_reduceElements.cppdeleted 100644 → 0 +0 −45 Original line number Diff line number Diff line #include <iostream> #include <functional> #include <TNL/Containers/Array.h> #include <TNL/Containers/ArrayView.h> using namespace TNL; template< typename Device > void reduceElementsExample() { /**** * Create new arrays */ const int size = 10; Containers::Array< float, Device > a( size ); auto a_view = a.getView(); /**** * Initiate the elements of array `a` */ a_view.forAllElements( [] __cuda_callable__ ( int i, float& value ) { value = i; } ); /**** * Sum all elements of array `a` */ auto fetch = [=] __cuda_callable__ ( int i, float& value ) { return value; }; auto sum = a_view.reduceEachElement( fetch, std::plus<>{}, 0.0 ); /**** * Print the results */ std::cout << " a = " << a << std::endl; std::cout << " sum = " << sum << std::endl; } int main( int argc, char* argv[] ) { std::cout << "Running example on the host system: " << std::endl; reduceElementsExample< Devices::Host >(); #ifdef HAVE_CUDA std::cout << "Running example on the CUDA device: " << std::endl; reduceElementsExample< Devices::Cuda >(); #endif }
Documentation/Examples/Containers/ArrayViewExample_reduceElements.cudeleted 120000 → 0 +0 −1 Original line number Diff line number Diff line ArrayViewExample_reduceElements.cpp No newline at end of file
src/TNL/Containers/Expressions/DistributedExpressionTemplates.h +4 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ template< typename T1, struct DistributedBinaryExpressionTemplate< T1, T2, Operation, VectorExpressionVariable, VectorExpressionVariable > { using RealType = decltype( Operation::evaluate( std::declval<T1>()[0], std::declval<T2>()[0] ) ); using ValueType = RealType; using DeviceType = typename T1::DeviceType; using IndexType = typename T1::IndexType; using LocalRangeType = typename T1::LocalRangeType; Loading Loading @@ -155,6 +156,7 @@ template< typename T1, struct DistributedBinaryExpressionTemplate< T1, T2, Operation, VectorExpressionVariable, ArithmeticVariable > { using RealType = decltype( Operation::evaluate( std::declval<T1>()[0], std::declval<T2>() ) ); using ValueType = RealType; using DeviceType = typename T1::DeviceType; using IndexType = typename T1::IndexType; using LocalRangeType = typename T1::LocalRangeType; Loading Loading @@ -236,6 +238,7 @@ template< typename T1, struct DistributedBinaryExpressionTemplate< T1, T2, Operation, ArithmeticVariable, VectorExpressionVariable > { using RealType = decltype( Operation::evaluate( std::declval<T1>(), std::declval<T2>()[0] ) ); using ValueType = RealType; using DeviceType = typename T2::DeviceType; using IndexType = typename T2::IndexType; using LocalRangeType = typename T2::LocalRangeType; Loading Loading @@ -318,6 +321,7 @@ template< typename T1, struct DistributedUnaryExpressionTemplate { using RealType = decltype( Operation::evaluate( std::declval<T1>()[0] ) ); using ValueType = RealType; using DeviceType = typename T1::DeviceType; using IndexType = typename T1::IndexType; using LocalRangeType = typename T1::LocalRangeType; Loading