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
Wiki
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
Ben Sepanski
loopy
Commits
43cc6dbd
Commit
43cc6dbd
authored
13 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Use straight integer division if isl can show the operands are nonnegative.
parent
28e5c125
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
MEMO
+3
-3
3 additions, 3 deletions
MEMO
loopy/isl_helpers.py
+17
-0
17 additions, 0 deletions
loopy/isl_helpers.py
loopy/symbolic.py
+10
-4
10 additions, 4 deletions
loopy/symbolic.py
with
30 additions
and
7 deletions
MEMO
+
3
−
3
View file @
43cc6dbd
...
@@ -41,9 +41,6 @@ To-do
...
@@ -41,9 +41,6 @@ To-do
- Automatically generate testing code vs. sequential.
- Automatically generate testing code vs. sequential.
- If isl can prove that all operands are positive, may use '/' instead of
'floor_div'.
- Fix all tests
- Fix all tests
- Deal with equality constraints.
- Deal with equality constraints.
...
@@ -86,6 +83,9 @@ Future ideas
...
@@ -86,6 +83,9 @@ Future ideas
Dealt with
Dealt with
^^^^^^^^^^
^^^^^^^^^^
- If isl can prove that all operands are positive, may use '/' instead of
'floor_div'.
- For forced workgroup sizes: check that at least one iname
- For forced workgroup sizes: check that at least one iname
maps to them.
maps to them.
...
...
This diff is collapsed.
Click to expand it.
loopy/isl_helpers.py
+
17
−
0
View file @
43cc6dbd
...
@@ -227,4 +227,21 @@ def duplicate_axes(isl_obj, duplicate_inames, new_inames):
...
@@ -227,4 +227,21 @@ def duplicate_axes(isl_obj, duplicate_inames, new_inames):
def
is_nonnegative
(
expr
,
over_set
):
space
=
over_set
.
get_space
()
from
loopy.symbolic
import
aff_from_expr
try
:
aff
=
aff_from_expr
(
space
,
-
expr
-
1
)
except
:
return
None
expr_neg_set
=
isl
.
BasicSet
.
universe
(
space
).
add_constraint
(
isl
.
Constraint
.
inequality_from_aff
(
aff
))
return
over_set
.
intersect
(
expr_neg_set
).
is_empty
()
# vim: foldmethod=marker
# vim: foldmethod=marker
This diff is collapsed.
Click to expand it.
loopy/symbolic.py
+
10
−
4
View file @
43cc6dbd
...
@@ -355,10 +355,16 @@ class LoopyCCodeMapper(CCodeMapper):
...
@@ -355,10 +355,16 @@ class LoopyCCodeMapper(CCodeMapper):
raise
RuntimeError
(
"
nothing known about variable
'
%s
'"
%
expr
.
aggregate
.
name
)
raise
RuntimeError
(
"
nothing known about variable
'
%s
'"
%
expr
.
aggregate
.
name
)
def
map_floor_div
(
self
,
expr
,
prec
):
def
map_floor_div
(
self
,
expr
,
prec
):
if
isinstance
(
expr
.
denominator
,
int
)
and
expr
.
denominator
>
0
:
from
loopy.isl_helpers
import
is_nonnegative
return
(
"
int_floor_div_pos_b(%s, %s)
"
num_nonneg
=
is_nonnegative
(
expr
.
numerator
,
self
.
kernel
.
domain
)
%
(
self
.
rec
(
expr
.
numerator
,
PREC_NONE
),
den_nonneg
=
is_nonnegative
(
expr
.
denominator
,
self
.
kernel
.
domain
)
expr
.
denominator
))
if
den_nonneg
:
if
num_nonneg
:
return
CCodeMapper
.
map_quotient
(
self
,
expr
,
prec
)
else
:
return
(
"
int_floor_div_pos_b(%s, %s)
"
%
(
self
.
rec
(
expr
.
numerator
,
PREC_NONE
),
expr
.
denominator
))
else
:
else
:
return
(
"
int_floor_div(%s, %s)
"
return
(
"
int_floor_div(%s, %s)
"
%
(
self
.
rec
(
expr
.
numerator
,
PREC_NONE
),
%
(
self
.
rec
(
expr
.
numerator
,
PREC_NONE
),
...
...
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