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
fb2437d4
Commit
fb2437d4
authored
4 years ago
by
Markus Holzer
Browse files
Options
Downloads
Patches
Plain Diff
Added test case for pow printing to llvm
parent
bd71f597
No related branches found
No related tags found
1 merge request
!174
Extend testsuit
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pystencils_tests/test_llvm.py
+46
-1
46 additions, 1 deletion
pystencils_tests/test_llvm.py
with
46 additions
and
1 deletion
pystencils_tests/test_
jacobi_
llvm.py
→
pystencils_tests/test_llvm.py
+
46
−
1
View file @
fb2437d4
...
@@ -6,11 +6,11 @@ try:
...
@@ -6,11 +6,11 @@ try:
from
pystencils.cpu.cpujit
import
get_llc_command
from
pystencils.cpu.cpujit
import
get_llc_command
from
pystencils
import
Assignment
,
Field
,
show_code
from
pystencils
import
Assignment
,
Field
,
show_code
import
numpy
as
np
import
numpy
as
np
import
sympy
as
sp
except
ModuleNotFoundError
:
except
ModuleNotFoundError
:
pytest
.
importorskip
(
"
llvmlite
"
)
pytest
.
importorskip
(
"
llvmlite
"
)
def
test_jacobi_fixed_field_size
():
def
test_jacobi_fixed_field_size
():
size
=
(
30
,
20
)
size
=
(
30
,
20
)
...
@@ -93,5 +93,50 @@ def test_jacobi_variable_field_size():
...
@@ -93,5 +93,50 @@ def test_jacobi_variable_field_size():
np
.
testing
.
assert_almost_equal
(
error
,
0.0
)
np
.
testing
.
assert_almost_equal
(
error
,
0.0
)
def
test_pow_llvm
():
size
=
(
30
,
20
)
src_field_llvm
=
4
*
np
.
ones
(
size
)
dst_field_llvm
=
np
.
zeros
(
size
)
f
=
Field
.
create_from_numpy_array
(
"
f
"
,
src_field_llvm
)
d
=
Field
.
create_from_numpy_array
(
"
d
"
,
dst_field_llvm
)
ur
=
Assignment
(
d
[
0
,
0
],
sp
.
Pow
(
f
[
0
,
0
],
-
1.0
))
ast
=
create_kernel
([
ur
])
jit
=
generate_and_jit
(
ast
)
jit
(
'
kernel
'
,
dst_field_llvm
,
src_field_llvm
)
assert
np
.
all
(
0.25
==
dst_field_llvm
)
ur
=
Assignment
(
d
[
0
,
0
],
sp
.
Pow
(
f
[
0
,
0
],
0.5
))
ast
=
create_kernel
([
ur
])
jit
=
generate_and_jit
(
ast
)
jit
(
'
kernel
'
,
dst_field_llvm
,
src_field_llvm
)
assert
np
.
all
(
2.0
==
dst_field_llvm
)
ur
=
Assignment
(
d
[
0
,
0
],
sp
.
Pow
(
f
[
0
,
0
],
2.0
))
ast
=
create_kernel
([
ur
])
jit
=
generate_and_jit
(
ast
)
jit
(
'
kernel
'
,
dst_field_llvm
,
src_field_llvm
)
assert
np
.
all
(
16.0
==
dst_field_llvm
)
ur
=
Assignment
(
d
[
0
,
0
],
sp
.
Pow
(
f
[
0
,
0
],
3.0
))
ast
=
create_kernel
([
ur
])
jit
=
generate_and_jit
(
ast
)
jit
(
'
kernel
'
,
dst_field_llvm
,
src_field_llvm
)
assert
np
.
all
(
64.0
==
dst_field_llvm
)
ur
=
Assignment
(
d
[
0
,
0
],
sp
.
Pow
(
f
[
0
,
0
],
4.0
))
ast
=
create_kernel
([
ur
])
jit
=
generate_and_jit
(
ast
)
jit
(
'
kernel
'
,
dst_field_llvm
,
src_field_llvm
)
assert
np
.
all
(
256.0
==
dst_field_llvm
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
test_jacobi_fixed_field_size_gpu
()
test_jacobi_fixed_field_size_gpu
()
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