Loading Documentation/Tutorials/ReductionAndScan/CMakeLists.txt +2 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,8 @@ set( COMMON_EXAMPLES MapReduceExample-3 ReductionWithArgument ReductionWithArgumentWithFunctional inclusiveScanExample exclusiveScanExample inplaceInclusiveScanExample inplaceExclusiveScanExample SegmentedScanExample Loading Documentation/Tutorials/ReductionAndScan/exclusiveScanExample.cpp 0 → 100644 +31 −0 Original line number Diff line number Diff line #include <iostream> #include <TNL/Containers/Array.h> #include <TNL/Algorithms/scan.h> using namespace TNL; using namespace TNL::Containers; using namespace TNL::Algorithms; int main( int argc, char* argv[] ) { /*** * Firstly, test the prefix sum with an array allocated on CPU. */ Array< double, Devices::Host > host_input( 10 ), host_output( 10 ); host_input = 1.0; std::cout << "host_input = " << host_input << std::endl; exclusiveScan( host_input, host_output ); std::cout << "host_output " << host_output << std::endl; /*** * And then also on GPU. */ #ifdef HAVE_CUDA Array< double, Devices::Cuda > cuda_input( 10 ), cuda_output( 10 ); cuda_input = 1.0; std::cout << "cuda_input = " << cuda_input << std::endl; exclusiveScan( cuda_input, cuda_output ); std::cout << "cuda_output " << cuda_output << std::endl; #endif return EXIT_SUCCESS; } Documentation/Tutorials/ReductionAndScan/exclusiveScanExample.cu 0 → 120000 +1 −0 Original line number Diff line number Diff line exclusiveScanExample.cpp No newline at end of file Documentation/Tutorials/ReductionAndScan/inclusiveScanExample.cpp 0 → 100644 +31 −0 Original line number Diff line number Diff line #include <iostream> #include <TNL/Containers/Array.h> #include <TNL/Algorithms/scan.h> using namespace TNL; using namespace TNL::Containers; using namespace TNL::Algorithms; int main( int argc, char* argv[] ) { /*** * Firstly, test the prefix sum with an array allocated on CPU. */ Array< double, Devices::Host > host_input( 10 ), host_output( 10 ); host_input = 1.0; std::cout << "host_input = " << host_input << std::endl; inclusiveScan( host_input, host_output ); std::cout << "host_output " << host_output << std::endl; /*** * And then also on GPU. */ #ifdef HAVE_CUDA Array< double, Devices::Cuda > cuda_input( 10 ), cuda_output( 10 ); cuda_input = 1.0; std::cout << "cuda_input = " << cuda_input << std::endl; inclusiveScan( cuda_input, cuda_output ); std::cout << "cuda_output " << cuda_output << std::endl; #endif return EXIT_SUCCESS; } Documentation/Tutorials/ReductionAndScan/inclusiveScanExample.cu 0 → 120000 +1 −0 Original line number Diff line number Diff line inclusiveScanExample.cpp No newline at end of file Loading
Documentation/Tutorials/ReductionAndScan/CMakeLists.txt +2 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,8 @@ set( COMMON_EXAMPLES MapReduceExample-3 ReductionWithArgument ReductionWithArgumentWithFunctional inclusiveScanExample exclusiveScanExample inplaceInclusiveScanExample inplaceExclusiveScanExample SegmentedScanExample Loading
Documentation/Tutorials/ReductionAndScan/exclusiveScanExample.cpp 0 → 100644 +31 −0 Original line number Diff line number Diff line #include <iostream> #include <TNL/Containers/Array.h> #include <TNL/Algorithms/scan.h> using namespace TNL; using namespace TNL::Containers; using namespace TNL::Algorithms; int main( int argc, char* argv[] ) { /*** * Firstly, test the prefix sum with an array allocated on CPU. */ Array< double, Devices::Host > host_input( 10 ), host_output( 10 ); host_input = 1.0; std::cout << "host_input = " << host_input << std::endl; exclusiveScan( host_input, host_output ); std::cout << "host_output " << host_output << std::endl; /*** * And then also on GPU. */ #ifdef HAVE_CUDA Array< double, Devices::Cuda > cuda_input( 10 ), cuda_output( 10 ); cuda_input = 1.0; std::cout << "cuda_input = " << cuda_input << std::endl; exclusiveScan( cuda_input, cuda_output ); std::cout << "cuda_output " << cuda_output << std::endl; #endif return EXIT_SUCCESS; }
Documentation/Tutorials/ReductionAndScan/exclusiveScanExample.cu 0 → 120000 +1 −0 Original line number Diff line number Diff line exclusiveScanExample.cpp No newline at end of file
Documentation/Tutorials/ReductionAndScan/inclusiveScanExample.cpp 0 → 100644 +31 −0 Original line number Diff line number Diff line #include <iostream> #include <TNL/Containers/Array.h> #include <TNL/Algorithms/scan.h> using namespace TNL; using namespace TNL::Containers; using namespace TNL::Algorithms; int main( int argc, char* argv[] ) { /*** * Firstly, test the prefix sum with an array allocated on CPU. */ Array< double, Devices::Host > host_input( 10 ), host_output( 10 ); host_input = 1.0; std::cout << "host_input = " << host_input << std::endl; inclusiveScan( host_input, host_output ); std::cout << "host_output " << host_output << std::endl; /*** * And then also on GPU. */ #ifdef HAVE_CUDA Array< double, Devices::Cuda > cuda_input( 10 ), cuda_output( 10 ); cuda_input = 1.0; std::cout << "cuda_input = " << cuda_input << std::endl; inclusiveScan( cuda_input, cuda_output ); std::cout << "cuda_output " << cuda_output << std::endl; #endif return EXIT_SUCCESS; }
Documentation/Tutorials/ReductionAndScan/inclusiveScanExample.cu 0 → 120000 +1 −0 Original line number Diff line number Diff line inclusiveScanExample.cpp No newline at end of file