Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
pystencils
Commits
83fcc73a
Commit
83fcc73a
authored
2 months ago
by
Richard Angersbach
Browse files
Options
Downloads
Patches
Plain Diff
Add reductions param to AddOpenMP
parent
c76b897f
No related branches found
No related tags found
1 merge request
!438
Reduction Support
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/pystencils/backend/transformations/add_pragmas.py
+14
-10
14 additions, 10 deletions
src/pystencils/backend/transformations/add_pragmas.py
src/pystencils/codegen/driver.py
+1
-0
1 addition, 0 deletions
src/pystencils/codegen/driver.py
with
15 additions
and
10 deletions
src/pystencils/backend/transformations/add_pragmas.py
+
14
−
10
View file @
83fcc73a
...
...
@@ -8,6 +8,7 @@ from ..kernelcreation import KernelCreationContext
from
..ast
import
PsAstNode
from
..ast.structural
import
PsBlock
,
PsLoop
,
PsPragma
,
PsStructuralNode
from
..ast.expressions
import
PsExpression
from
..kernelcreation.context
import
ReductionInfo
from
...types
import
PsScalarType
...
...
@@ -104,12 +105,16 @@ class AddOpenMP:
def
__init__
(
self
,
ctx
:
KernelCreationContext
,
reductions
:
Sequence
[
ReductionInfo
]
=
(),
nesting_depth
:
int
=
0
,
num_threads
:
int
|
None
=
None
,
schedule
:
str
|
None
=
None
,
collapse
:
int
|
None
=
None
,
omit_parallel
:
bool
=
False
,
)
->
None
:
self
.
_reductions
=
reductions
pragma_text
=
"
omp
"
if
not
omit_parallel
:
...
...
@@ -123,16 +128,15 @@ class AddOpenMP:
if
num_threads
is
not
None
:
pragma_text
+=
f
"
num_threads(
{
str
(
num_threads
)
}
)
"
if
bool
(
ctx
.
reduction_data
):
for
_
,
reduction_info
in
ctx
.
reduction_data
.
items
():
if
isinstance
(
reduction_info
.
local_symbol
.
dtype
,
PsScalarType
):
pragma_text
+=
(
f
"
reduction(
{
reduction_info
.
op
.
value
}
:
{
reduction_info
.
local_symbol
.
name
}
)
"
)
else
:
NotImplementedError
(
"
OMP: Reductions for non-scalar data types are not supported yet.
"
)
for
reduction_info
in
self
.
_reductions
:
if
isinstance
(
reduction_info
.
local_symbol
.
dtype
,
PsScalarType
):
pragma_text
+=
(
f
"
reduction(
{
reduction_info
.
op
.
value
}
:
{
reduction_info
.
local_symbol
.
name
}
)
"
)
else
:
NotImplementedError
(
"
OMP: Reductions for non-scalar data types are not supported yet.
"
)
if
collapse
is
not
None
:
if
collapse
<=
0
:
...
...
This diff is collapsed.
Click to expand it.
src/pystencils/codegen/driver.py
+
1
−
0
View file @
83fcc73a
...
...
@@ -359,6 +359,7 @@ class DefaultKernelCreationDriver:
add_omp
=
AddOpenMP
(
self
.
_ctx
,
reductions
=
list
(
self
.
_ctx
.
reduction_data
.
values
()),
nesting_depth
=
omp_options
.
get_option
(
"
nesting_depth
"
),
num_threads
=
omp_options
.
get_option
(
"
num_threads
"
),
schedule
=
omp_options
.
get_option
(
"
schedule
"
),
...
...
This diff is collapsed.
Click to expand it.
Frederik Hennig
@da15siwa
mentioned in commit
4e688b86
·
2 months ago
mentioned in commit
4e688b86
mentioned in commit 4e688b867339c90a6fba3ad12c383d1e59211ed9
Toggle commit list
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