Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
loopy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Klöckner
loopy
Commits
00f0b96b
Commit
00f0b96b
authored
12 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Implement (untested) link_inames.
parent
bdf07733
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
MEMO
+6
-0
6 additions, 0 deletions
MEMO
doc/reference.rst
+6
-0
6 additions, 0 deletions
doc/reference.rst
loopy/__init__.py
+87
-0
87 additions, 0 deletions
loopy/__init__.py
with
99 additions
and
0 deletions
MEMO
+
6
−
0
View file @
00f0b96b
...
...
@@ -48,6 +48,12 @@ To-do
- Kernel fusion
- rename iname
- delete unused inames
- link_inames
- ExpandingIdentityMapper
extract_subst -> needs WalkMapper
padding
...
...
This diff is collapsed.
Click to expand it.
doc/reference.rst
+
6
−
0
View file @
00f0b96b
...
...
@@ -163,6 +163,12 @@ Wrangling inames
.. autofunction:: duplicate_inames
.. autofunction:: link_inames
.. autofunction:: rename_inames
.. autofunction:: delete_unused_inames
Dealing with Substitution Rules
-------------------------------
...
...
This diff is collapsed.
Click to expand it.
loopy/__init__.py
+
87
−
0
View file @
00f0b96b
...
...
@@ -527,6 +527,7 @@ def duplicate_inames(knl, inames, within, new_inames=None, suffix=None,
knl
=
knl
.
copy
(
domains
=
domch
.
get_domains_with
(
duplicate_axes
(
domch
.
domain
,
[
old_iname
],
[
new_iname
])))
# }}}
# {{{ change the inames in the code
...
...
@@ -552,6 +553,92 @@ def duplicate_inames(knl, inames, within, new_inames=None, suffix=None,
# }}}
# {{{ link inames
def
link_inames
(
knl
,
inames
,
new_iname
,
within
=
None
,
tag
=
None
):
# {{{ normalize arguments
if
isinstance
(
inames
,
str
):
inames
=
inames
.
split
(
"
,
"
)
new_iname
=
knl
.
get_var_name_generator
()(
new_iname
)
# }}}
# {{{ ensure that each iname is used at most once in each instruction
inames_set
=
set
(
inames
)
for
insn
in
knl
.
instructions
:
insn_inames
=
knl
.
insn_inames
(
insn
.
id
)
|
insn
.
reduction_inames
()
if
len
(
insn_inames
&
inames_set
)
>
1
:
raise
RuntimeError
(
"
To-be-linked inames
'
%s
'
are used in
"
"
instruction
'
%s
'
. No more than one such iname can
"
"
be used in one instruction.
"
%
(
"
,
"
.
join
(
insn_inames
&
inames_set
),
insn
.
id
))
# }}}
from
loopy.kernel
import
DomainChanger
domch
=
DomainChanger
(
knl
,
inames
)
# {{{ ensure that projections are identical
unrelated_dom_inames
=
list
(
set
(
domch
.
domain
.
get_var_names
(
dim_type
.
set
))
-
inames_set
)
projections
=
[
domch
.
domain
.
project_out_except
(
unrelated_dom_inames
+
[
iname
],
dim_type
.
set
)
for
iname
in
inames
]
from
pytools
import
all_equal
if
not
all_equal
(
projections
):
raise
RuntimeError
(
"
Inames cannot be linked because their domain
"
"
constraints are not the same.
"
)
# }}}
# change the domain
from
loopy.isl_helpers
import
duplicate_axes
knl
=
knl
.
copy
(
domains
=
domch
.
get_domains_with
(
duplicate_axes
(
domch
.
domain
,
[
inames
[
0
]],
[
new_iname
])))
# {{{ change the code
subst_dict
=
dict
((
iname
,
new_iname
)
for
iname
in
inames
)
from
loopy.context_matching
import
parse_stack_match
within
=
parse_stack_match
(
within
)
from
pymbolic.mapper.substitutor
import
make_subst_func
ijoin
=
ExpandingSubstitutionMapper
(
knl
,
within
,
make_subst_func
(
subst_dict
))
knl
=
ijoin
.
map_kernel
(
knl
)
# }}}
knl
=
knl
.
delete_unused_inames
(
knl
,
inames
)
if
tag
is
not
None
:
knl
=
tag_inames
(
knl
,
{
new_iname
:
tag
})
return
knl
# }}}
# {{{ delete unused inames
def
delete_unused_inames
(
knl
,
inames
=
None
):
from
warnings
import
warn
warn
(
"
delete_unused_inames is unimplemented
"
)
return
knl
# }}}
# {{{ convenience: add_prefetch
# {{{ process footprint_subscripts
...
...
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