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
Markus Holzer
pystencils
Commits
791a5668
Commit
791a5668
authored
4 years ago
by
Markus Holzer
Browse files
Options
Downloads
Patches
Plain Diff
Fix segfault in kerncraft benchmark
parent
faba3cc4
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#30488
failed
4 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils/kerncraft_coupling/generate_benchmark.py
+18
-5
18 additions, 5 deletions
pystencils/kerncraft_coupling/generate_benchmark.py
pystencils/kerncraft_coupling/templates/benchmark.c
+8
-4
8 additions, 4 deletions
pystencils/kerncraft_coupling/templates/benchmark.c
with
26 additions
and
9 deletions
pystencils/kerncraft_coupling/generate_benchmark.py
+
18
−
5
View file @
791a5668
...
...
@@ -10,8 +10,10 @@ from pystencils.backends.cbackend import generate_c, get_headers
from
pystencils.cpu.cpujit
import
get_compiler_config
,
run_compile_step
from
pystencils.data_types
import
get_base_type
from
pystencils.include
import
get_pystencils_include_path
from
pystencils.integer_functions
import
modulo_ceil
from
pystencils.sympyextensions
import
prod
import
numpy
as
np
def
generate_benchmark
(
ast
,
likwid
=
False
,
openmp
=
False
,
timing
=
False
):
"""
Return C code of a benchmark program for the given kernel.
...
...
@@ -37,7 +39,18 @@ def generate_benchmark(ast, likwid=False, openmp=False, timing=False):
assert
p
.
is_field_pointer
,
"
Benchmark implemented only for kernels with fixed loop size
"
field
=
accessed_fields
[
p
.
field_name
]
dtype
=
str
(
get_base_type
(
p
.
symbol
.
dtype
))
fields
.
append
((
p
.
field_name
,
dtype
,
prod
(
field
.
shape
)))
np_dtype
=
np
.
dtype
(
dtype
)
size_data_type
=
np_dtype
.
itemsize
elements
=
prod
(
field
.
shape
)
align
=
64
required_size
=
size_data_type
*
elements
+
align
size
=
modulo_ceil
(
required_size
,
align
)
assert
align
%
np_dtype
.
itemsize
==
0
offset
=
int
(
-
ast
.
ghost_layers
[
0
][
0
]
%
(
align
/
np_dtype
.
itemsize
))
fields
.
append
((
p
.
field_name
,
dtype
,
elements
,
size
,
offset
))
call_parameters
.
append
(
p
.
field_name
)
header_list
=
get_headers
(
ast
)
...
...
@@ -99,10 +112,10 @@ def run_c_benchmark(ast, inner_iterations, outer_iterations=3, path=None):
compiler_config
=
get_compiler_config
()
compile_cmd
=
[
compiler_config
[
'
command
'
]]
+
compiler_config
[
'
flags
'
].
split
()
compile_cmd
+=
[
*
extra_flags
,
kerncraft_path
/
'
headers
'
/
'
timing.c
'
,
kerncraft_path
/
'
headers
'
/
'
dummy.c
'
,
path
/
'
bench.c
'
,
'
-o
'
,
path
/
'
bench
'
,
str
(
kerncraft_path
/
'
headers
'
/
'
timing.c
'
)
,
str
(
kerncraft_path
/
'
headers
'
/
'
dummy.c
'
)
,
str
(
path
/
'
bench.c
'
)
,
'
-o
'
,
str
(
path
/
'
bench
'
)
,
]
run_compile_step
(
compile_cmd
)
...
...
This diff is collapsed.
Click to expand it.
pystencils/kerncraft_coupling/templates/benchmark.c
+
8
−
4
View file @
791a5668
...
...
@@ -28,11 +28,11 @@ int main(int argc, char **argv)
likwid_markerInit
();
{
%-
endif
%
}
{
%-
for
field_name
,
dataType
,
size
in
fields
%
}
{
%-
for
field_name
,
dataType
,
elements
,
size
,
offset
in
fields
%
}
// Initialization {{field_name}}
double
*
{{
field_name
}}
=
(
double
*
)
aligned_
m
alloc
(
sizeof
({{
dataTyp
e
}})
*
{{
size
}},
64
)
;
for
(
unsigned
long
long
i
=
0
;
i
<
{{
size
}};
++
i
)
double
*
{{
field_name
}}
=
(
double
*
)
aligned_alloc
(
64
,
{{
siz
e
}})
+
{{
offset
}}
;
for
(
unsigned
long
long
i
=
0
;
i
<
{{
elements
}};
++
i
)
{{
field_name
}}[
i
]
=
0
.
23
;
if
(
var_false
)
...
...
@@ -80,7 +80,7 @@ int main(int argc, char **argv)
{{
kernelName
}}({{
call_argument_list
}});
// Dummy calls
{
%-
for
field_name
,
dataType
,
size
in
fields
%
}
{
%-
for
field_name
,
dataType
,
elements
,
size
,
offset
in
fields
%
}
if
(
var_false
)
dummy
((
void
*
){{
field_name
}});
{
%-
endfor
%
}
{
%-
for
constantName
,
dataType
in
constants
%
}
...
...
@@ -105,4 +105,8 @@ int main(int argc, char **argv)
{
%-
if
likwid
%
}
likwid_markerClose
();
{
%-
endif
%
}
{
%-
for
field_name
,
dataType
,
elements
,
size
,
offset
in
fields
%
}
free
({{
field_name
}}
-
{{
offset
}});
{
%-
endfor
%
}
}
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