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
Jonas Plewinski
pystencils
Commits
5a5a878c
Commit
5a5a878c
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Add execution test for complex numbers
parent
f9b8ee6e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils/cpu/cpujit.py
+2
-1
2 additions, 1 deletion
pystencils/cpu/cpujit.py
pystencils_tests/test_complex_numbers.py
+27
-3
27 additions, 3 deletions
pystencils_tests/test_complex_numbers.py
with
29 additions
and
4 deletions
pystencils/cpu/cpujit.py
+
2
−
1
View file @
5a5a878c
...
@@ -358,7 +358,8 @@ def create_function_boilerplate_code(parameter_info, name, insert_checks=True):
...
@@ -358,7 +358,8 @@ def create_function_boilerplate_code(parameter_info, name, insert_checks=True):
np_dtype
=
field
.
dtype
.
numpy_dtype
np_dtype
=
field
.
dtype
.
numpy_dtype
item_size
=
np_dtype
.
itemsize
item_size
=
np_dtype
.
itemsize
if
np_dtype
.
isbuiltin
and
FieldType
.
is_generic
(
field
):
if
(
np_dtype
.
isbuiltin
and
FieldType
.
is_generic
(
field
)
and
not
np
.
issubdtype
(
field
.
dtype
.
numpy_dtype
,
np
.
complexfloating
)):
dtype_cond
=
"
buffer_{name}.format[0] ==
'
{format}
'"
.
format
(
name
=
field
.
name
,
dtype_cond
=
"
buffer_{name}.format[0] ==
'
{format}
'"
.
format
(
name
=
field
.
name
,
format
=
field
.
dtype
.
numpy_dtype
.
char
)
format
=
field
.
dtype
.
numpy_dtype
.
char
)
pre_call_code
+=
template_check_array
.
format
(
cond
=
dtype_cond
,
what
=
"
data type
"
,
name
=
field
.
name
,
pre_call_code
+=
template_check_array
.
format
(
cond
=
dtype_cond
,
what
=
"
data type
"
,
name
=
field
.
name
,
...
...
This diff is collapsed.
Click to expand it.
pystencils_tests/test_complex_numbers.py
+
27
−
3
View file @
5a5a878c
...
@@ -9,10 +9,10 @@
...
@@ -9,10 +9,10 @@
import
itertools
import
itertools
import
numpy
as
np
import
pytest
import
pytest
import
sympy
import
sympy
from
sympy.functions
import
im
,
re
from
sympy.functions
import
im
,
re
import
numpy
as
np
import
pystencils
import
pystencils
from
pystencils
import
AssignmentCollection
from
pystencils
import
AssignmentCollection
...
@@ -86,10 +86,10 @@ TEST_ASSIGNMENTS = [
...
@@ -86,10 +86,10 @@ TEST_ASSIGNMENTS = [
})
})
]
]
SCALAR_DTYPES
=
[
'
float64
'
]
SCALAR_DTYPES
=
[
'
float64
'
]
@pytest.mark.parametrize
(
"
assignment
"
,
TEST_ASSIGNMENTS
)
@pytest.mark.parametrize
(
"
assignment
"
,
TEST_ASSIGNMENTS
)
@pytest.mark.parametrize
(
'
target
'
,
(
'
cpu
'
,
'
gpu
'
))
@pytest.mark.parametrize
(
'
target
'
,
(
'
cpu
'
,
'
gpu
'
))
def
test_complex_numbers_64
(
assignment
,
target
):
def
test_complex_numbers_64
(
assignment
,
target
):
ast
=
pystencils
.
create_kernel
(
assignment
,
ast
=
pystencils
.
create_kernel
(
assignment
,
...
@@ -102,3 +102,27 @@ def test_complex_numbers_64(assignment, target):
...
@@ -102,3 +102,27 @@ def test_complex_numbers_64(assignment, target):
kernel
=
ast
.
compile
()
kernel
=
ast
.
compile
()
assert
kernel
is
not
None
assert
kernel
is
not
None
@pytest.mark.parametrize
(
'
dtype
'
,
(
np
.
float32
,
np
.
float64
))
@pytest.mark.parametrize
(
'
target
'
,
(
'
cpu
'
,
'
gpu
'
))
def
test_complex_execution
(
dtype
,
target
):
complex_dtype
=
f
'
complex
{
64
if
dtype
==
np
.
float32
else
128
}
'
x
,
y
=
pystencils
.
fields
(
f
'
x, y:
{
complex_dtype
}
[2d]
'
)
x_arr
=
np
.
zeros
((
20
,
30
),
complex_dtype
)
y_arr
=
np
.
zeros
((
20
,
30
),
complex_dtype
)
assignments
=
AssignmentCollection
({
y
.
center
:
x
.
center
*
(
2j
+
1
)
})
if
target
==
'
gpu
'
:
from
pycuda.gpuarray
import
zeros
x_arr
=
zeros
((
20
,
30
),
complex_dtype
)
y_arr
=
zeros
((
20
,
30
),
complex_dtype
)
kernel
=
pystencils
.
create_kernel
(
assignments
,
target
=
target
,
data_type
=
dtype
).
compile
()
kernel
(
x
=
x_arr
,
y
=
y_arr
)
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