Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cbmroot
Manage
Activity
Members
Labels
Plan
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Show more breadcrumbs
Computing
cbmroot
Commits
a054c167
Commit
a054c167
authored
1 year ago
by
Felix Weiglhofer
Browse files
Options
Downloads
Patches
Plain Diff
algo: Add CBM_PARALLEL_FOR macro.
parent
6f36b307
No related branches found
No related tags found
1 merge request
!1350
algo: Add CBM_PARALLEL_FOR macro.
Pipeline
#24357
passed
1 year ago
Stage: build
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.clang-format
+1
-0
1 addition, 0 deletions
.clang-format
algo/base/compat/OpenMP.h
+15
-0
15 additions, 0 deletions
algo/base/compat/OpenMP.h
algo/unpack/Unpack.cxx
+3
-2
3 additions, 2 deletions
algo/unpack/Unpack.cxx
with
19 additions
and
2 deletions
.clang-format
+
1
−
0
View file @
a054c167
...
...
@@ -147,6 +147,7 @@ SpacesInParentheses: false
SpacesInSquareBrackets: false
WhitespaceSensitiveMacros: ['CBM_ENUM_DICT']
StatementMacros: ['CBM_PARALLEL_FOR']
Standard: c++11
...
...
This diff is collapsed.
Click to expand it.
algo/base/compat/OpenMP.h
+
15
−
0
View file @
a054c167
...
...
@@ -10,6 +10,21 @@
#include
<omp.h>
#endif
#define CBM_PRAGMA(...) _Pragma(#__VA_ARGS__)
// OpenMP parallel for
// If OpenMP is not available, this macro expands to nothing
//
// Hiding the pragma in a macro isn't technically necessary, as the compiler will ignore it if OpenMP is not available.
// But it slightly increases readability as it's indented to the same level as the code it applies to.
//
// Accepts the same arguments as the OpenMP parallel for pragma.
#ifdef HAVE_OMP
#define CBM_PARALLEL_FOR(...) CBM_PRAGMA(omp parallel for __VA_ARGS__)
#else
#define CBM_PARALLEL_FOR(...)
#endif
namespace
cbm
::
algo
::
openmp
{
...
...
This diff is collapsed.
Click to expand it.
algo/unpack/Unpack.cxx
+
3
−
2
View file @
a054c167
...
...
@@ -10,6 +10,7 @@
#include
<xpu/host.h>
#include
"compat/Algorithm.h"
#include
"compat/OpenMP.h"
#include
"log.hpp"
using
namespace
std
;
...
...
@@ -178,7 +179,7 @@ namespace cbm::algo
xpu
::
push_timer
(
"Unpack"
);
xpu
::
t_add_bytes
(
sizeBytes
);
#pragma omp parallel for
schedule(dynamic)
CBM_PARALLEL_FOR
(
schedule
(
dynamic
)
)
for
(
size_t
i
=
0
;
i
<
numMs
;
i
++
)
{
auto
result
=
algos
.
at
(
msEqIds
[
i
])(
msContent
[
i
],
msDesc
[
i
],
ts
.
start_time
());
msDigis
[
i
]
=
std
::
move
(
result
.
first
);
...
...
@@ -196,7 +197,7 @@ namespace cbm::algo
xpu
::
push_timer
(
"Merge"
);
xpu
::
t_add_bytes
(
nDigisTotal
*
sizeof
(
Digi
));
#pragma omp parallel for
schedule(dynamic)
CBM_PARALLEL_FOR
(
schedule
(
dynamic
)
)
for
(
unsigned
int
i
=
0
;
i
<
numMs
;
i
++
)
{
unsigned
int
offset
=
0
;
for
(
unsigned
int
x
=
0
;
x
<
i
;
x
++
)
...
...
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