Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Stephan Seitz
pystencils
Commits
800eaf6c
Commit
800eaf6c
authored
Oct 01, 2019
by
Martin Bauer
Browse files
Merge branch 'master' into 'ConditionalFieldAccess'
# Conflicts: # pystencils/data_types.py
parents
8dfe844c
ae69d3d3
Pipeline
#18637
passed with stage
in 2 minutes and 59 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
pystencils/astnodes.py
View file @
800eaf6c
...
@@ -465,11 +465,13 @@ class LoopOverCoordinate(Node):
...
@@ -465,11 +465,13 @@ class LoopOverCoordinate(Node):
@
staticmethod
@
staticmethod
def
get_loop_counter_symbol
(
coordinate_to_loop_over
):
def
get_loop_counter_symbol
(
coordinate_to_loop_over
):
return
TypedSymbol
(
LoopOverCoordinate
.
get_loop_counter_name
(
coordinate_to_loop_over
),
'int'
)
return
TypedSymbol
(
LoopOverCoordinate
.
get_loop_counter_name
(
coordinate_to_loop_over
),
'int'
,
nonnegative
=
True
)
@
staticmethod
@
staticmethod
def
get_block_loop_counter_symbol
(
coordinate_to_loop_over
):
def
get_block_loop_counter_symbol
(
coordinate_to_loop_over
):
return
TypedSymbol
(
LoopOverCoordinate
.
get_block_loop_counter_name
(
coordinate_to_loop_over
),
'int'
)
return
TypedSymbol
(
LoopOverCoordinate
.
get_block_loop_counter_name
(
coordinate_to_loop_over
),
'int'
,
nonnegative
=
True
)
@
property
@
property
def
loop_counter_symbol
(
self
):
def
loop_counter_symbol
(
self
):
...
@@ -503,7 +505,7 @@ class SympyAssignment(Node):
...
@@ -503,7 +505,7 @@ class SympyAssignment(Node):
def
__init__
(
self
,
lhs_symbol
,
rhs_expr
,
is_const
=
True
):
def
__init__
(
self
,
lhs_symbol
,
rhs_expr
,
is_const
=
True
):
super
(
SympyAssignment
,
self
).
__init__
(
parent
=
None
)
super
(
SympyAssignment
,
self
).
__init__
(
parent
=
None
)
self
.
_lhs_symbol
=
lhs_symbol
self
.
_lhs_symbol
=
lhs_symbol
self
.
rhs
=
sp
.
s
i
mp
l
ify
(
rhs_expr
)
self
.
rhs
=
sp
.
s
y
mpify
(
rhs_expr
)
self
.
_is_const
=
is_const
self
.
_is_const
=
is_const
self
.
_is_declaration
=
self
.
__is_declaration
()
self
.
_is_declaration
=
self
.
__is_declaration
()
...
...
pystencils/cpu/kernelcreation.py
View file @
800eaf6c
...
@@ -42,12 +42,11 @@ def create_kernel(assignments: AssignmentOrAstNodeList, function_name: str = "ke
...
@@ -42,12 +42,11 @@ def create_kernel(assignments: AssignmentOrAstNodeList, function_name: str = "ke
Returns:
Returns:
AST node representing a function, that can be printed as C or CUDA code
AST node representing a function, that can be printed as C or CUDA code
"""
"""
def
type_symbol
(
term
):
def
type_symbol
(
term
):
if
isinstance
(
term
,
Field
.
Access
)
or
isinstance
(
term
,
TypedSymbol
):
if
isinstance
(
term
,
Field
.
Access
)
or
isinstance
(
term
,
TypedSymbol
):
return
term
return
term
elif
isinstance
(
term
,
sp
.
Symbol
):
elif
isinstance
(
term
,
sp
.
Symbol
):
if
not
hasattr
(
type_info
,
'__getitem__'
):
if
isinstance
(
type_info
,
str
)
or
not
hasattr
(
type_info
,
'__getitem__'
):
return
TypedSymbol
(
term
.
name
,
create_type
(
type_info
))
return
TypedSymbol
(
term
.
name
,
create_type
(
type_info
))
else
:
else
:
return
TypedSymbol
(
term
.
name
,
type_info
[
term
.
name
])
return
TypedSymbol
(
term
.
name
,
type_info
[
term
.
name
])
...
...
pystencils/data_types.py
View file @
800eaf6c
...
@@ -240,6 +240,10 @@ class TypedSymbol(sp.Symbol):
...
@@ -240,6 +240,10 @@ class TypedSymbol(sp.Symbol):
def
canonical
(
self
):
def
canonical
(
self
):
return
self
return
self
@
property
def
reversed
(
self
):
return
self
def
create_type
(
specification
):
def
create_type
(
specification
):
"""Creates a subclass of Type according to a string or an object of subclass Type.
"""Creates a subclass of Type according to a string or an object of subclass Type.
...
...
pystencils/simp/assignment_collection.py
View file @
800eaf6c
...
@@ -111,6 +111,7 @@ class AssignmentCollection:
...
@@ -111,6 +111,7 @@ class AssignmentCollection:
"Not in SSA form - same symbol assigned multiple times"
"Not in SSA form - same symbol assigned multiple times"
return
bound_symbols_set
return
bound_symbols_set
@
property
def
free_fields
(
self
):
def
free_fields
(
self
):
"""All fields accessed in the assignment collection, which do not occur as left hand sides in any assignment."""
"""All fields accessed in the assignment collection, which do not occur as left hand sides in any assignment."""
return
{
s
.
field
for
s
in
self
.
free_symbols
if
hasattr
(
s
,
'field'
)}
return
{
s
.
field
for
s
in
self
.
free_symbols
if
hasattr
(
s
,
'field'
)}
...
...
pystencils_tests/test_vectorization.py
View file @
800eaf6c
...
@@ -46,6 +46,7 @@ def test_inplace_update():
...
@@ -46,6 +46,7 @@ def test_inplace_update():
kernel
(
f
=
arr
)
kernel
(
f
=
arr
)
np
.
testing
.
assert_equal
(
arr
,
2
)
np
.
testing
.
assert_equal
(
arr
,
2
)
def
test_vectorization_fixed_size
():
def
test_vectorization_fixed_size
():
configurations
=
[]
configurations
=
[]
# Fixed size - multiple of four
# Fixed size - multiple of four
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment