Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-codegen
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Christian Heinigk
dune-codegen
Commits
29b60014
Commit
29b60014
authored
5 years ago
by
René Heß
Browse files
Options
Downloads
Patches
Plain Diff
[skip ci] Autotune loop order in tensor contraction
parent
3d7cb6ac
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/dune/codegen/sumfact/transformations.py
+39
-8
39 additions, 8 deletions
python/dune/codegen/sumfact/transformations.py
with
39 additions
and
8 deletions
python/dune/codegen/sumfact/transformations.py
+
39
−
8
View file @
29b60014
...
@@ -9,6 +9,7 @@ from dune.codegen.loopy.transformations.remove_reductions import remove_all_redu
...
@@ -9,6 +9,7 @@ from dune.codegen.loopy.transformations.remove_reductions import remove_all_redu
from
dune.codegen.options
import
get_form_option
,
get_option
from
dune.codegen.options
import
get_form_option
,
get_option
from
dune.codegen.pdelab.geometry
import
world_dimension
from
dune.codegen.pdelab.geometry
import
world_dimension
from
dune.codegen.error
import
CodegenAutotuneError
from
dune.codegen.error
import
CodegenAutotuneError
from
dune.codegen.sumfact.autotune
import
autotune_realization
def
move_zero_assignment_up
(
kernel
,
move_up_inames
):
def
move_zero_assignment_up
(
kernel
,
move_up_inames
):
...
@@ -169,16 +170,46 @@ def reorder_loops_in_tensor_contraction(kernel, iname_order):
...
@@ -169,16 +170,46 @@ def reorder_loops_in_tensor_contraction(kernel, iname_order):
return
kernel
return
kernel
def
tensor_contraction_loop_order_generator
(
kernel
):
dim
=
world_dimension
()
assert
dim
==
3
yield
kernel
indices
=
[
'
l
'
,
'
k
'
,
'
i
'
,
'
j
'
]
import
itertools
for
loop_order
in
itertools
.
permutations
(
indices
):
loop_order
=
''
.
join
(
loop_order
)
new_kernel
=
reorder_loops_in_tensor_contraction
(
kernel
,
loop_order
)
yield
new_kernel
def
simple_autotuner
(
kernel_generator
,
signature
):
# palpo TODO
from
dune.codegen.options
import
set_option
set_option
(
"
autotune_google_benchmark
"
,
True
)
kernel
=
next
(
kernel_generator
)
best_cost
=
autotune_realization
(
kernel
=
kernel
,
signature
=
signature
)
best_kernel
=
kernel
for
kernel
in
kernel_generator
:
cost
=
autotune_realization
(
kernel
=
kernel
,
signature
=
signature
)
if
cost
<
best_cost
:
best_cost
=
cost
best_kernel
=
kernel
return
best_kernel
def
autotune_tensor_contraction_loop_order
(
kernel
,
signature
):
from
dune.codegen.loopy.transformations.matchfma
import
match_fused_multiply_add
kernel
=
match_fused_multiply_add
(
kernel
)
generator
=
tensor_contraction_loop_order_generator
(
kernel
)
return
simple_autotuner
(
generator
,
signature
)
def
sumfact_performance_transformations
(
kernel
,
signature
):
def
sumfact_performance_transformations
(
kernel
,
signature
):
if
kernel
.
name
.
startswith
(
'
sfimpl
'
):
if
kernel
.
name
.
startswith
(
'
sfimpl
'
):
# from dune.codegen.loopy.transformations.matchfma import match_fused_multiply_add
# kernel = autotune_tensor_contraction_loop_order(kernel, signature)
# kernel = match_fused_multiply_add(kernel)
# kernel = reorder_loops_in_tensor_contraction(kernel, 'ijlk')
# from dune.codegen.sumfact.autotune import autotune_realization
# from dune.codegen.options import set_option
# set_option("autotune_google_benchmark", True)
# test = autotune_realization(kernel=kernel, signature=signature)
pass
pass
return
kernel
return
kernel
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