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
Package 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
itischler
pystencils
Commits
0998f2e1
Commit
0998f2e1
authored
6 years ago
by
Martin Bauer
Browse files
Options
Downloads
Patches
Plain Diff
Kerncraft interface: update to work with kerncraft 0.8.0
parent
920a47d5
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils/kerncraft_coupling/kerncraft_interface.py
+17
-6
17 additions, 6 deletions
pystencils/kerncraft_coupling/kerncraft_interface.py
pystencils_tests/test_kerncraft_coupling.py
+4
-1
4 additions, 1 deletion
pystencils_tests/test_kerncraft_coupling.py
with
21 additions
and
7 deletions
pystencils/kerncraft_coupling/kerncraft_interface.py
+
17
−
6
View file @
0998f2e1
...
@@ -3,7 +3,7 @@ from tempfile import TemporaryDirectory
...
@@ -3,7 +3,7 @@ from tempfile import TemporaryDirectory
import
sympy
as
sp
import
sympy
as
sp
from
collections
import
defaultdict
from
collections
import
defaultdict
import
kerncraft
import
kerncraft
import
kerncraft.kerne
l
from
kerncraft.kern
craft
import
KernelCod
e
from
typing
import
Optional
from
typing
import
Optional
from
kerncraft.machinemodel
import
MachineModel
from
kerncraft.machinemodel
import
MachineModel
...
@@ -16,7 +16,7 @@ from pystencils.utils import DotDict
...
@@ -16,7 +16,7 @@ from pystencils.utils import DotDict
import
warnings
import
warnings
class
PyStencilsKerncraftKernel
(
kerncraft
.
kernel
.
KernelCode
):
class
PyStencilsKerncraftKernel
(
KernelCode
):
"""
"""
Implementation of kerncraft
'
s kernel interface for pystencils CPU kernels.
Implementation of kerncraft
'
s kernel interface for pystencils CPU kernels.
Analyses a list of equations assuming they will be executed on a CPU
Analyses a list of equations assuming they will be executed on a CPU
...
@@ -42,6 +42,7 @@ class PyStencilsKerncraftKernel(kerncraft.kernel.KernelCode):
...
@@ -42,6 +42,7 @@ class PyStencilsKerncraftKernel(kerncraft.kernel.KernelCode):
self
.
kernel_ast
=
ast
self
.
kernel_ast
=
ast
self
.
temporary_dir
=
TemporaryDirectory
()
self
.
temporary_dir
=
TemporaryDirectory
()
self
.
_keep_intermediates
=
debug_print
# Loops
# Loops
inner_loops
=
[
l
for
l
in
filtered_tree_iteration
(
ast
,
LoopOverCoordinate
,
stop_type
=
SympyAssignment
)
inner_loops
=
[
l
for
l
in
filtered_tree_iteration
(
ast
,
LoopOverCoordinate
,
stop_type
=
SympyAssignment
)
...
@@ -127,14 +128,24 @@ class PyStencilsKerncraftKernel(kerncraft.kernel.KernelCode):
...
@@ -127,14 +128,24 @@ class PyStencilsKerncraftKernel(kerncraft.kernel.KernelCode):
print
(
"
----------------------------- FLOPS -------------------------------
"
)
print
(
"
----------------------------- FLOPS -------------------------------
"
)
pprint
(
self
.
_flops
)
pprint
(
self
.
_flops
)
def
as_code
(
self
,
type_
=
'
iaca
'
,
openmp
=
False
):
def
as_code
(
self
,
type_
=
'
iaca
'
,
openmp
=
False
,
as_filename
=
False
):
"""
"""
Generate and return compilable source code.
Generate and return compilable source code.
:param type: can be iaca or likwid.
Args:
:param openmp: if true, openmp code will be generated
type_: can be iaca or likwid.
openmp: if true, openmp code will be generated
as_filename:
"""
"""
return
generate_benchmark
(
self
.
kernel_ast
,
likwid
=
type_
==
'
likwid
'
,
openmp
=
openmp
)
code
=
generate_benchmark
(
self
.
kernel_ast
,
likwid
=
type_
==
'
likwid
'
,
openmp
=
openmp
)
if
as_filename
:
fp
,
already_available
=
self
.
_get_intermediate_file
(
'
kernel_{}.c
'
.
format
(
type_
),
machine_and_compiler_dependent
=
False
)
if
not
already_available
:
fp
.
write
(
code
)
return
fp
.
name
else
:
return
code
class
KerncraftParameters
(
DotDict
):
class
KerncraftParameters
(
DotDict
):
...
...
This diff is collapsed.
Click to expand it.
pystencils_tests/test_kerncraft_coupling.py
+
4
−
1
View file @
0998f2e1
...
@@ -18,9 +18,12 @@ INPUT_FOLDER = os.path.join(SCRIPT_FOLDER, "kerncraft_inputs")
...
@@ -18,9 +18,12 @@ INPUT_FOLDER = os.path.join(SCRIPT_FOLDER, "kerncraft_inputs")
@pytest.mark.kernkraft
@pytest.mark.kernkraft
def
test_compilation
():
def
test_compilation
():
machine_file_path
=
os
.
path
.
join
(
INPUT_FOLDER
,
"
default_machine_file.yaml
"
)
machine
=
MachineModel
(
path_to_yaml
=
machine_file_path
)
kernel_file_path
=
os
.
path
.
join
(
INPUT_FOLDER
,
"
2d-5pt.c
"
)
kernel_file_path
=
os
.
path
.
join
(
INPUT_FOLDER
,
"
2d-5pt.c
"
)
with
open
(
kernel_file_path
)
as
kernel_file
:
with
open
(
kernel_file_path
)
as
kernel_file
:
reference_kernel
=
KernelCode
(
kernel_file
.
read
(),
machine
=
No
ne
,
filename
=
kernel_file_path
)
reference_kernel
=
KernelCode
(
kernel_file
.
read
(),
machine
=
machi
ne
,
filename
=
kernel_file_path
)
reference_kernel
.
as_code
(
'
likwid
'
)
reference_kernel
.
as_code
(
'
likwid
'
)
size
=
[
30
,
50
,
3
]
size
=
[
30
,
50
,
3
]
...
...
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