Commit 1765a6b2 authored by Jakub Klinkovský's avatar Jakub Klinkovský

Cleaned up examples in reduction tutorials

parent 78d15fb0
#include <iostream>
#include <cstdlib>
#include <TNL/Containers/Vector.h>
#include <TNL/Containers/Array.h>
#include <TNL/Containers/Algorithms/Reduction.h>
#include <TNL/Containers/StaticVector.h>
using namespace TNL;
using namespace TNL::Containers;
......
......@@ -2,7 +2,6 @@
#include <cstdlib>
#include <TNL/Containers/Vector.h>
#include <TNL/Containers/Algorithms/Reduction.h>
#include <TNL/Timer.h>
using namespace TNL;
using namespace TNL::Containers;
......@@ -20,7 +19,6 @@ double mapReduce( Vector< double, Device >& u )
int main( int argc, char* argv[] )
{
Timer timer;
Vector< double, Devices::Host > host_u( 10 );
host_u.evaluate( [] __cuda_callable__ ( int i ) { return sin( ( double ) i ); } );
double result = mapReduce( host_u );
......
#include <iostream>
#include <cstdlib>
#include <TNL/Containers/Vector.h>
#include <TNL/Containers/Array.h>
#include <TNL/Containers/Algorithms/Reduction.h>
#include <TNL/Containers/StaticVector.h>
using namespace TNL;
using namespace TNL::Containers;
......
#include <iostream>
#include <cstdlib>
#include <TNL/Containers/Vector.h>
#include <TNL/Containers/Array.h>
#include <TNL/Containers/Algorithms/Reduction.h>
#include <TNL/Containers/StaticVector.h>
using namespace TNL;
using namespace TNL::Containers;
......
double sequentialSum( const double* a, const int size )
{
auto fetch = [=] (int i)->double { return a[ i ]; };
auto reduce = [] (double& x, const double& y) { x += y; };
auto reduce = [] (double& x, const double& y) { return x + y; };
double sum( 0.0 );
for( int i = 0; i < size; i++ )
reduce( sum, fetch( i ) );
sum = reduce( sum, fetch( i ) );
return sum;
}
#include <iostream>
#include <cstdlib>
#include <TNL/Containers/Vector.h>
#include <TNL/Containers/Array.h>
#include <TNL/Containers/Algorithms/Reduction.h>
#include <TNL/Containers/StaticVector.h>
using namespace TNL;
using namespace TNL::Containers;
using namespace TNL::Containers::Algorithms;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment