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
2e26d884
There was an error fetching the commit references. Please try again later.
Commit
2e26d884
authored
6 years ago
by
Tomáš Oberhuber
Committed by
Tomáš Oberhuber
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Optimization of ParallelFor on CPU.
parent
075740ec
No related branches found
No related tags found
1 merge request
!20
Traversers optimizations
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/TNL/ParallelFor.h
+50
-11
50 additions, 11 deletions
src/TNL/ParallelFor.h
with
50 additions
and
11 deletions
src/TNL/ParallelFor.h
+
50
−
11
View file @
2e26d884
...
...
@@ -37,10 +37,21 @@ struct ParallelFor
static
void
exec
(
Index
start
,
Index
end
,
Function
f
,
FunctionArgs
...
args
)
{
#ifdef HAVE_OPENMP
#pragma omp parallel for if( TNL::Devices::Host::isOMPEnabled() && end - start > 512 )
#endif
// Benchmarks show that this is significantly faster compared
// to '#pragma omp parallel for if( TNL::Devices::Host::isOMPEnabled() && end - start > 512 )'
if
(
TNL
::
Devices
::
Host
::
isOMPEnabled
()
&&
end
-
start
>
512
)
{
#pragma omp parallel for
for
(
Index
i
=
start
;
i
<
end
;
i
++
)
f
(
i
,
args
...
);
}
else
for
(
Index
i
=
start
;
i
<
end
;
i
++
)
f
(
i
,
args
...
);
#else
for
(
Index
i
=
start
;
i
<
end
;
i
++
)
f
(
i
,
args
...
);
#endif
}
};
...
...
@@ -53,11 +64,24 @@ struct ParallelFor2D
static
void
exec
(
Index
startX
,
Index
startY
,
Index
endX
,
Index
endY
,
Function
f
,
FunctionArgs
...
args
)
{
#ifdef HAVE_OPENMP
#pragma omp parallel for if( TNL::Devices::Host::isOMPEnabled() )
#endif
// Benchmarks show that this is significantly faster compared
// to '#pragma omp parallel for if( TNL::Devices::Host::isOMPEnabled() )'
if
(
TNL
::
Devices
::
Host
::
isOMPEnabled
()
)
{
#pragma omp parallel for
for
(
Index
i
=
startX
;
i
<
endX
;
i
++
)
for
(
Index
j
=
startY
;
j
<
endY
;
j
++
)
f
(
i
,
j
,
args
...
);
}
else
for
(
Index
i
=
startX
;
i
<
endX
;
i
++
)
for
(
Index
j
=
startY
;
j
<
endY
;
j
++
)
f
(
i
,
j
,
args
...
);
#else
for
(
Index
i
=
startX
;
i
<
endX
;
i
++
)
for
(
Index
j
=
startY
;
j
<
endY
;
j
++
)
f
(
i
,
j
,
args
...
);
for
(
Index
j
=
startY
;
j
<
endY
;
j
++
)
f
(
i
,
j
,
args
...
);
#endif
}
};
...
...
@@ -70,12 +94,27 @@ struct ParallelFor3D
static
void
exec
(
Index
startX
,
Index
startY
,
Index
startZ
,
Index
endX
,
Index
endY
,
Index
endZ
,
Function
f
,
FunctionArgs
...
args
)
{
#ifdef HAVE_OPENMP
#pragma omp parallel for collapse(2) if( TNL::Devices::Host::isOMPEnabled() )
#endif
// Benchmarks show that this is significantly faster compared
// to '#pragma omp parallel for if( TNL::Devices::Host::isOMPEnabled() )'
if
(
TNL
::
Devices
::
Host
::
isOMPEnabled
()
)
{
#pragma omp parallel for collapse(2)
for
(
Index
i
=
startX
;
i
<
endX
;
i
++
)
for
(
Index
j
=
startY
;
j
<
endY
;
j
++
)
for
(
Index
k
=
startZ
;
k
<
endZ
;
k
++
)
f
(
i
,
j
,
k
,
args
...
);
for
(
Index
j
=
startY
;
j
<
endY
;
j
++
)
for
(
Index
k
=
startZ
;
k
<
endZ
;
k
++
)
f
(
i
,
j
,
k
,
args
...
);
}
else
for
(
Index
i
=
startX
;
i
<
endX
;
i
++
)
for
(
Index
j
=
startY
;
j
<
endY
;
j
++
)
for
(
Index
k
=
startZ
;
k
<
endZ
;
k
++
)
f
(
i
,
j
,
k
,
args
...
);
#else
for
(
Index
i
=
startX
;
i
<
endX
;
i
++
)
for
(
Index
j
=
startY
;
j
<
endY
;
j
++
)
for
(
Index
k
=
startZ
;
k
<
endZ
;
k
++
)
f
(
i
,
j
,
k
,
args
...
);
#endif
}
};
...
...
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