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
Christoph Alt
pystencils
Commits
5cf6febc
Commit
5cf6febc
authored
May 06, 2021
by
Michael Kuron
Browse files
don't zero cachelines beyond the end of a field
parent
2d5fcf53
Changes
2
Hide whitespace changes
Inline
Side-by-side
pystencils/backends/cbackend.py
View file @
5cf6febc
...
...
@@ -8,7 +8,7 @@ import sympy as sp
from
sympy.core
import
S
from
sympy.logic.boolalg
import
BooleanFalse
,
BooleanTrue
from
pystencils.astnodes
import
KernelFunction
,
Node
from
pystencils.astnodes
import
KernelFunction
,
LoopOverCoordinate
,
Node
from
pystencils.cpu.vectorization
import
vec_all
,
vec_any
,
CachelineSize
from
pystencils.data_types
import
(
PointerType
,
VectorType
,
address_of
,
cast_func
,
create_type
,
get_type_of_expression
,
...
...
@@ -293,7 +293,14 @@ class CBackend:
pre_code
=
''
if
nontemporal
and
'cachelineZero'
in
self
.
_vector_instruction_set
:
pre_code
=
f
"if (((uintptr_t)
{
ptr
}
&
{
CachelineSize
.
mask_symbol
}
) == 0) "
+
"{
\n\t
"
+
\
first_cond
=
f
"((uintptr_t)
{
ptr
}
&
{
CachelineSize
.
mask_symbol
}
) == 0"
offset
=
sp
.
Add
(
*
[
sp
.
Symbol
(
LoopOverCoordinate
.
get_loop_counter_name
(
i
))
*
node
.
lhs
.
args
[
0
].
field
.
spatial_strides
[
i
]
for
i
in
range
(
len
(
node
.
lhs
.
args
[
0
].
field
.
spatial_strides
))])
size
=
sp
.
Mul
(
*
node
.
lhs
.
args
[
0
].
field
.
spatial_shape
)
element_size
=
8
if
data_type
.
base_type
.
base_name
==
'double'
else
4
size_cond
=
f
"(
{
offset
}
+
{
CachelineSize
.
symbol
/
element_size
}
) <
{
size
}
"
pre_code
=
f
"if (
{
first_cond
}
&&
{
size_cond
}
) "
+
"{
\n\t
"
+
\
self
.
_vector_instruction_set
[
'cachelineZero'
].
format
(
ptr
)
+
';
\n
}
\n
'
code
=
self
.
_vector_instruction_set
[
instr
].
format
(
ptr
,
self
.
sympy_printer
.
doprint
(
rhs
),
...
...
pytest.ini
View file @
5cf6febc
...
...
@@ -43,7 +43,7 @@ exclude_lines =
if
__name__
=
= .__main__.:
skip_covered
=
True
fail_under
=
8
8
fail_under
=
8
7
[html]
directory
=
coverage_report
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