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
Compare revisions
5d03477a57b945e3cf66b545ecf887fa38ce2ca4 to 205ef8957ba36b88e7e34e5efa2cc7c13ce7564d
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
pycodegen/pystencils
Select target project
No results found
205ef8957ba36b88e7e34e5efa2cc7c13ce7564d
Select Git revision
Branches
66-absolute-access-is-probably-not-copied-correctly-after-_eval_subs
const_fix
fhennig/cpu-jit
fhennig/v2.0-deprecations
fma
gpu_bufferfield_fix
gpu_liveness_opts
holzer-master-patch-46757
hyteg
improved_comm
master
nhr-course-week
rangersbach/fix-gpu-atomics
target_dh_refactoring
v2.0-dev
vectorization_sqrt_fix
zikeliml/124-rework-tutorials
zikeliml/Task-96-dotExporterForAST
Tags
last/Kerncraft
last/LLVM
last/OpenCL
release/0.2.1
release/0.2.10
release/0.2.11
release/0.2.12
release/0.2.13
release/0.2.14
release/0.2.15
release/0.2.2
release/0.2.3
release/0.2.4
release/0.2.6
release/0.2.7
release/0.2.8
release/0.2.9
release/0.3.0
release/0.3.1
release/0.3.2
release/0.3.3
release/0.3.4
release/0.4.0
release/0.4.1
release/0.4.2
release/0.4.3
release/0.4.4
release/1.0
release/1.0.1
release/1.1
release/1.1.1
release/1.2
release/1.3
release/1.3.1
release/1.3.2
release/1.3.3
release/1.3.4
release/1.3.5
release/1.3.6
release/1.3.7
release/2.0.dev0
59 results
Swap
Target
pycodegen/pystencils
Select target project
anirudh.jonnalagadda/pystencils
hyteg/pystencils
jbadwaik/pystencils
jngrad/pystencils
itischler/pystencils
ob28imeq/pystencils
hoenig/pystencils
Bindgen/pystencils
hammer/pystencils
da15siwa/pystencils
holzer/pystencils
alexander.reinauer/pystencils
ec93ujoh/pystencils
Harke/pystencils
seitz/pystencils
pycodegen/pystencils
16 results
5d03477a57b945e3cf66b545ecf887fa38ce2ca4
Select Git revision
Branches
66-absolute-access-is-probably-not-copied-correctly-after-_eval_subs
const_fix
fhennig/cpu-jit
fhennig/v2.0-deprecations
fma
gpu_bufferfield_fix
gpu_liveness_opts
holzer-master-patch-46757
hyteg
improved_comm
master
nhr-course-week
rangersbach/fix-gpu-atomics
target_dh_refactoring
v2.0-dev
vectorization_sqrt_fix
zikeliml/124-rework-tutorials
zikeliml/Task-96-dotExporterForAST
Tags
last/Kerncraft
last/LLVM
last/OpenCL
release/0.2.1
release/0.2.10
release/0.2.11
release/0.2.12
release/0.2.13
release/0.2.14
release/0.2.15
release/0.2.2
release/0.2.3
release/0.2.4
release/0.2.6
release/0.2.7
release/0.2.8
release/0.2.9
release/0.3.0
release/0.3.1
release/0.3.2
release/0.3.3
release/0.3.4
release/0.4.0
release/0.4.1
release/0.4.2
release/0.4.3
release/0.4.4
release/1.0
release/1.0.1
release/1.1
release/1.1.1
release/1.2
release/1.3
release/1.3.1
release/1.3.2
release/1.3.3
release/1.3.4
release/1.3.5
release/1.3.6
release/1.3.7
release/2.0.dev0
59 results
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/nbackend/transformations/test_add_pragmas.py
+54
-0
54 additions, 0 deletions
tests/nbackend/transformations/test_add_pragmas.py
tests/nbackend/transformations/test_branch_elimination.py
+44
-2
44 additions, 2 deletions
tests/nbackend/transformations/test_branch_elimination.py
with
98 additions
and
2 deletions
tests/nbackend/transformations/test_add_pragmas.py
0 → 100644
View file @
205ef895
import
sympy
as
sp
from
itertools
import
product
from
pystencils
import
make_slice
,
fields
,
Assignment
from
pystencils.backend.kernelcreation
import
(
KernelCreationContext
,
AstFactory
,
FullIterationSpace
,
)
from
pystencils.backend.ast
import
dfs_preorder
from
pystencils.backend.ast.structural
import
PsBlock
,
PsPragma
,
PsLoop
from
pystencils.backend.transformations
import
InsertPragmasAtLoops
,
LoopPragma
def
test_insert_pragmas
():
ctx
=
KernelCreationContext
()
factory
=
AstFactory
(
ctx
)
f
,
g
=
fields
(
"
f, g: [3D]
"
)
ispace
=
FullIterationSpace
.
create_from_slice
(
ctx
,
make_slice
[:,
:,
:],
archetype_field
=
f
)
ctx
.
set_iteration_space
(
ispace
)
stencil
=
list
(
product
([
-
1
,
0
,
1
],
[
-
1
,
0
,
1
],
[
-
1
,
0
,
1
]))
loop_body
=
PsBlock
([
factory
.
parse_sympy
(
Assignment
(
f
.
center
(
0
),
sum
(
g
.
neighbors
(
stencil
))))
])
loops
=
factory
.
loops_from_ispace
(
ispace
,
loop_body
)
pragmas
=
(
LoopPragma
(
"
omp parallel for
"
,
0
),
LoopPragma
(
"
some nonsense pragma
"
,
1
),
LoopPragma
(
"
omp simd
"
,
-
1
),
)
add_pragmas
=
InsertPragmasAtLoops
(
ctx
,
pragmas
)
ast
=
add_pragmas
(
loops
)
assert
isinstance
(
ast
,
PsBlock
)
first_pragma
=
ast
.
statements
[
0
]
assert
isinstance
(
first_pragma
,
PsPragma
)
assert
first_pragma
.
text
==
pragmas
[
0
].
text
assert
ast
.
statements
[
1
]
==
loops
second_pragma
=
loops
.
body
.
statements
[
0
]
assert
isinstance
(
second_pragma
,
PsPragma
)
assert
second_pragma
.
text
==
pragmas
[
1
].
text
second_loop
=
list
(
dfs_preorder
(
ast
,
lambda
node
:
isinstance
(
node
,
PsLoop
)))[
1
]
assert
isinstance
(
second_loop
,
PsLoop
)
third_pragma
=
second_loop
.
body
.
statements
[
0
]
assert
isinstance
(
third_pragma
,
PsPragma
)
assert
third_pragma
.
text
==
pragmas
[
2
].
text
This diff is collapsed.
Click to expand it.
tests/nbackend/transformations/test_branch_elimination.py
View file @
205ef895
...
@@ -4,12 +4,18 @@ from pystencils.backend.kernelcreation import (
...
@@ -4,12 +4,18 @@ from pystencils.backend.kernelcreation import (
Typifier
,
Typifier
,
AstFactory
,
AstFactory
,
)
)
from
pystencils.backend.ast.expressions
import
PsExpression
from
pystencils.backend.ast.expressions
import
(
PsExpression
,
PsEq
,
PsGe
,
PsGt
,
PsLe
,
PsLt
,
)
from
pystencils.backend.ast.structural
import
PsConditional
,
PsBlock
,
PsComment
from
pystencils.backend.ast.structural
import
PsConditional
,
PsBlock
,
PsComment
from
pystencils.backend.constants
import
PsConstant
from
pystencils.backend.constants
import
PsConstant
from
pystencils.backend.transformations
import
EliminateBranches
from
pystencils.backend.transformations
import
EliminateBranches
from
pystencils.types.quick
import
Int
from
pystencils.types.quick
import
Int
from
pystencils.backend.ast.expressions
import
PsGt
i0
=
PsExpression
.
make
(
PsConstant
(
0
,
Int
(
32
)))
i0
=
PsExpression
.
make
(
PsConstant
(
0
,
Int
(
32
)))
...
@@ -53,3 +59,39 @@ def test_eliminate_nested_conditional():
...
@@ -53,3 +59,39 @@ def test_eliminate_nested_conditional():
result
=
elim
(
ast
)
result
=
elim
(
ast
)
assert
result
.
body
.
statements
[
0
].
body
.
statements
[
0
]
==
b1
assert
result
.
body
.
statements
[
0
].
body
.
statements
[
0
]
==
b1
def
test_isl
():
ctx
=
KernelCreationContext
()
factory
=
AstFactory
(
ctx
)
typify
=
Typifier
(
ctx
)
elim
=
EliminateBranches
(
ctx
)
i
=
PsExpression
.
make
(
ctx
.
get_symbol
(
"
i
"
,
ctx
.
index_dtype
))
j
=
PsExpression
.
make
(
ctx
.
get_symbol
(
"
j
"
,
ctx
.
index_dtype
))
const_2
=
PsExpression
.
make
(
PsConstant
(
2
,
ctx
.
index_dtype
))
const_4
=
PsExpression
.
make
(
PsConstant
(
4
,
ctx
.
index_dtype
))
a_true
=
PsBlock
([
PsComment
(
"
a true
"
)])
a_false
=
PsBlock
([
PsComment
(
"
a false
"
)])
b_true
=
PsBlock
([
PsComment
(
"
b true
"
)])
b_false
=
PsBlock
([
PsComment
(
"
b false
"
)])
c_true
=
PsBlock
([
PsComment
(
"
c true
"
)])
c_false
=
PsBlock
([
PsComment
(
"
c false
"
)])
a
=
PsConditional
(
PsLt
(
i
+
j
,
const_2
*
const_4
),
a_true
,
a_false
)
b
=
PsConditional
(
PsGe
(
j
,
const_4
),
b_true
,
b_false
)
c
=
PsConditional
(
PsEq
(
i
,
const_4
),
c_true
,
c_false
)
outer_loop
=
factory
.
loop
(
j
.
symbol
.
name
,
slice
(
0
,
3
),
PsBlock
([
a
,
b
,
c
]))
outer_cond
=
typify
(
PsConditional
(
PsLe
(
i
,
const_4
),
PsBlock
([
outer_loop
]),
PsBlock
([]))
)
ast
=
outer_cond
result
=
elim
(
ast
)
assert
result
.
branch_true
.
statements
[
0
].
body
.
statements
[
0
]
==
a_true
assert
result
.
branch_true
.
statements
[
0
].
body
.
statements
[
1
]
==
b_false
assert
result
.
branch_true
.
statements
[
0
].
body
.
statements
[
2
]
==
c
This diff is collapsed.
Click to expand it.
Prev
1
2
Next