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
c378ca19
Commit
c378ca19
authored
7 years ago
by
Martin Bauer
Browse files
Options
Downloads
Patches
Plain Diff
Fixes in vectorization to also support float kernels
parent
27cf4f19
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
backends/cbackend.py
+1
-1
1 addition, 1 deletion
backends/cbackend.py
cpu/vectorization.py
+1
-1
1 addition, 1 deletion
cpu/vectorization.py
data_types.py
+3
-4
3 additions, 4 deletions
data_types.py
with
5 additions
and
6 deletions
backends/cbackend.py
+
1
−
1
View file @
c378ca19
...
...
@@ -262,7 +262,7 @@ class CustomSympyPrinter(CCodePrinter):
def
_typed_number
(
self
,
number
,
dtype
):
res
=
self
.
_print
(
number
)
if
dtype
.
is_float
:
if
dtype
.
is_float
()
:
if
dtype
==
self
.
_float_type
:
if
'
.
'
not
in
res
:
res
+=
"
.0f
"
...
...
This diff is collapsed.
Click to expand it.
cpu/vectorization.py
+
1
−
1
View file @
c378ca19
...
...
@@ -35,7 +35,7 @@ def vectorize(kernel_ast: ast.KernelFunction, instruction_set: str = 'avx',
elif
nontemporal
is
True
:
nontemporal
=
all_fields
field_float_dtypes
=
set
(
f
.
dtype
for
f
in
all_fields
if
f
.
dtype
.
is_float
)
field_float_dtypes
=
set
(
f
.
dtype
for
f
in
all_fields
if
f
.
dtype
.
is_float
()
)
if
len
(
field_float_dtypes
)
!=
1
:
raise
NotImplementedError
(
"
Cannot vectorize kernels that contain accesses
"
"
to differently typed floating point fields
"
)
...
...
This diff is collapsed.
Click to expand it.
data_types.py
+
3
−
4
View file @
c378ca19
...
...
@@ -276,6 +276,8 @@ def collate_types(types):
# now we should have a list of basic types - struct types are not yet supported
assert
all
(
type
(
t
)
is
BasicType
for
t
in
types
)
if
any
(
t
.
is_float
()
for
t
in
types
):
types
=
tuple
(
t
for
t
in
types
if
t
.
is_float
())
# use numpy collation -> create type from numpy type -> and, put vector type around if necessary
result_numpy_type
=
np
.
result_type
(
*
(
t
.
numpy_dtype
for
t
in
types
))
result
=
BasicType
(
result_numpy_type
)
...
...
@@ -289,10 +291,7 @@ def get_type_of_expression(expr):
from
pystencils.astnodes
import
ResolvedFieldAccess
expr
=
sp
.
sympify
(
expr
)
if
isinstance
(
expr
,
sp
.
Integer
):
if
expr
==
1
or
expr
==
-
1
:
return
create_type
(
"
int16
"
)
else
:
return
create_type
(
"
int
"
)
return
create_type
(
"
int
"
)
elif
isinstance
(
expr
,
sp
.
Rational
)
or
isinstance
(
expr
,
sp
.
Float
):
return
create_type
(
"
double
"
)
elif
isinstance
(
expr
,
ResolvedFieldAccess
):
...
...
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