Loading Documentation/Examples/Algorithms/ParallelForExample-2D.cpp +6 −6 Original line number Diff line number Diff line #include <iostream> #include <cstdlib> #include <TNL/Containers/Vector.h> #include <TNL/Algorithms/ParallelFor.h> Loading @@ -13,10 +12,12 @@ void initMeshFunction( const int xSize, Vector< double, Device >& v, const double& c ) { auto view = v1.getConstView(); auto init = [=] __cuda_callable__ ( int i, int j, const int xSize, const double c ) mutable { view[ j * xSize + i ] = c; }; ParallelFor2D< Device >::exec( 0, 0, xSize, ySize, init, xSize, c ); auto view = v.getView(); auto init = [=] __cuda_callable__ ( int i, int j ) mutable { view[ j * xSize + i ] = c; }; ParallelFor2D< Device >::exec( 0, 0, xSize, ySize, init ); } int main( int argc, char* argv[] ) Loading @@ -42,4 +43,3 @@ int main( int argc, char* argv[] ) #endif return EXIT_SUCCESS; } Documentation/Examples/Algorithms/ParallelForExample-3D.cpp +7 −7 Original line number Diff line number Diff line #include <iostream> #include <cstdlib> #include <TNL/Containers/Vector.h> #include <TNL/Algorithms/ParallelFor.h> Loading @@ -14,16 +13,18 @@ void initMeshFunction( const int xSize, Vector< double, Device >& v, const double& c ) { auto view = v1.getConstView(); auto init = [=] __cuda_callable__ ( int i, int j, int k, const int xSize, const int ySize, const double c ) mutable { view[ ( k * ySize + j ) * xSize + i ] = c; }; ParallelFor3D< Device >::exec( 0, 0, xSize, ySize, init, xSize, ySize, c ); auto view = v.getView(); auto init = [=] __cuda_callable__ ( int i, int j, int k ) mutable { view[ ( k * ySize + j ) * xSize + i ] = c; }; ParallelFor3D< Device >::exec( 0, 0, 0, xSize, ySize, zSize, init ); } int main( int argc, char* argv[] ) { /*** * Define dimensions of 2D mesh function. * Define dimensions of a 3D mesh function. */ const int xSize( 10 ), ySize( 10 ), zSize( 10 ); const int size = xSize * ySize * zSize; Loading @@ -43,4 +44,3 @@ int main( int argc, char* argv[] ) #endif return EXIT_SUCCESS; } Documentation/Examples/Algorithms/ParallelForExample.cpp +6 −6 Original line number Diff line number Diff line #include <iostream> #include <cstdlib> #include <TNL/Containers/Vector.h> #include <TNL/Algorithms/ParallelFor.h> using namespace TNL; using namespace TNL::Containers; using namespace TNL::Algorithms; /**** * Set all elements of the vector v to the constant c. Loading @@ -14,10 +14,11 @@ void initVector( Vector< double, Device >& v, const double& c ) { auto view = v.getView(); auto init = [=] __cuda_callable__ ( int i, const double c ) mutable { view[ i ] = c; }; Algorithms::ParallelFor< Device >::exec( 0, v.getSize(), init, c ); auto init = [=] __cuda_callable__ ( int i ) mutable { view[ i ] = c; }; ParallelFor< Device >::exec( 0, v.getSize(), init ); } int main( int argc, char* argv[] ) Loading @@ -39,4 +40,3 @@ int main( int argc, char* argv[] ) #endif return EXIT_SUCCESS; } Documentation/Tutorials/ForLoops/CMakeLists.txt +3 −15 Original line number Diff line number Diff line IF( BUILD_CUDA ) CUDA_ADD_EXECUTABLE( ParallelForExample ParallelForExample.cu ) ADD_CUSTOM_COMMAND( COMMAND ParallelForExample > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/ParallelForExample.out OUTPUT ParallelForExample.out ) CUDA_ADD_EXECUTABLE( ParallelForExample-2D ParallelForExample-2D.cu ) CUDA_ADD_EXECUTABLE( ParallelForExample-3D ParallelForExample-3D.cu ) ELSE() ADD_EXECUTABLE( ParallelForExample-2D ParallelForExample-2D_ug.cpp ) ADD_EXECUTABLE( ParallelForExample-3D ParallelForExample-3D_ug.cpp ) ENDIF() ADD_EXECUTABLE( StaticForExample StaticForExample_ug.cpp ) ADD_CUSTOM_COMMAND( COMMAND StaticForExample > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/StaticForExample.out OUTPUT StaticForExample.out ) ADD_EXECUTABLE( TemplateStaticForExample TemplateStaticForExample_ug.cpp ) ADD_CUSTOM_COMMAND( COMMAND TemplateStaticForExample > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/TemplateStaticForExample.out OUTPUT TemplateStaticForExample.out ) IF( BUILD_CUDA ) ADD_CUSTOM_TARGET( ForLoops-cuda ALL DEPENDS ParallelForExample.out ADD_CUSTOM_TARGET( ForLoops ALL DEPENDS StaticForExample.out TemplateStaticForExample.out ) ENDIF() TemplateStaticForExample.out ) Documentation/Tutorials/ForLoops/ParallelForExample-2D.cudeleted 120000 → 0 +0 −1 Original line number Diff line number Diff line ParallelForExample-2D_ug.cpp No newline at end of file Loading
Documentation/Examples/Algorithms/ParallelForExample-2D.cpp +6 −6 Original line number Diff line number Diff line #include <iostream> #include <cstdlib> #include <TNL/Containers/Vector.h> #include <TNL/Algorithms/ParallelFor.h> Loading @@ -13,10 +12,12 @@ void initMeshFunction( const int xSize, Vector< double, Device >& v, const double& c ) { auto view = v1.getConstView(); auto init = [=] __cuda_callable__ ( int i, int j, const int xSize, const double c ) mutable { view[ j * xSize + i ] = c; }; ParallelFor2D< Device >::exec( 0, 0, xSize, ySize, init, xSize, c ); auto view = v.getView(); auto init = [=] __cuda_callable__ ( int i, int j ) mutable { view[ j * xSize + i ] = c; }; ParallelFor2D< Device >::exec( 0, 0, xSize, ySize, init ); } int main( int argc, char* argv[] ) Loading @@ -42,4 +43,3 @@ int main( int argc, char* argv[] ) #endif return EXIT_SUCCESS; }
Documentation/Examples/Algorithms/ParallelForExample-3D.cpp +7 −7 Original line number Diff line number Diff line #include <iostream> #include <cstdlib> #include <TNL/Containers/Vector.h> #include <TNL/Algorithms/ParallelFor.h> Loading @@ -14,16 +13,18 @@ void initMeshFunction( const int xSize, Vector< double, Device >& v, const double& c ) { auto view = v1.getConstView(); auto init = [=] __cuda_callable__ ( int i, int j, int k, const int xSize, const int ySize, const double c ) mutable { view[ ( k * ySize + j ) * xSize + i ] = c; }; ParallelFor3D< Device >::exec( 0, 0, xSize, ySize, init, xSize, ySize, c ); auto view = v.getView(); auto init = [=] __cuda_callable__ ( int i, int j, int k ) mutable { view[ ( k * ySize + j ) * xSize + i ] = c; }; ParallelFor3D< Device >::exec( 0, 0, 0, xSize, ySize, zSize, init ); } int main( int argc, char* argv[] ) { /*** * Define dimensions of 2D mesh function. * Define dimensions of a 3D mesh function. */ const int xSize( 10 ), ySize( 10 ), zSize( 10 ); const int size = xSize * ySize * zSize; Loading @@ -43,4 +44,3 @@ int main( int argc, char* argv[] ) #endif return EXIT_SUCCESS; }
Documentation/Examples/Algorithms/ParallelForExample.cpp +6 −6 Original line number Diff line number Diff line #include <iostream> #include <cstdlib> #include <TNL/Containers/Vector.h> #include <TNL/Algorithms/ParallelFor.h> using namespace TNL; using namespace TNL::Containers; using namespace TNL::Algorithms; /**** * Set all elements of the vector v to the constant c. Loading @@ -14,10 +14,11 @@ void initVector( Vector< double, Device >& v, const double& c ) { auto view = v.getView(); auto init = [=] __cuda_callable__ ( int i, const double c ) mutable { view[ i ] = c; }; Algorithms::ParallelFor< Device >::exec( 0, v.getSize(), init, c ); auto init = [=] __cuda_callable__ ( int i ) mutable { view[ i ] = c; }; ParallelFor< Device >::exec( 0, v.getSize(), init ); } int main( int argc, char* argv[] ) Loading @@ -39,4 +40,3 @@ int main( int argc, char* argv[] ) #endif return EXIT_SUCCESS; }
Documentation/Tutorials/ForLoops/CMakeLists.txt +3 −15 Original line number Diff line number Diff line IF( BUILD_CUDA ) CUDA_ADD_EXECUTABLE( ParallelForExample ParallelForExample.cu ) ADD_CUSTOM_COMMAND( COMMAND ParallelForExample > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/ParallelForExample.out OUTPUT ParallelForExample.out ) CUDA_ADD_EXECUTABLE( ParallelForExample-2D ParallelForExample-2D.cu ) CUDA_ADD_EXECUTABLE( ParallelForExample-3D ParallelForExample-3D.cu ) ELSE() ADD_EXECUTABLE( ParallelForExample-2D ParallelForExample-2D_ug.cpp ) ADD_EXECUTABLE( ParallelForExample-3D ParallelForExample-3D_ug.cpp ) ENDIF() ADD_EXECUTABLE( StaticForExample StaticForExample_ug.cpp ) ADD_CUSTOM_COMMAND( COMMAND StaticForExample > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/StaticForExample.out OUTPUT StaticForExample.out ) ADD_EXECUTABLE( TemplateStaticForExample TemplateStaticForExample_ug.cpp ) ADD_CUSTOM_COMMAND( COMMAND TemplateStaticForExample > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/TemplateStaticForExample.out OUTPUT TemplateStaticForExample.out ) IF( BUILD_CUDA ) ADD_CUSTOM_TARGET( ForLoops-cuda ALL DEPENDS ParallelForExample.out ADD_CUSTOM_TARGET( ForLoops ALL DEPENDS StaticForExample.out TemplateStaticForExample.out ) ENDIF() TemplateStaticForExample.out )
Documentation/Tutorials/ForLoops/ParallelForExample-2D.cudeleted 120000 → 0 +0 −1 Original line number Diff line number Diff line ParallelForExample-2D_ug.cpp No newline at end of file