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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Sebastian Bindgen
pystencils
Commits
d0a06963
Commit
d0a06963
authored
4 years ago
by
Markus Holzer
Browse files
Options
Downloads
Patches
Plain Diff
Fixed operation count
parent
e462d7f4
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pystencils/sympyextensions.py
+3
-2
3 additions, 2 deletions
pystencils/sympyextensions.py
pystencils_tests/test_datahandling.py
+3
-3
3 additions, 3 deletions
pystencils_tests/test_datahandling.py
pystencils_tests/test_sympyextensions.py
+1
-1
1 addition, 1 deletion
pystencils_tests/test_sympyextensions.py
with
7 additions
and
6 deletions
pystencils/sympyextensions.py
+
3
−
2
View file @
d0a06963
...
@@ -481,7 +481,7 @@ def count_operations(term: Union[sp.Expr, List[sp.Expr]],
...
@@ -481,7 +481,7 @@ def count_operations(term: Union[sp.Expr, List[sp.Expr]],
pass
pass
elif
t
.
func
is
sp
.
Mul
:
elif
t
.
func
is
sp
.
Mul
:
if
check_type
(
t
):
if
check_type
(
t
):
result
[
'
muls
'
]
+=
len
(
t
.
args
)
result
[
'
muls
'
]
+=
len
(
t
.
args
)
-
1
for
a
in
t
.
args
:
for
a
in
t
.
args
:
if
a
==
1
or
a
==
-
1
:
if
a
==
1
or
a
==
-
1
:
result
[
'
muls
'
]
-=
1
result
[
'
muls
'
]
-=
1
...
@@ -509,7 +509,8 @@ def count_operations(term: Union[sp.Expr, List[sp.Expr]],
...
@@ -509,7 +509,8 @@ def count_operations(term: Union[sp.Expr, List[sp.Expr]],
if
t
.
exp
>=
0
:
if
t
.
exp
>=
0
:
result
[
'
muls
'
]
+=
int
(
t
.
exp
)
-
1
result
[
'
muls
'
]
+=
int
(
t
.
exp
)
-
1
else
:
else
:
result
[
'
muls
'
]
-=
1
if
result
[
'
muls
'
]
>
0
:
result
[
'
muls
'
]
-=
1
result
[
'
divs
'
]
+=
1
result
[
'
divs
'
]
+=
1
result
[
'
muls
'
]
+=
(
-
int
(
t
.
exp
))
-
1
result
[
'
muls
'
]
+=
(
-
int
(
t
.
exp
))
-
1
elif
sp
.
nsimplify
(
t
.
exp
)
==
sp
.
Rational
(
1
,
2
):
elif
sp
.
nsimplify
(
t
.
exp
)
==
sp
.
Rational
(
1
,
2
):
...
...
This diff is collapsed.
Click to expand it.
pystencils_tests/test_datahandling.py
+
3
−
3
View file @
d0a06963
...
@@ -116,9 +116,6 @@ def kernel_execution_jacobi(dh, target):
...
@@ -116,9 +116,6 @@ def kernel_execution_jacobi(dh, target):
assert
dh
.
is_on_gpu
(
'
f
'
)
assert
dh
.
is_on_gpu
(
'
f
'
)
assert
dh
.
is_on_gpu
(
'
tmp
'
)
assert
dh
.
is_on_gpu
(
'
tmp
'
)
with
pytest
.
raises
(
ValueError
):
dh
.
add_array
(
'
f
'
,
gpu
=
test_gpu
)
stencil_2d
=
[(
1
,
0
),
(
-
1
,
0
),
(
0
,
1
),
(
0
,
-
1
)]
stencil_2d
=
[(
1
,
0
),
(
-
1
,
0
),
(
0
,
1
),
(
0
,
-
1
)]
stencil_3d
=
[(
1
,
0
,
0
),
(
-
1
,
0
,
0
),
(
0
,
1
,
0
),
(
0
,
-
1
,
0
),
(
0
,
0
,
1
),
(
0
,
0
,
-
1
)]
stencil_3d
=
[(
1
,
0
,
0
),
(
-
1
,
0
,
0
),
(
0
,
1
,
0
),
(
0
,
-
1
,
0
),
(
0
,
0
,
1
),
(
0
,
0
,
-
1
)]
stencil
=
stencil_2d
if
dh
.
dim
==
2
else
stencil_3d
stencil
=
stencil_2d
if
dh
.
dim
==
2
else
stencil_3d
...
@@ -263,6 +260,9 @@ def test_get_kwarg():
...
@@ -263,6 +260,9 @@ def test_get_kwarg():
dh
.
fill
(
"
src
"
,
1.0
,
ghost_layers
=
True
)
dh
.
fill
(
"
src
"
,
1.0
,
ghost_layers
=
True
)
dh
.
fill
(
"
dst
"
,
0.0
,
ghost_layers
=
True
)
dh
.
fill
(
"
dst
"
,
0.0
,
ghost_layers
=
True
)
with
pytest
.
raises
(
ValueError
):
dh
.
add_array
(
'
src
'
)
ur
=
ps
.
Assignment
(
src
.
center
,
dst
.
center
)
ur
=
ps
.
Assignment
(
src
.
center
,
dst
.
center
)
kernel
=
ps
.
create_kernel
(
ur
).
compile
()
kernel
=
ps
.
create_kernel
(
ur
).
compile
()
...
...
This diff is collapsed.
Click to expand it.
pystencils_tests/test_sympyextensions.py
+
1
−
1
View file @
d0a06963
...
@@ -119,7 +119,7 @@ def test_count_operations():
...
@@ -119,7 +119,7 @@ def test_count_operations():
expr
=
sympy
.
Pow
(
1
/
x
+
y
*
sympy
.
sqrt
(
z
),
100
)
expr
=
sympy
.
Pow
(
1
/
x
+
y
*
sympy
.
sqrt
(
z
),
100
)
ops
=
count_operations
(
expr
,
only_type
=
None
)
ops
=
count_operations
(
expr
,
only_type
=
None
)
assert
ops
[
'
adds
'
]
==
1
assert
ops
[
'
adds
'
]
==
1
assert
ops
[
'
muls
'
]
==
100
assert
ops
[
'
muls
'
]
==
99
assert
ops
[
'
divs
'
]
==
1
assert
ops
[
'
divs
'
]
==
1
assert
ops
[
'
sqrts
'
]
==
1
assert
ops
[
'
sqrts
'
]
==
1
...
...
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