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
Jonas Plewinski
pystencils
Commits
d676dec0
Commit
d676dec0
authored
Apr 04, 2019
by
Julian Hammer
Browse files
fixed likwid and openmp code generation
parent
6a562914
Changes
2
Hide whitespace changes
Inline
Side-by-side
pystencils/kerncraft_coupling/generate_benchmark.py
View file @
d676dec0
...
...
@@ -2,6 +2,7 @@ from jinja2 import Template
from
pystencils.backends.cbackend
import
generate_c
,
get_headers
from
pystencils.sympyextensions
import
prod
from
pystencils.data_types
import
get_base_type
from
pystencils.astnodes
import
PragmaBlock
benchmark_template
=
Template
(
"""
#include "kerncraft.h"
...
...
@@ -28,7 +29,6 @@ int main(int argc, char **argv)
{
{%- if likwid %}
likwid_markerInit();
likwid_markerThreadInit();
{%- endif %}
{%- for field_name, dataType, size in fields %}
...
...
@@ -56,7 +56,14 @@ int main(int argc, char **argv)
{%- endfor %}
int repeat = atoi(argv[1]);
{%- if likwid %}
{%- if openmp %}
#pragma omp parallel
{
likwid_markerRegisterRegion("loop");
#pragma omp barrier
{%- endif %}
likwid_markerStartRegion("loop");
{%- endif %}
...
...
@@ -75,6 +82,9 @@ int main(int argc, char **argv)
{%- if likwid %}
likwid_markerStopRegion("loop");
{%- if openmp %}
}
{%- endif %}
{%- endif %}
{%- if likwid %}
...
...
@@ -84,7 +94,7 @@ int main(int argc, char **argv)
"""
)
def
generate_benchmark
(
ast
,
likwid
=
False
):
def
generate_benchmark
(
ast
,
likwid
=
False
,
openmp
=
False
):
accessed_fields
=
{
f
.
name
:
f
for
f
in
ast
.
fields_accessed
}
constants
=
[]
fields
=
[]
...
...
@@ -103,8 +113,15 @@ def generate_benchmark(ast, likwid=False):
header_list
=
get_headers
(
ast
)
includes
=
"
\n
"
.
join
([
"#include %s"
%
(
include_file
,)
for
include_file
in
header_list
])
# Strip "#pragma omp parallel" from within kernel, because main function takes care of that
# when likwid and openmp are enabled
if
likwid
and
openmp
:
if
len
(
ast
.
body
.
args
)
>
0
and
isinstance
(
ast
.
body
.
args
[
0
],
PragmaBlock
):
ast
.
body
.
args
[
0
].
pragma_line
=
''
args
=
{
'likwid'
:
likwid
,
'openmp'
:
openmp
,
'kernel_code'
:
generate_c
(
ast
,
dialect
=
'c'
),
'kernelName'
:
ast
.
function_name
,
'fields'
:
fields
,
...
...
pystencils/kerncraft_coupling/kerncraft_interface.py
View file @
d676dec0
...
...
@@ -134,7 +134,7 @@ class PyStencilsKerncraftKernel(kerncraft.kernel.KernelCode):
:param type: can be iaca or likwid.
:param openmp: if true, openmp code will be generated
"""
return
generate_benchmark
(
self
.
kernel_ast
,
likwid
=
type_
==
'likwid'
)
return
generate_benchmark
(
self
.
kernel_ast
,
likwid
=
type_
==
'likwid'
,
openmp
=
openmp
)
class
KerncraftParameters
(
DotDict
):
...
...
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