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
Jonas Plewinski
pystencils
Commits
9abd0e4a
Commit
9abd0e4a
authored
Mar 15, 2019
by
Martin Bauer
Browse files
use SIMD inverse sqrt approximation when available
parent
5ad56d04
Changes
2
Hide whitespace changes
Inline
Side-by-side
backends/cbackend.py
View file @
9abd0e4a
...
...
@@ -330,7 +330,10 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
elif
expr
.
func
==
fast_sqrt
:
return
"({})"
.
format
(
self
.
_print
(
sp
.
sqrt
(
expr
.
args
[
0
])))
elif
expr
.
func
==
fast_inv_sqrt
:
return
"({})"
.
format
(
self
.
_print
(
1
/
sp
.
sqrt
(
expr
.
args
[
0
])))
if
self
.
instruction_set
[
'rsqrt'
]:
return
self
.
instruction_set
[
'rsqrt'
].
format
(
self
.
_print
(
expr
.
args
[
0
]))
else
:
return
"({})"
.
format
(
self
.
_print
(
1
/
sp
.
sqrt
(
expr
.
args
[
0
])))
return
super
(
VectorizedCustomSympyPrinter
,
self
).
_print_Function
(
expr
)
def
_print_And
(
self
,
expr
):
...
...
backends/simd_instruction_sets.py
View file @
9abd0e4a
...
...
@@ -93,6 +93,16 @@ def get_vector_instruction_set(data_type='double', instruction_set='avx'):
result
[
'bool'
]
=
"__m%dd"
%
(
bit_width
,)
result
[
'headers'
]
=
headers
[
instruction_set
]
if
instruction_set
==
'avx512'
and
data_type
==
'double'
:
result
[
'rsqrt'
]
=
"_mm512_rsqrt14_pd({0})"
elif
instruction_set
==
'avx512'
and
data_type
==
'float'
:
result
[
'rsqrt'
]
=
"_mm512_rsqrt14_ps({0})"
elif
instruction_set
==
'avx'
and
data_type
==
'float'
:
result
[
'rsqrt'
]
=
"_mm256_rsqrt_ps({0})"
else
:
result
[
'rsqrt'
]
=
None
return
result
...
...
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