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
e2e4372a
Commit
e2e4372a
authored
12 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Centralize convexification. Better code for get_bounds_checks.
parent
00791241
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
MEMO
+2
-2
2 additions, 2 deletions
MEMO
loopy/codegen/bounds.py
+16
-23
16 additions, 23 deletions
loopy/codegen/bounds.py
loopy/cse.py
+2
-27
2 additions, 27 deletions
loopy/cse.py
loopy/isl_helpers.py
+38
-0
38 additions, 0 deletions
loopy/isl_helpers.py
with
58 additions
and
52 deletions
MEMO
+
2
−
2
View file @
e2e4372a
...
...
@@ -97,14 +97,14 @@ Future ideas
- Try, fix indirect addressing
- Use gists (why do disjoint sets arise?)
- Nested slab decomposition (in conjunction with conditional hoisting) could
generate nested conditional code.
Dealt with
^^^^^^^^^^
- Use gists (why do disjoint sets arise?)
- Automatically verify that all array access is within bounds.
- : (as in, Matlab full-slice) in prefetches
...
...
This diff is collapsed.
Click to expand it.
loopy/codegen/bounds.py
+
16
−
23
View file @
e2e4372a
...
...
@@ -105,43 +105,36 @@ def constraint_to_code(ccm, cns):
from
loopy.symbolic
import
constraint_to_expr
return
"
%s %s 0
"
%
(
ccm
(
constraint_to_expr
(
cns
),
'
i
'
),
comp_op
)
def
filter_necessary_constraints
(
implemented_domain
,
constraints
):
return
[
cns
for
cns
in
constraints
if
not
implemented_domain
.
is_subset
(
isl
.
align_spaces
(
isl
.
BasicSet
.
universe
(
cns
.
get_space
()).
add_constraint
(
cns
),
implemented_domain
))]
def
generate_bounds_checks
(
domain
,
check_inames
,
implemented_domain
):
"""
Will not overapproximate
if check_inames consists of all inames in the domain
.
"""
"""
Will not overapproximate.
"""
if
len
(
check_inames
)
==
domain
.
dim
(
dim_type
.
set
):
assert
check_inames
==
frozenset
(
domain
.
get_var_names
(
dim_type
.
set
))
else
:
domain
=
(
domain
.
eliminate_except
(
check_inames
,
[
dim_type
.
set
])
.
remove_divs
())
domain
=
(
domain
.
eliminate_except
(
check_inames
,
[
dim_type
.
set
])
.
compute_divs
())
if
isinstance
(
domain
,
isl
.
Set
):
bsets
=
domain
.
get_basic_sets
()
if
len
(
bsets
)
==
1
:
domain_bset
,
=
bsets
else
:
if
len
(
bsets
)
!=
1
:
domain
=
domain
.
coalesce
()
bsets
=
domain
.
get_basic_sets
()
if
len
(
bsets
)
=
=
1
:
if
len
(
bsets
)
!
=
1
:
raise
RuntimeError
(
"
domain of inames
'
%s
'
projected onto
'
%s
'
"
"
did not reduce to a single conjunction
"
%
(
"
,
"
.
join
(
domain
.
get_var_names
(
dim_type
.
set
)),
check_inames
))
domain
,
=
bsets
else
:
domain_bset
=
domain
domain
=
domain
domain
=
domain
.
remove_redundancies
()
domain
=
isl
.
Set
.
from_basic_set
(
domain
)
domain
=
isl
.
align_spaces
(
domain
,
implemented_domain
)
domain_bset
=
domain_bset
.
remove_redundancies
(
)
result
=
domain
.
gist
(
implemented_domain
)
return
filter_necessary_constraints
(
implemented_domain
,
domain_bset
.
get_constraints
()
)
from
loopy.isl_helpers
import
convexify
return
convexify
(
result
)
.
get_constraints
()
def
wrap_in_bounds_checks
(
ccm
,
domain
,
check_inames
,
implemented_domain
,
stmt
):
bounds_checks
=
generate_bounds_checks
(
...
...
This diff is collapsed.
Click to expand it.
loopy/cse.py
+
2
−
27
View file @
e2e4372a
...
...
@@ -650,33 +650,8 @@ def precompute(kernel, subst_use, dtype, sweep_inames=[],
storage_axis_names
,
storage_axis_sources
,
sweep_inames
,
invocation_descriptors
)
# {{{ try a few ways to get new_domain to be convex
if
len
(
new_domain
.
get_basic_sets
())
>
1
:
hull_new_domain
=
new_domain
.
simple_hull
()
if
isl
.
Set
.
from_basic_set
(
hull_new_domain
)
<=
new_domain
:
new_domain
=
hull_new_domain
new_domain
=
new_domain
.
coalesce
()
if
len
(
new_domain
.
get_basic_sets
())
>
1
:
hull_new_domain
=
new_domain
.
simple_hull
()
if
isl
.
Set
.
from_basic_set
(
hull_new_domain
)
<=
new_domain
:
new_domain
=
hull_new_domain
if
isinstance
(
new_domain
,
isl
.
Set
):
dom_bsets
=
new_domain
.
get_basic_sets
()
if
len
(
dom_bsets
)
>
1
:
print
"
PIECES:
"
for
dbs
in
dom_bsets
:
print
"
%s
"
%
(
isl
.
Set
.
from_basic_set
(
dbs
).
gist
(
new_domain
))
raise
NotImplementedError
(
"
Substitution
'
%s
'
yielded a non-convex footprint
"
%
subst_name
)
new_domain
,
=
dom_bsets
# }}}
from
loopy.isl_helpers
import
convexify
new_domain
=
convexify
(
new_domain
)
# {{{ set up compute insn
...
...
This diff is collapsed.
Click to expand it.
loopy/isl_helpers.py
+
38
−
0
View file @
e2e4372a
...
...
@@ -277,6 +277,44 @@ def is_nonnegative(expr, over_set):
def
convexify
(
domain
):
"""
Try a few ways to get *domain* to be a BasicSet, i.e.
explicitly convex.
"""
if
isinstance
(
domain
,
isl
.
BasicSet
):
return
domain
dom_bsets
=
domain
.
get_basic_sets
()
if
len
(
dom_bsets
)
==
1
:
domain
,
=
dom_bsets
return
domain
hull_domain
=
domain
.
simple_hull
()
if
isl
.
Set
.
from_basic_set
(
hull_domain
)
<=
domain
:
return
hull_domain
domain
=
domain
.
coalesce
()
dom_bsets
=
domain
.
get_basic_sets
()
if
len
(
domain
.
get_basic_sets
())
==
1
:
domain
,
=
dom_bsets
return
domain
hull_domain
=
domain
.
simple_hull
()
if
isl
.
Set
.
from_basic_set
(
hull_domain
)
<=
domain
:
return
hull_domain
dom_bsets
=
domain
.
get_basic_sets
()
assert
len
(
dom_bsets
)
>
1
print
"
PIECES:
"
for
dbs
in
dom_bsets
:
print
"
%s
"
%
(
isl
.
Set
.
from_basic_set
(
dbs
).
gist
(
domain
))
raise
NotImplementedError
(
"
Could not find convex representation of set
"
)
# vim: foldmethod=marker
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