Commit 76a95d0b authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Implemented 'outplace' variants of scan and distributed scan functions

parent 4f1dc3af
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@ set( COMMON_EXAMPLES
     MapReduceExample-3
     ReductionWithArgument
     ReductionWithArgumentWithFunctional
     inclusiveScanExample
     exclusiveScanExample
     inplaceInclusiveScanExample
     inplaceExclusiveScanExample
     SegmentedScanExample
+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;
}
+1 −0
Original line number Diff line number Diff line
exclusiveScanExample.cpp
 No newline at end of file
+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;
}
+1 −0
Original line number Diff line number Diff line
inclusiveScanExample.cpp
 No newline at end of file
Loading