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
eb6e8c0f
Commit
eb6e8c0f
authored
3 months ago
by
Richard Angersbach
Browse files
Options
Downloads
Patches
Plain Diff
Check if reduction symbol is (illegally) accessed before/after reduction assignment
parent
f0aba2e9
No related branches found
No related tags found
1 merge request
!438
Reduction Support
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pystencils/backend/kernelcreation/freeze.py
+15
-15
15 additions, 15 deletions
src/pystencils/backend/kernelcreation/freeze.py
with
15 additions
and
15 deletions
src/pystencils/backend/kernelcreation/freeze.py
+
15
−
15
View file @
eb6e8c0f
...
@@ -189,22 +189,12 @@ class FreezeExpressions:
...
@@ -189,22 +189,12 @@ class FreezeExpressions:
def
map_ReductionAssignment
(
self
,
expr
:
ReductionAssignment
):
def
map_ReductionAssignment
(
self
,
expr
:
ReductionAssignment
):
assert
isinstance
(
expr
.
lhs
,
TypedSymbol
)
assert
isinstance
(
expr
.
lhs
,
TypedSymbol
)
# make sure that either:
# make sure that lhs symbol never occurred before ReductionAssignment
# 1) lhs symbol never occurred
# 2) that it is at least known as lhs of an existing reduction operation
if
self
.
_ctx
.
find_symbol
(
expr
.
lhs
.
name
):
if
self
.
_ctx
.
find_symbol
(
expr
.
lhs
.
name
):
# make sure that reduction operations are not mixed within a kernel
raise
FreezeError
(
if
info
:
=
self
.
_ctx
.
find_reduction_info
(
expr
.
lhs
.
name
):
f
"
Left-hand side
{
expr
.
lhs
}
of ReductionAssignment already exists in symbol table.
"
if
info
.
op
is
not
expr
.
reduction_op
:
f
"
Make sure that it is only used once in a kernel
'
s ReductionAssignment.
"
raise
FreezeError
(
)
f
"
Different reduction operation
{
info
.
op
}
already exists
"
f
"
for
{
expr
.
lhs
}
with target reduction op
{
expr
.
reduction_op
}
.
"
)
else
:
raise
FreezeError
(
f
"
Left-hand side
{
expr
.
lhs
}
of ReductionAssignment already exists in symbol table.
"
f
"
Make sure that it is exclusively used within the kernel to conduct ReductionAssignment
'
s.
"
)
lhs
=
self
.
visit
(
expr
.
lhs
)
lhs
=
self
.
visit
(
expr
.
lhs
)
rhs
=
self
.
visit
(
expr
.
rhs
)
rhs
=
self
.
visit
(
expr
.
rhs
)
...
@@ -340,6 +330,16 @@ class FreezeExpressions:
...
@@ -340,6 +330,16 @@ class FreezeExpressions:
def
map_TypedSymbol
(
self
,
expr
:
TypedSymbol
):
def
map_TypedSymbol
(
self
,
expr
:
TypedSymbol
):
dtype
=
self
.
_ctx
.
resolve_dynamic_type
(
expr
.
dtype
)
dtype
=
self
.
_ctx
.
resolve_dynamic_type
(
expr
.
dtype
)
# check if symbol is referenced after freezing a ReductionAssignment
if
self
.
_ctx
.
find_reduction_info
(
expr
.
name
):
# check if types do not align since a ReductionAssignment modifies
# the symbol's type to PsPointerType in the context's symbol table
if
(
symbol
:
=
self
.
_ctx
.
find_symbol
(
expr
.
name
))
and
symbol
.
dtype
!=
dtype
:
raise
FreezeError
(
f
"
Illegal access to reduction symbol
{
symbol
.
name
}
after freezing a kernel
'
s ReductionAssignment.
"
)
symb
=
self
.
_ctx
.
get_symbol
(
expr
.
name
,
dtype
)
symb
=
self
.
_ctx
.
get_symbol
(
expr
.
name
,
dtype
)
return
PsSymbolExpr
(
symb
)
return
PsSymbolExpr
(
symb
)
...
...
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