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
91be1b94
Commit
91be1b94
authored
12 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Improve code generation for constants, 'f' vs no trailing 'f', integer vs non-integer.
parent
76de8414
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
MEMO
+3
-1
3 additions, 1 deletion
MEMO
loopy/codegen/bounds.py
+2
-2
2 additions, 2 deletions
loopy/codegen/bounds.py
loopy/codegen/expression.py
+183
-79
183 additions, 79 deletions
loopy/codegen/expression.py
loopy/codegen/instruction.py
+10
-3
10 additions, 3 deletions
loopy/codegen/instruction.py
with
198 additions
and
85 deletions
MEMO
+
3
−
1
View file @
91be1b94
...
...
@@ -65,7 +65,6 @@ To-do
- Scalar insn priority
- What to do about constants in codegen? (...f suffix, complex types)
- If finding a maximum proves troublesome, move parameters into the domain
...
...
@@ -123,6 +122,9 @@ Future ideas
Dealt with
^^^^^^^^^^
- What to do about constants in codegen? (...f suffix, complex types)
-> dealt with by type contexts
- relating to Multi-Domain
- Make sure that variables that enter into loop bounds are only written
exactly once. [DONE]
...
...
This diff is collapsed.
Click to expand it.
loopy/codegen/bounds.py
+
2
−
2
View file @
91be1b94
...
...
@@ -173,7 +173,7 @@ def wrap_in_for_from_constraints(ccm, iname, constraint_bset, stmt):
from
pymbolic
import
var
rhs
+=
iname_coeff
*
var
(
iname
)
end_conds
.
append
(
"
%s >= 0
"
%
ccm
(
cfm
(
rhs
)))
ccm
(
cfm
(
rhs
)
,
'
i
'
))
else
:
# iname_coeff > 0
kind
,
bound
=
solve_constraint_for_bound
(
cns
,
iname
)
assert
kind
==
"
>=
"
...
...
@@ -205,7 +205,7 @@ def wrap_in_for_from_constraints(ccm, iname, constraint_bset, stmt):
from
cgen
import
For
from
loopy.codegen
import
wrap_in
return
wrap_in
(
For
,
"
int %s = %s
"
%
(
iname
,
ccm
(
start_expr
)),
"
int %s = %s
"
%
(
iname
,
ccm
(
start_expr
,
'
i
'
)),
"
&&
"
.
join
(
end_conds
),
"
++%s
"
%
iname
,
stmt
)
...
...
This diff is collapsed.
Click to expand it.
loopy/codegen/expression.py
+
183
−
79
View file @
91be1b94
This diff is collapsed.
Click to expand it.
loopy/codegen/instruction.py
+
10
−
3
View file @
91be1b94
...
...
@@ -12,11 +12,18 @@ def generate_instruction_code(kernel, insn, codegen_state):
expr
=
insn
.
expression
from
loopy.codegen.expression
import
perform_cast
expr
=
perform_cast
(
ccm
,
expr
,
expr_dtype
=
ccm
.
infer_type
(
expr
),
target_dtype
=
kernel
.
get_var_descriptor
(
insn
.
get_assignee_var_name
()).
dtype
)
target_dtype
=
kernel
.
get_var_descriptor
(
insn
.
get_assignee_var_name
()).
dtype
expr_dtype
=
ccm
.
infer_type
(
expr
)
expr
=
perform_cast
(
ccm
,
expr
,
expr_dtype
=
expr_dtype
,
target_dtype
=
target_dtype
)
from
cgen
import
Assign
insn_code
=
Assign
(
ccm
(
insn
.
assignee
),
ccm
(
expr
))
from
loopy.codegen.expression
import
dtype_to_type_context
insn_code
=
Assign
(
ccm
(
insn
.
assignee
,
prec
=
None
,
type_context
=
None
),
ccm
(
expr
,
prec
=
None
,
type_context
=
dtype_to_type_context
(
target_dtype
)))
from
loopy.codegen.bounds
import
wrap_in_bounds_checks
insn_inames
=
kernel
.
insn_inames
(
insn
)
insn_code
,
impl_domain
=
wrap_in_bounds_checks
(
...
...
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