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

Replacing Array[,View]::evaluate with Array[,View]::[forElements,forEachElement].

parent 32ffa20e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ int main( int argc, char* argv[] )
    */
   Vector< double, Devices::Host > host_v1( 10 ), host_v2( 10 ), host_result( 10 );
   host_v1 = 1.0;
   host_v2.evaluate( []__cuda_callable__ ( int i )->double { return i; } );
   host_v2.forEachElement( []__cuda_callable__ ( int i, double& v ) { v = i; } );
   vectorSum( host_v1, host_v2, 2.0, host_result );
   std::cout << "host_v1 = " << host_v1 << std::endl;
   std::cout << "host_v2 = " << host_v2 << std::endl;
@@ -48,7 +48,7 @@ int main( int argc, char* argv[] )
#ifdef HAVE_CUDA
   Vector< double, Devices::Cuda > cuda_v1( 10 ), cuda_v2( 10 ), cuda_result( 10 );
   cuda_v1 = 1.0;
   cuda_v2.evaluate( []__cuda_callable__ ( int i )->double { return i; } );
   cuda_v2.forEachElement( []__cuda_callable__ ( int i, double& v ) { v = i; } );
   vectorSum( cuda_v1, cuda_v2, 2.0, cuda_result );
   std::cout << "cuda_v1 = " << cuda_v1 << std::endl;
   std::cout << "cuda_v2 = " << cuda_v2 << std::endl;
+2 −2
Original line number Diff line number Diff line
@@ -44,8 +44,8 @@ void arrayViewExample()
    */
   ArrayType a3( size );
   ViewType a3_view = a3.getView();
   auto f1 = [] __cuda_callable__ ( IndexType i ) -> int { return 2 * i; };
   a3_view.evaluate( f1 );
   auto f1 = [] __cuda_callable__ ( IndexType i, int& value ) { value = 2 * i; };
   a3_view.forEachElement( f1 );

   for( int i = 0; i < size; i++ )
      if( a3_view.getElement( i ) != 2 * i )
+0 −1
Original line number Diff line number Diff line
ArrayViewEvaluate.cpp
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
@@ -18,12 +18,12 @@ int main( int argc, char* argv[] )
    * Create an ArrayView and use it for initiation
    */
   auto a_view = a.getView();
   a_view.evaluate( [] __cuda_callable__ ( int i ) -> float { return i; } );
   a_view.forEachElement( [] __cuda_callable__ ( int i, float& value ) { value = i; } );

   /****
    * Initiate elements of b with indexes 0-4 using a_view
    */
   b.getView().evaluate( [=] __cuda_callable__ ( int i ) -> float { return a_view[ i ] + 4.0; }, 0, 5 );
   b.getView().forElements( 0, 5, [=] __cuda_callable__ ( int i, float& value ) { value = a_view[ i ] + 4.0; } );

   /****
    * Print the results
+1 −0
Original line number Diff line number Diff line
ArrayViewForElements.cpp
 No newline at end of file
Loading