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
Stephan Seitz
pystencils
Commits
44a924db
Commit
44a924db
authored
5 years ago
by
Michael Kuron
Browse files
Options
Downloads
Patches
Plain Diff
Improve debugging of create_staggered_kernel
parent
358c44b8
Branches
ponsuganth/mixed-mass-operators
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils/kernelcreation.py
+10
-5
10 additions, 5 deletions
pystencils/kernelcreation.py
pystencils_tests/test_staggered_kernel.py
+2
-1
2 additions, 1 deletion
pystencils_tests/test_staggered_kernel.py
with
12 additions
and
6 deletions
pystencils/kernelcreation.py
+
10
−
5
View file @
44a924db
...
@@ -215,14 +215,18 @@ def create_staggered_kernel(assignments, gpu_exclusive_conditions=False, **kwarg
...
@@ -215,14 +215,18 @@ def create_staggered_kernel(assignments, gpu_exclusive_conditions=False, **kwarg
if
isinstance
(
assignments
,
AssignmentCollection
):
if
isinstance
(
assignments
,
AssignmentCollection
):
subexpressions
=
assignments
.
subexpressions
+
[
a
for
a
in
assignments
.
main_assignments
subexpressions
=
assignments
.
subexpressions
+
[
a
for
a
in
assignments
.
main_assignments
if
type
(
a
.
lhs
)
is
not
Field
.
Access
if
not
hasattr
(
a
,
'
lhs
'
)
or
type
(
a
.
lhs
)
is
not
Field
.
Access
or
not
FieldType
.
is_staggered
(
a
.
lhs
.
field
)]
or
not
FieldType
.
is_staggered
(
a
.
lhs
.
field
)]
assignments
=
[
a
for
a
in
assignments
.
main_assignments
if
type
(
a
.
lhs
)
is
Field
.
Access
assignments
=
[
a
for
a
in
assignments
.
main_assignments
if
hasattr
(
a
,
'
lhs
'
)
and
type
(
a
.
lhs
)
is
Field
.
Access
and
FieldType
.
is_staggered
(
a
.
lhs
.
field
)]
and
FieldType
.
is_staggered
(
a
.
lhs
.
field
)]
else
:
else
:
subexpressions
=
[
a
for
a
in
assignments
if
type
(
a
.
lhs
)
is
not
Field
.
Access
subexpressions
=
[
a
for
a
in
assignments
if
not
hasattr
(
a
,
'
lhs
'
)
or
type
(
a
.
lhs
)
is
not
Field
.
Access
or
not
FieldType
.
is_staggered
(
a
.
lhs
.
field
)]
or
not
FieldType
.
is_staggered
(
a
.
lhs
.
field
)]
assignments
=
[
a
for
a
in
assignments
if
type
(
a
.
lhs
)
is
Field
.
Access
assignments
=
[
a
for
a
in
assignments
if
hasattr
(
a
,
'
lhs
'
)
and
type
(
a
.
lhs
)
is
Field
.
Access
and
FieldType
.
is_staggered
(
a
.
lhs
.
field
)]
and
FieldType
.
is_staggered
(
a
.
lhs
.
field
)]
if
len
(
set
([
tuple
(
a
.
lhs
.
field
.
staggered_stencil
)
for
a
in
assignments
]))
!=
1
:
if
len
(
set
([
tuple
(
a
.
lhs
.
field
.
staggered_stencil
)
for
a
in
assignments
]))
!=
1
:
raise
ValueError
(
"
All assignments need to be made to staggered fields with the same stencil
"
)
raise
ValueError
(
"
All assignments need to be made to staggered fields with the same stencil
"
)
...
@@ -277,7 +281,8 @@ def create_staggered_kernel(assignments, gpu_exclusive_conditions=False, **kwarg
...
@@ -277,7 +281,8 @@ def create_staggered_kernel(assignments, gpu_exclusive_conditions=False, **kwarg
for
assignment
in
assignments
:
for
assignment
in
assignments
:
direction
=
assignment
.
lhs
.
field
.
staggered_stencil
[
assignment
.
lhs
.
index
[
0
]]
direction
=
assignment
.
lhs
.
field
.
staggered_stencil
[
assignment
.
lhs
.
index
[
0
]]
sp_assignments
=
[
SympyAssignment
(
s
.
lhs
,
s
.
rhs
)
for
s
in
subexpressions
]
+
\
sp_assignments
=
[
s
for
s
in
subexpressions
if
not
hasattr
(
s
,
'
lhs
'
)]
+
\
[
SympyAssignment
(
s
.
lhs
,
s
.
rhs
)
for
s
in
subexpressions
if
hasattr
(
s
,
'
lhs
'
)]
+
\
[
SympyAssignment
(
assignment
.
lhs
,
assignment
.
rhs
)]
[
SympyAssignment
(
assignment
.
lhs
,
assignment
.
rhs
)]
last_conditional
=
Conditional
(
condition
(
direction
),
Block
(
sp_assignments
))
last_conditional
=
Conditional
(
condition
(
direction
),
Block
(
sp_assignments
))
final_assignments
.
append
(
last_conditional
)
final_assignments
.
append
(
last_conditional
)
...
...
This diff is collapsed.
Click to expand it.
pystencils_tests/test_staggered_kernel.py
+
2
−
1
View file @
44a924db
...
@@ -45,8 +45,9 @@ class TestStaggeredDiffusion:
...
@@ -45,8 +45,9 @@ class TestStaggeredDiffusion:
dh
.
all_to_cpu
()
dh
.
all_to_cpu
()
def
init
():
def
init
():
dh
.
fill
(
c
.
name
,
np
.
nan
,
ghost_layers
=
True
,
inner_ghost_layers
=
True
)
dh
.
fill
(
c
.
name
,
0
)
dh
.
fill
(
c
.
name
,
0
)
dh
.
fill
(
j
.
name
,
np
.
nan
)
dh
.
fill
(
j
.
name
,
np
.
nan
,
ghost_layers
=
True
,
inner_ghost_layers
=
True
)
dh
.
cpu_arrays
[
c
.
name
][
L
[
0
]
//
2
:
L
[
0
]
//
2
+
2
,
L
[
1
]
//
2
:
L
[
1
]
//
2
+
2
]
=
1.0
dh
.
cpu_arrays
[
c
.
name
][
L
[
0
]
//
2
:
L
[
0
]
//
2
+
2
,
L
[
1
]
//
2
:
L
[
1
]
//
2
+
2
]
=
1.0
init
()
init
()
...
...
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