Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pystencils-benchmark
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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-benchmark
Commits
b7c6dd59
Commit
b7c6dd59
authored
1 year ago
by
Christoph Alt
Browse files
Options
Downloads
Patches
Plain Diff
If openmp is used wrap the likwid markers calls in omp blocks
parent
2bf0e93f
No related branches found
No related tags found
1 merge request
!2
Adding likwid markers
Pipeline
#54698
skipped
Stage: docker-build
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils_benchmark/benchmark.py
+7
-3
7 additions, 3 deletions
pystencils_benchmark/benchmark.py
pystencils_benchmark/templates/main.c
+28
-4
28 additions, 4 deletions
pystencils_benchmark/templates/main.c
with
35 additions
and
7 deletions
pystencils_benchmark/benchmark.py
+
7
−
3
View file @
b7c6dd59
...
...
@@ -6,7 +6,7 @@ from jinja2 import Environment, PackageLoader, StrictUndefined
import
numpy
as
np
from
pystencils.backends.cbackend
import
generate_c
,
get_headers
from
pystencils.astnodes
import
KernelFunction
from
pystencils.astnodes
import
KernelFunction
,
PragmaBlock
from
pystencils.enums
import
Backend
from
pystencils.typing
import
get_base_type
from
pystencils.sympyextensions
import
prod
...
...
@@ -98,7 +98,7 @@ def kernel_main(kernels_ast: List[KernelFunction], *,
Returns:
C code as string
"""
Kernel
=
namedtuple
(
'
Kernel
'
,
[
'
name
'
,
'
constants
'
,
'
fields
'
,
'
call_parameters
'
,
'
call_argument_list
'
])
Kernel
=
namedtuple
(
'
Kernel
'
,
[
'
name
'
,
'
constants
'
,
'
fields
'
,
'
call_parameters
'
,
'
call_argument_list
'
,
'
openmp
'
])
kernels
=
[]
includes
=
set
()
for
kernel
in
kernels_ast
:
...
...
@@ -107,6 +107,8 @@ def kernel_main(kernels_ast: List[KernelFunction], *,
constants
=
[]
fields
=
[]
call_parameters
=
[]
# TODO: Think about it maybe there is a better way to detect openmp
openmp
=
isinstance
(
kernel
.
body
.
args
[
0
],
PragmaBlock
)
for
p
in
kernel
.
get_parameters
():
if
not
p
.
is_field_parameter
:
constants
.
append
((
p
.
symbol
.
name
,
str
(
p
.
symbol
.
dtype
)))
...
...
@@ -139,8 +141,10 @@ def kernel_main(kernels_ast: List[KernelFunction], *,
align
=
0
fields
.
append
((
p
.
field_name
,
dtype
,
elements
,
size
,
offset
,
align
))
call_parameters
.
append
(
p
.
field_name
)
# TODO: Think about openmp detection again
kernels
.
append
(
Kernel
(
name
=
name
,
fields
=
fields
,
constants
=
constants
,
call_parameters
=
call_parameters
,
call_argument_list
=
"
,
"
.
join
(
call_parameters
)))
call_argument_list
=
"
,
"
.
join
(
call_parameters
)
,
openmp
=
openmp
))
includes
.
add
(
name
)
...
...
This diff is collapsed.
Click to expand it.
pystencils_benchmark/templates/main.c
+
28
−
4
View file @
b7c6dd59
...
...
@@ -39,6 +39,9 @@ int main(int argc, char **argv)
{
%
else
%
}
{{
dataType
}}
*
{{
field_name
}}
=
({{
dataType
}}
*
)
malloc
({{
size
}});
{
%
endif
%
}
{
%
if
kernel
.
openmp
%
}
#pragma omp parallel for schedule(static)
{
%
endif
%
}
for
(
unsigned
long
long
i
=
0
;
i
<
{{
elements
}};
++
i
)
{{
field_name
}}[
i
]
=
0
.
23
;
{
%
endfor
%
}
...
...
@@ -50,7 +53,14 @@ int main(int argc, char **argv)
{
%
endfor
%
}
{
%
if
likwid
%
}
{
%
if
kernel
.
openmp
%
}
#pragma omp parallel
{
{
%
endif
%
}
LIKWID_MARKER_REGISTER
(
"{{kernel.name}}"
);
{
%
if
kernel
.
openmp
%
}
}
{
%
endif
%
}
{
%
endif
%
}
for
(
int
warmup
=
1
;
warmup
>=
0
;
--
warmup
)
{
...
...
@@ -58,7 +68,14 @@ int main(int argc, char **argv)
if
(
warmup
==
0
)
{
repeat
=
n_repeat
;
{
%
if
likwid
%
}
{
%
if
kernel
.
openmp
%
}
#pragma omp parallel
{
{
%
endif
%
}
LIKWID_MARKER_START
(
"{{kernel.name}}"
);
{
%
if
kernel
.
openmp
%
}
}
{
%
endif
%
}
{
%
endif
%
}
}
...
...
@@ -80,13 +97,20 @@ int main(int argc, char **argv)
{
%
endif
%
}
}
{
%
for
field_name
,
dataType
,
elements
,
size
,
offset
,
alignment
in
kernel
.
fields
%
}
free
({{
field_name
}});
{
%
endfor
%
}
{
%
if
likwid
%
}
{
%
if
kernel
.
openmp
%
}
#pragma omp parallel
{
{
%
endif
%
}
LIKWID_MARKER_STOP
(
"{{kernel.name}}"
);
{
%
if
kernel
.
openmp
%
}
}
{
%
endif
%
}
{
%
endif
%
}
{
%
for
field_name
,
dataType
,
elements
,
size
,
offset
,
alignment
in
kernel
.
fields
%
}
free
({{
field_name
}});
{
%
endfor
%
}
}
{
%
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