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
4b7f9e3a
Commit
4b7f9e3a
authored
4 years ago
by
Markus Holzer
Browse files
Options
Downloads
Patches
Plain Diff
Added test case
parent
25e62569
No related branches found
No related tags found
1 merge request
!226
Fix field size
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_vectorization_specific.py
+25
-0
25 additions, 0 deletions
pystencils_tests/test_vectorization_specific.py
with
27 additions
and
1 deletion
pystencils/cpu/cpujit.py
+
2
−
1
View file @
4b7f9e3a
...
...
@@ -376,7 +376,8 @@ def create_function_boilerplate_code(parameter_info, name, ast_node, insert_chec
item_size
=
np_dtype
.
itemsize
aligned
=
any
([
a
.
lhs
.
args
[
2
]
for
a
in
ast_node
.
assignments
if
isinstance
(
a
.
lhs
,
cast_func
)
and
isinstance
(
a
.
lhs
.
dtype
,
VectorType
)])
hasattr
(
a
,
'
lhs
'
)
and
isinstance
(
a
.
lhs
,
cast_func
)
and
hasattr
(
a
.
lhs
,
'
dtype
'
)
and
isinstance
(
a
.
lhs
.
dtype
,
VectorType
)])
if
ast_node
.
instruction_set
and
aligned
:
byte_width
=
ast_node
.
instruction_set
[
'
width
'
]
*
item_size
...
...
This diff is collapsed.
Click to expand it.
pystencils_tests/test_vectorization_specific.py
+
25
−
0
View file @
4b7f9e3a
...
...
@@ -5,6 +5,8 @@ import sympy as sp
import
pystencils
as
ps
from
pystencils.backends.simd_instruction_sets
import
get_supported_instruction_sets
from
pystencils.backends.x86_instruction_sets
import
get_vector_instruction_set_x86
from
pystencils.data_types
import
cast_func
,
VectorType
supported_instruction_sets
=
get_supported_instruction_sets
()
if
get_supported_instruction_sets
()
else
[]
...
...
@@ -49,3 +51,26 @@ def test_vectorized_abs(instruction_set, dtype):
dst
=
np
.
zeros_like
(
arr
)
func
(
g
=
dst
,
f
=
arr
)
np
.
testing
.
assert_equal
(
np
.
sum
(
dst
[
1
:
-
1
,
1
:
-
1
]),
2
**
2
*
2
**
3
)
@pytest.mark.parametrize
(
'
dtype
'
,
(
'
float
'
,
'
double
'
))
@pytest.mark.parametrize
(
'
instruction_set
'
,
supported_instruction_sets
)
def
test_alignment_and_correct_ghost_layers
(
instruction_set
,
dtype
):
itemsize
=
8
if
dtype
==
'
double
'
else
4
alignment
=
get_vector_instruction_set_x86
(
dtype
,
instruction_set
)[
'
width
'
]
*
itemsize
dtype
=
np
.
float64
if
dtype
==
'
double
'
else
np
.
float32
domain_size
=
(
128
,
128
)
dh
=
ps
.
create_data_handling
(
domain_size
,
periodicity
=
(
True
,
True
),
default_target
=
'
cpu
'
)
src
=
dh
.
add_array
(
"
src
"
,
values_per_cell
=
1
,
dtype
=
dtype
,
ghost_layers
=
1
,
alignment
=
alignment
)
dh
.
fill
(
src
.
name
,
1.0
,
ghost_layers
=
True
)
dst
=
dh
.
add_array
(
"
dst
"
,
values_per_cell
=
1
,
dtype
=
dtype
,
ghost_layers
=
1
,
alignment
=
alignment
)
dh
.
fill
(
dst
.
name
,
1.0
,
ghost_layers
=
True
)
update_rule
=
ps
.
Assignment
(
dst
[
0
,
0
],
src
[
0
,
0
])
opt
=
{
'
instruction_set
'
:
instruction_set
,
'
assume_aligned
'
:
True
,
'
nontemporal
'
:
True
,
'
assume_inner_stride_one
'
:
True
}
ast
=
ps
.
create_kernel
(
update_rule
,
target
=
dh
.
default_target
,
cpu_vectorize_info
=
opt
,
ghost_layers
=
0
)
kernel
=
ast
.
compile
()
with
pytest
.
raises
(
ValueError
):
dh
.
run_kernel
(
kernel
)
\ No newline at end of file
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