Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Markus Holzer
pystencils
Commits
dced5877
Commit
dced5877
authored
Mar 24, 2021
by
Markus Holzer
Browse files
Add type conversion for SP types
parent
24dde405
Pipeline
#31124
failed with stage
in 16 minutes and 30 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
pystencils/kernelcreation.py
View file @
dced5877
...
...
@@ -12,7 +12,8 @@ from pystencils.gpucuda.indexing import indexing_creator_from_params
from
pystencils.simp.assignment_collection
import
AssignmentCollection
from
pystencils.stencil
import
direction_string_to_offset
,
inverse_direction_string
from
pystencils.transformations
import
(
loop_blocking
,
move_constants_before_loop
,
remove_conditionals_in_staggered_kernel
)
loop_blocking
,
move_constants_before_loop
,
remove_conditionals_in_staggered_kernel
,
replace_data_type_of_typed_symbols
)
def
create_kernel
(
assignments
,
...
...
@@ -88,6 +89,8 @@ def create_kernel(assignments,
split_groups
=
assignments
.
simplification_hints
[
'split_groups'
]
assignments
=
assignments
.
all_assignments
assignments
=
replace_data_type_of_typed_symbols
(
assignments
,
data_type
)
# ---- Creating ast
if
target
==
'cpu'
:
from
pystencils.cpu
import
create_kernel
...
...
pystencils/transformations.py
View file @
dced5877
...
...
@@ -1101,6 +1101,15 @@ def remove_conditionals_in_staggered_kernel(function_node: ast.KernelFunction, i
move_constants_before_loop
(
function_node
.
body
)
cleanup_blocks
(
function_node
.
body
)
def
replace_data_type_of_typed_symbols
(
assignments
,
data_type
):
"""changes the data types of the lhs of assignments which are already specified as TypedSymbol. This is needed
if the Assignments are already typed to double but the kernel is created for single precision"""
for
i
,
assignment
in
enumerate
(
assignments
):
if
type
(
assignment
.
lhs
)
is
TypedSymbol
and
assignment
.
lhs
.
dtype
!=
data_type
:
assignments
[
i
]
=
Assignment
(
TypedSymbol
(
assignments
[
i
].
lhs
.
name
,
data_type
),
assignments
[
i
].
rhs
)
return
assignments
# --------------------------------------- Helper Functions -------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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