Commit fe182333 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Writting documentation - general concepts.

parent 75a8f3e3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
add_subdirectory( GeneralConcepts )
add_subdirectory( Arrays )
add_subdirectory( Vectors )
add_subdirectory( ReductionAndScan )
+0 −15
Original line number Diff line number Diff line
\page tutorial_CoreConcepts Core concepts

## Introduction




## Table of Contents
1. [Devices and allocators](#devices_and_allocators)
2. [Algorithms and lambda functions](#algorithms_and_lambda_functions)
3. [Smart pointers and views](#static_for)


## Devices and allocators<a name="devices_and_allocators"></a>
+8 −0
Original line number Diff line number Diff line
template< typename Device >
void vectorAddition( double* v1, double* v2, double* sum, const int size )
{
    auto sum_lambda = [=] __cuda_callable__ ( int i ) mutable {
        sum[ i ] = v1[ i ] + v2[ i ];
    }
    TNL::Algorithms::ParalellFor< Device >::exec( 0, size, sum_lambda );
}
 No newline at end of file
+10 −0
Original line number Diff line number Diff line
template< typename Device >
void scalarProduct( double* v1, double* v2, double* product, const int size )
{
    auto fetch = [=] __cuda_callable__ ( int i ) -> double {
        return = v1[ i ] * v2[ i ];
    }
    auto reduce = [] __cuda_callable__ ( const double& a, const double& b ) {
        return a + b; };
    TNL::Algorithms::Reduction< Device >::reduce( 0, size, reduce, fetch, 0.0 );
}
 No newline at end of file
+12 −0
Original line number Diff line number Diff line
template< typename Device >
void scalarProduct( double* u1, double* u2,
                    double* v1, double* v2,
                    double* product, const int size )
{
    auto fetch = [=] __cuda_callable__ ( int i ) -> double {
        return = ( u1[ i ] + u2[ i ] ) * ( v1[ i ] + v2[ i ] );
    }
    auto reduce = [] __cuda_callable__ ( const double& a, const double& b ) {
        return a + b; };
    TNL::Algorithms::Reduction< Device >::reduce( 0, size, reduce, fetch, 0.0 );
}
 No newline at end of file
Loading