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
test map validity checking/errors in map_domain
jdsteve2 committed Aug 11, 2021
commit f5b2257db8f0692ddb46e69787d57b938e4d9a5f
90 changes: 46 additions & 44 deletions test/test_transform.py
Original file line number Diff line number Diff line change
@@ -692,20 +692,22 @@ def test_map_domain_vs_split_iname():
# }}}


# {{{ test_map_domain_with_transform_map_missing_dims
# {{{ test_map_domain_transform_map_validity_and_errors

def test_map_domain_with_transform_map_missing_dims():
# Make sure map_domain works correctly when the mapping doesn't include
# all the dims in the domain.
def test_map_domain_transform_map_validity_and_errors():

# {{{ Make kernel

knl = lp.make_kernel(
[
"[nx,nt] -> {[x, y, z, t]: 0 <= x,y,z < nx and 0 <= t < nt}",
"[m] -> {[j]: 0 <= j < m}",
],
"""
a[y,x,t,z] = b[y,x,t,z] {id=stmta}
for j
<>temp = j {dep=stmta}
end
""",
lang_version=(2018, 2),
)
@@ -714,6 +716,9 @@ def test_map_domain_with_transform_map_missing_dims():

# }}}

# Make sure map_domain works correctly when the mapping doesn't include
# all the dims in the domain.

# {{{ Apply domain change mapping

knl_map_dom = ref_knl # loop priority goes away, deps stay
@@ -729,10 +734,10 @@ def test_map_domain_with_transform_map_missing_dims():
"y = y_new"
"}")

# Call map_domain to transform kernel
# Call map_domain to transform kernel; this should not produce an error
knl_map_dom = lp.map_domain(knl_map_dom, transform_map)

# Prioritize loops (prio should eventually be updated in map_domain?)
# Prioritize loops (prio should eventually be updated in map_domain)
try:
# Use constrain_loop_nesting if it's available
desired_prio = "x, t_outer, t_inner, z, y_new"
@@ -780,9 +785,7 @@ def test_map_domain_with_transform_map_missing_dims():

# }}}

# {{{ Make sure there's an error if transform map contains *extra* dims
# Note, this is only okay if transform map 'in' dims don't match *any*
# domain inames, in which case nothing happens.
# {{{ Make sure we error on a map that is not bijective

# Not bijective
transform_map = isl.BasicMap(
@@ -798,43 +801,42 @@ def test_map_domain_with_transform_map_missing_dims():
except LoopyError as err:
assert "map must be bijective" in str(err)

# Bijective and rogue dim
# (with some inames missing from in-dims, which would otherwise be okay)
transform_map = isl.BasicMap(
"[nx,nt] -> {[t, y, rogue] -> [t_new, y_new, rogue_new]: "
"y = y_new and t = t_new and rogue = rogue_new"
"}")

try:
knl_map_dom = lp.map_domain(knl_map_dom, transform_map)
raise AssertionError()
except LoopyError as err:
assert (
"attempts to map variables that are not present in domain" in str(err))

# Bijective and rogue dim
# (with all inames present in in-dims)
transform_map = isl.BasicMap(
"[nx,nt] -> {[t, y, x, z, rogue] -> [t_new, y_new, x_new, z_new, rogue_new]:"
"y = y_new and t = t_new and x = x_new and z = z_new and rogue = rogue_new"
"}")

try:
knl_map_dom = lp.map_domain(knl_map_dom, transform_map)
raise AssertionError()
except LoopyError as err:
assert (
"attempts to map variables that are not present in domain" in str(err))
# }}}

# Bijective and rogue dim with *no* inames present in domain
# (allowed but does nothing)
transform_map = isl.BasicMap(
"[nx,nt] -> {[rogue] -> [rogue_new]: "
"rogue = rogue_new"
"}")
# {{{ Make sure there's an error if transform map does not apply to
# exactly one domain.

test_maps = [
# Map where some inames match exactly one domain but there's also a
# rogue dim
isl.BasicMap(
"[nx,nt] -> {[t, y, rogue] -> [t_new, y_new, rogue_new]: "
"y = y_new and t = t_new and rogue = rogue_new"
"}"),
# Map where all inames match exactly one domain but there's also a
# rogue dim
isl.BasicMap(
"[nx,nt] -> {[t, y, x, z, rogue] -> "
"[t_new, y_new, x_new, z_new, rogue_new]: "
"y = y_new and t = t_new and x = x_new and z = z_new "
"and rogue = rogue_new"
"}"),
# Map where no inames match any domain
isl.BasicMap(
"[nx,nt] -> {[rogue] -> [rogue_new]: "
"rogue = rogue_new"
"}"),
]

# This should not raise an error
knl_map_dom = lp.map_domain(knl_map_dom, transform_map)
for transform_map in test_maps:
try:
knl_map_dom = lp.map_domain(knl_map_dom, transform_map)
raise AssertionError()
except LoopyError as err:
assert (
"was applicable to 0 domains. "
"Transform map must be applicable to exactly one domain."
in str(err))

# }}}