Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map domain transformation v2 #478

Merged
merged 44 commits into from
Sep 6, 2021
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f719cfb
add map_domain to loopy init
jdsteve2 Aug 5, 2021
2780237
copy in map_domain funcs from old branch (add-map-domain-transformation)
jdsteve2 Aug 5, 2021
e5edf40
define add_and_name_isl_dims and add_eq_isl_constraint_from_names loc…
jdsteve2 Aug 5, 2021
c6320d8
define ensure_dim_names_match_and_align locally for now (previously w…
jdsteve2 Aug 5, 2021
34b7d8f
remove FIXME now that dim_type usage is consistent
jdsteve2 Aug 10, 2021
62d711b
add better encapsulation for case where domain map has fewer dims tha…
jdsteve2 Aug 10, 2021
05acfbe
improve var names and error message related to mismatching of transfo…
jdsteve2 Aug 10, 2021
8b3195f
test map_domain cases where there is a mismatch between the inames in…
jdsteve2 Aug 10, 2021
6ee3cf0
enforce that transform map in map_domain must apply to exactly one do…
jdsteve2 Aug 11, 2021
f5b2257
test map validity checking/errors in map_domain
jdsteve2 Aug 11, 2021
fddd305
remove map applicability logic from process_set
jdsteve2 Aug 11, 2021
be524ff
update expected error string for map_domain test
jdsteve2 Aug 11, 2021
3add15b
Merge branch 'main' into map-domain-transformation-v2
jdsteve2 Aug 13, 2021
e5b765c
remove arg from map_domain
jdsteve2 Aug 13, 2021
c0a613c
in map_domain, error if there are any loop priorities/nest constraint…
jdsteve2 Aug 13, 2021
88ebe1a
add test for map_domain error when there are any loop priorities/nest…
jdsteve2 Aug 13, 2021
13356df
in map_domain, rename isl_map->transform_map; add docstring
jdsteve2 Aug 14, 2021
ab6076a
clean up code for map_domain; clarify error message a bit
jdsteve2 Aug 27, 2021
d710f8d
add map_domain test for handling of case where stmt.within_inames con…
jdsteve2 Aug 27, 2021
48e2c9a
clarify comment in map_domain
jdsteve2 Aug 27, 2021
6e7951a
remove fixme
jdsteve2 Aug 28, 2021
061a8ec
clean up and document _apply_identity_for_missing_map_dims
jdsteve2 Aug 28, 2021
fc0e265
document _error_if_any_iname_in_constraint
jdsteve2 Aug 28, 2021
aee9c83
minor changes to error messages in _MapDomainMapper and _find_aff_sub…
jdsteve2 Aug 28, 2021
468819d
vim fold markers for map_domain and associated functions
jdsteve2 Aug 28, 2021
1073f99
final cleanup of map_domain functions
jdsteve2 Aug 28, 2021
e2ff759
Update loopy/transform/iname.py
jdsteve2 Aug 31, 2021
4ce6c7a
Update loopy/transform/iname.py
jdsteve2 Aug 31, 2021
dbc3954
Merge branch 'main' into map-domain-transformation-v2
jdsteve2 Aug 31, 2021
a1534bd
move add_and_name_isl_dims, add_eq_isl_constraint_from_names, and fin…
jdsteve2 Aug 31, 2021
3281b76
rename isl_map to isl_obj when sets are also allowed; remove comments…
jdsteve2 Aug 31, 2021
c7ac1f2
docstrings for add_and_name_isl_dims, add_eq_isl_constraint_from_name…
jdsteve2 Aug 31, 2021
693ee86
remove unnecessary variable renaming in add_and_name_dims
jdsteve2 Aug 31, 2021
b8c3400
since find_and_rename_dim is only used for one dim type at a time, ma…
jdsteve2 Aug 31, 2021
9801d1c
more detailed documentation for _apply_identity_for_missing_map_dims
jdsteve2 Aug 31, 2021
09703eb
in map_domain, don't recompute subst_from_map for no reason
jdsteve2 Aug 31, 2021
3d24d43
use auto_test_vs_ref in test_map_domain_vs_split_iname
jdsteve2 Aug 31, 2021
6594873
use get_attr instead of try/except to check for loop_nest_constraints…
jdsteve2 Aug 31, 2021
9404594
shrink problem size to make test_map_domain_transform_map_validity_an…
jdsteve2 Aug 31, 2021
8188649
use same loop prioritization regardless of whether we're using priori…
jdsteve2 Sep 1, 2021
434f04b
further clarification in comments about purpose of some map-domain tests
jdsteve2 Sep 1, 2021
332ebf5
tell pylint to chill out about a missing attribute
jdsteve2 Sep 1, 2021
6e1f1d9
tell pylint to chill out about a missing attribute
jdsteve2 Sep 1, 2021
19a3802
fixing merge conflicts
jdsteve2 Sep 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improve var names and error message related to mismatching of transfo…
…rm map and inames domain
jdsteve2 committed Aug 10, 2021
commit 05acfbee1f4626e16d458893cb09a9ee23ecc94c
41 changes: 23 additions & 18 deletions loopy/transform/iname.py
Original file line number Diff line number Diff line change
@@ -2022,8 +2022,6 @@ def map_domain(kernel, isl_map, within=None):
# FIXME: Document

# FIXME: Support within
# FIXME: Right now, this requires all inames in a domain (or none) to
# be mapped. That makes this awkward to use.

# {{{ within processing (disabled for now)
if within is not None:
@@ -2044,8 +2042,8 @@ def map_domain(kernel, isl_map, within=None):
if not isl_map.is_bijective():
raise LoopyError("isl_map must be bijective")

new_inames = frozenset(isl_map.get_var_dict(dim_type.out))
old_inames = frozenset(isl_map.get_var_dict(dim_type.in_))
transform_map_out_dims = frozenset(isl_map.get_var_dict(dim_type.out))
transform_map_in_dims = frozenset(isl_map.get_var_dict(dim_type.in_))

# {{{ solve for representation of old inames in terms of new

@@ -2055,7 +2053,7 @@ def map_domain(kernel, isl_map, within=None):

from loopy.symbolic import aff_to_expr
from pymbolic import var
for iname in old_inames:
for iname in transform_map_in_dims:
substitutions[iname] = aff_to_expr(
_find_aff_subst_from_map(iname, isl_map))
var_substitutions[var(iname)] = aff_to_expr(
@@ -2066,20 +2064,27 @@ def map_domain(kernel, isl_map, within=None):

# }}}

def process_set(s):
def process_iname_dom(s):
# Make sure the inames we're transforming are all present in the domain
# if not transform_map_in_dims.issubset(frozenset(s.get_var_dict())):
# raise LoopyError("transform map %s attempts to map inames "
# "not present in domain %s. Transform map input inames "
# "must be a subset of the domain inames."
# % (isl_map, s))

var_dict = s.get_var_dict()

overlap = old_inames & frozenset(var_dict)
overlap = transform_map_in_dims & frozenset(var_dict)

if not overlap:
# inames in s are not present in transform map, don't change s
return s

if len(overlap) != len(old_inames):
raise LoopyError("loop domain '%s' involves a part "
"of the map domain inames. Domains must "
"either involve all or none of the map domain "
"inames." % s)
if len(overlap) != len(transform_map_in_dims):
raise LoopyError(
"Transform map %s attempts to map variables that are not present "
"in domain %s. This is only allowed if *none* of the mapped "
"variables are found in the domain." % (isl_map, s))

# {{{ align dims of isl_map and s

@@ -2137,22 +2142,22 @@ def process_set(s):

# FIXME: Revive _project_out_only_if_all_instructions_in_within

new_domains = [process_set(dom) for dom in kernel.domains]
new_domains = [process_iname_dom(dom) for dom in kernel.domains]

# {{{ update within_inames

new_insns = []
for insn in kernel.instructions:
overlap = old_inames & insn.within_inames
overlap = transform_map_in_dims & insn.within_inames
if overlap and within(kernel, insn):
if len(overlap) != len(old_inames):
if len(overlap) != len(transform_map_in_dims):
raise LoopyError("instruction '%s' is within only a part "
"of the map domain inames. Instructions must "
"either be within all or none of the map domain "
"inames." % insn.id)

insn = insn.copy(
within_inames=(insn.within_inames - old_inames) | new_inames)
insn = insn.copy(within_inames=(
insn.within_inames - transform_map_in_dims) | transform_map_out_dims)
else:
# leave insn unmodified
pass
@@ -2169,7 +2174,7 @@ def process_set(s):
rule_mapping_context = SubstitutionRuleMappingContext(
kernel.substitutions, kernel.get_var_name_generator())
ins = _MapDomainMapper(rule_mapping_context, within,
new_inames, substitutions)
transform_map_out_dims, substitutions)

kernel = ins.map_kernel(kernel)
kernel = rule_mapping_context.finish_kernel(kernel)