From 8c10f04fcb83d4644a7272a8ea560dc9833f7bbd Mon Sep 17 00:00:00 2001 From: Tomas Oberhuber <tomas.oberhuber@fjfi.cvut.cz> Date: Wed, 20 Nov 2019 17:02:19 +0100 Subject: [PATCH] Added description of the Algorithms namespace. --- src/TNL/Algorithms/ParallelFor.h | 68 +++++++++++++++++--------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/src/TNL/Algorithms/ParallelFor.h b/src/TNL/Algorithms/ParallelFor.h index 20e6bf7969..b8fec84885 100644 --- a/src/TNL/Algorithms/ParallelFor.h +++ b/src/TNL/Algorithms/ParallelFor.h @@ -31,13 +31,19 @@ */ namespace TNL { -namespace Algorithms { +/** + * \brief Namespace for fundamental TNL algorithms + * + * It contains algorithms like for-loops, memory operations, (parallel) reduction, + * multireduction, scan etc. + */ +namespace Algorithms // TODO: ParallelForMode should be moved to Device (=Executor) /** - * \brief Enum for the parallel processing of the for-loop. - * + * \brief Enum for the parallel processing of the for-loop. + * * Synchronous means that the program control returns to the caller when the loop is processed completely. * Asynchronous means that the program control returns to the caller immediately even before the loop is processing is finished. */ @@ -46,9 +52,9 @@ enum ParallelForMode { SynchronousMode, AsynchronousMode }; /** * \brief Parallel for loop for one dimensional interval of indexes. - * + * * \tparam Device says on what device the for-loop is gonna be executed. - * It can be Devices::Host, Devices::Cuda or Devices::Sequential. + * It can be Devices::Host, Devices::Cuda or Devices::Sequential. * \tparam Mode defines synchronous/asynchronous mode on parallel devices. */ template< typename Device = Devices::Sequential, @@ -57,22 +63,22 @@ struct ParallelFor { /** * \brief Static method for execution of the loop. - * + * * \tparam Index defines the type of indexes over which the loop iterates. * \tparam Function is the type of function to be called in each iteration. - * \tparam FunctionArgs is a variadic type of additional parameters which are + * \tparam FunctionArgs is a variadic type of additional parameters which are * supposed to be passed to the inner Function. - * + * * \param start the for-loop iterates over index interval [start, end). * \param end the for-loop iterates over index interval [start, end). * \param f is the function to be called in each iteration * \param args are additional parameters to be passed to the function f. - * + * * \par Example * \include Algorithms/ParallelForExample.cpp * \par Output * \include ParallelForExample.out - * + * */ template< typename Index, typename Function, @@ -86,9 +92,9 @@ struct ParallelFor /** * \brief Parallel for loop for two dimensional domain of indexes. - * + * * \tparam Device says on what device the for-loop is gonna be executed. - * It can be Devices::Host, Devices::Cuda or Devices::Sequential. + * It can be Devices::Host, Devices::Cuda or Devices::Sequential. * \tparam Mode defines synchronous/asynchronous mode on parallel devices. */ template< typename Device = Devices::Sequential, @@ -97,30 +103,30 @@ struct ParallelFor2D { /** * \brief Static method for execution of the loop. - * + * * \tparam Index defines the type of indexes over which the loop iterates. * \tparam Function is the type of function to be called in each iteration. - * \tparam FunctionArgs is a variadic type of additional parameters which are + * \tparam FunctionArgs is a variadic type of additional parameters which are * supposed to be passed to the inner Function. - * + * * \param startX the for-loop iterates over index domain [startX,endX)x[startY,endY). * \param startY the for-loop iterates over index domain [startX,endX)x[startY,endY). * \param endX the for-loop iterates over index domain [startX,endX)x[startY,endY). * \param endY the for-loop iterates over index domain [startX,endX)x[startY,endY). * \param f is the function to be called in each iteration * \param args are additional parameters to be passed to the function f. - * - * The function f is called for each iteration as - * + * + * The function f is called for each iteration as + * * f( i, j, args... ) - * + * * where the first parameter is changing more often than the second one. * * \par Example * \include Algorithms/ParallelForExample-2D.cpp * \par Output * \include ParallelForExample-2D.out - * + * */ template< typename Index, typename Function, @@ -135,9 +141,9 @@ struct ParallelFor2D /** * \brief Parallel for loop for three dimensional domain of indexes. - * + * * \tparam Device says on what device the for-loop is gonna be executed. - * It can be Devices::Host, Devices::Cuda or Devices::Sequential. + * It can be Devices::Host, Devices::Cuda or Devices::Sequential. * \tparam Mode defines synchronous/asynchronous mode on parallel devices. */ template< typename Device = Devices::Sequential, @@ -146,12 +152,12 @@ struct ParallelFor3D { /** * \brief Static method for execution of the loop. - * + * * \tparam Index defines the type of indexes over which the loop iterates. * \tparam Function is the type of function to be called in each iteration. - * \tparam FunctionArgs is a variadic type of additional parameters which are + * \tparam FunctionArgs is a variadic type of additional parameters which are * supposed to be passed to the inner Function. - * + * * \param startX the for-loop iterates over index domain [startX,endX)x[startY,endY)x[startZ,endZ). * \param startY the for-loop iterates over index domain [startX,endX)x[startY,endY)x[startZ,endZ). * \param startZ the for-loop iterates over index domain [startX,endX)x[startY,endY)x[startZ,endZ). @@ -160,18 +166,18 @@ struct ParallelFor3D * \param endZ the for-loop iterates over index domain [startX,endX)x[startY,endY)x[startZ,endZ). * \param f is the function to be called in each iteration * \param args are additional parameters to be passed to the function f. - * - * The function f is called for each iteration as - * + * + * The function f is called for each iteration as + * * f( i, j, k, args... ) - * + * * where the first parameter is changing the most often. - * + * * \par Example * \include Algorithms/ParallelForExample-3D.cpp * \par Output * \include ParallelForExample-3D.out - * + * */ template< typename Index, typename Function, -- GitLab