Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
6eb47984
There was an error fetching the commit references. Please try again later.
Commit
6eb47984
authored
5 years ago
by
Tomáš Oberhuber
Browse files
Options
Downloads
Patches
Plain Diff
Writing documentation for StaticFor.
parent
06a9d8bd
No related branches found
No related tags found
1 merge request
!44
Tutorials
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/TNL/Algorithms/StaticFor.h
+28
-4
28 additions, 4 deletions
src/TNL/Algorithms/StaticFor.h
with
28 additions
and
4 deletions
src/TNL/Algorithms/StaticFor.h
+
28
−
4
View file @
6eb47984
...
...
@@ -15,10 +15,28 @@
namespace
TNL
{
namespace
Algorithms
{
// Manual unrolling does not make sense for loops with a large iterations
// count. For a very large iterations count it would trigger the compiler's
// limit on recursive template instantiation. Also note that the compiler
// will (at least partially) unroll loops with static bounds anyway.
/***
* \brief StaticFor is a wrapper for common for-loop with explicit unrolling.
*
* StaticFor can be used only for for-loops bounds of which are known at the
* compile time. StaticFor performs explicit loop unrolling for better performance.
* This, however, does not make sense for loops with a large iterations
* count. For a very large iterations count it could trigger the compiler's
* limit on recursive template instantiation. Also note that the compiler
* will (at least partially) unroll loops with static bounds anyway. For theses
* reasons, the explicit loop unrolling can be controlled by the third template
* parameter.
*
* \tparam Begin the loop will iterate over indexes [Begin,End)
* \tparam End the loop will iterate over indexes [Begin,End)
* \tparam unrolled controls the explicit loop unrolling. If it is true, the
* unrolling is performed.
*
* \par Example
* \include Algorithms/StaticForExample.cpp
* \par Output
* \include StaticForExample.out
*/
template
<
int
Begin
,
int
End
,
bool
unrolled
=
(
End
-
Begin
<=
8
)
>
struct
StaticFor
;
...
...
@@ -27,6 +45,12 @@ struct StaticFor< Begin, End, true >
{
static_assert
(
Begin
<
End
,
"Wrong index interval for StaticFor. Begin must be less than end."
);
/**
* \brief Static method for execution od the StaticFor.
*
* @param f is a (lambda) function to be performed in each iteration.
* @param args are auxiliary data to be passed to the function f.
*/
template
<
typename
Function
,
typename
...
Args
>
__cuda_callable__
static
void
exec
(
const
Function
&
f
,
Args
&&
...
args
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment