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
227ae708
Commit
227ae708
authored
8 years ago
by
Matt Wala
Browse files
Options
Downloads
Patches
Plain Diff
Kernel printing: Print out items in natural order.
parent
f5059b81
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
loopy/kernel/__init__.py
+20
-6
20 additions, 6 deletions
loopy/kernel/__init__.py
with
20 additions
and
6 deletions
loopy/kernel/__init__.py
+
20
−
6
View file @
227ae708
...
@@ -1116,6 +1116,20 @@ class LoopKernel(ImmutableRecordWithoutPickling):
...
@@ -1116,6 +1116,20 @@ class LoopKernel(ImmutableRecordWithoutPickling):
sep
=
75
*
"
-
"
sep
=
75
*
"
-
"
def
natorder
(
key
):
# Return natural ordering for strings, as opposed to dictionary order.
# E.g. will result in
# 'abc1' < 'abc9' < 'abc10'
# rather than
# 'abc1' < 'abc10' < 'abc9'
# Based on
# http://code.activestate.com/recipes/285264-natural-string-sorting/#c7
import
re
return
[
int
(
n
)
if
n
else
s
for
n
,
s
in
re
.
findall
(
r
'
(\d+)|(\D+)
'
,
key
)]
def
natsorted
(
seq
,
key
=
lambda
x
:
x
):
return
sorted
(
seq
,
key
=
lambda
y
:
natorder
(
key
(
y
)))
if
"
name
"
in
what
:
if
"
name
"
in
what
:
lines
.
append
(
sep
)
lines
.
append
(
sep
)
lines
.
append
(
"
KERNEL:
"
+
kernel
.
name
)
lines
.
append
(
"
KERNEL:
"
+
kernel
.
name
)
...
@@ -1123,7 +1137,7 @@ class LoopKernel(ImmutableRecordWithoutPickling):
...
@@ -1123,7 +1137,7 @@ class LoopKernel(ImmutableRecordWithoutPickling):
if
"
arguments
"
in
what
:
if
"
arguments
"
in
what
:
lines
.
append
(
sep
)
lines
.
append
(
sep
)
lines
.
append
(
"
ARGUMENTS:
"
)
lines
.
append
(
"
ARGUMENTS:
"
)
for
arg_name
in
sorted
(
kernel
.
arg_dict
):
for
arg_name
in
nat
sorted
(
kernel
.
arg_dict
):
lines
.
append
(
str
(
kernel
.
arg_dict
[
arg_name
]))
lines
.
append
(
str
(
kernel
.
arg_dict
[
arg_name
]))
if
"
domains
"
in
what
:
if
"
domains
"
in
what
:
...
@@ -1135,21 +1149,21 @@ class LoopKernel(ImmutableRecordWithoutPickling):
...
@@ -1135,21 +1149,21 @@ class LoopKernel(ImmutableRecordWithoutPickling):
if
"
tags
"
in
what
:
if
"
tags
"
in
what
:
lines
.
append
(
sep
)
lines
.
append
(
sep
)
lines
.
append
(
"
INAME IMPLEMENTATION TAGS:
"
)
lines
.
append
(
"
INAME IMPLEMENTATION TAGS:
"
)
for
iname
in
sorted
(
kernel
.
all_inames
()):
for
iname
in
nat
sorted
(
kernel
.
all_inames
()):
line
=
"
%s: %s
"
%
(
iname
,
kernel
.
iname_to_tag
.
get
(
iname
))
line
=
"
%s: %s
"
%
(
iname
,
kernel
.
iname_to_tag
.
get
(
iname
))
lines
.
append
(
line
)
lines
.
append
(
line
)
if
"
variables
"
in
what
and
kernel
.
temporary_variables
:
if
"
variables
"
in
what
and
kernel
.
temporary_variables
:
lines
.
append
(
sep
)
lines
.
append
(
sep
)
lines
.
append
(
"
TEMPORARIES:
"
)
lines
.
append
(
"
TEMPORARIES:
"
)
for
tv
in
sorted
(
six
.
itervalues
(
kernel
.
temporary_variables
),
for
tv
in
nat
sorted
(
six
.
itervalues
(
kernel
.
temporary_variables
),
key
=
lambda
tv
:
tv
.
name
):
key
=
lambda
tv
:
tv
.
name
):
lines
.
append
(
str
(
tv
))
lines
.
append
(
str
(
tv
))
if
"
rules
"
in
what
and
kernel
.
substitutions
:
if
"
rules
"
in
what
and
kernel
.
substitutions
:
lines
.
append
(
sep
)
lines
.
append
(
sep
)
lines
.
append
(
"
SUBSTIUTION RULES:
"
)
lines
.
append
(
"
SUBSTIUTION RULES:
"
)
for
rule_name
in
sorted
(
six
.
iterkeys
(
kernel
.
substitutions
)):
for
rule_name
in
nat
sorted
(
six
.
iterkeys
(
kernel
.
substitutions
)):
lines
.
append
(
str
(
kernel
.
substitutions
[
rule_name
]))
lines
.
append
(
str
(
kernel
.
substitutions
[
rule_name
]))
if
"
instructions
"
in
what
:
if
"
instructions
"
in
what
:
...
@@ -1167,7 +1181,7 @@ class LoopKernel(ImmutableRecordWithoutPickling):
...
@@ -1167,7 +1181,7 @@ class LoopKernel(ImmutableRecordWithoutPickling):
return
return
printed_insn_ids
.
add
(
insn
.
id
)
printed_insn_ids
.
add
(
insn
.
id
)
for
dep_id
in
sorted
(
insn
.
depends_on
):
for
dep_id
in
nat
sorted
(
insn
.
depends_on
):
insert_insn_into_order
(
kernel
.
id_to_insn
[
dep_id
])
insert_insn_into_order
(
kernel
.
id_to_insn
[
dep_id
])
printed_insn_order
.
append
(
insn
)
printed_insn_order
.
append
(
insn
)
...
@@ -1214,7 +1228,7 @@ class LoopKernel(ImmutableRecordWithoutPickling):
...
@@ -1214,7 +1228,7 @@ class LoopKernel(ImmutableRecordWithoutPickling):
raise
LoopyError
(
"
unexpected instruction type: %s
"
raise
LoopyError
(
"
unexpected instruction type: %s
"
%
type
(
insn
).
__name__
)
%
type
(
insn
).
__name__
)
loop_list
=
"
,
"
.
join
(
sorted
(
kernel
.
insn_inames
(
insn
)))
loop_list
=
"
,
"
.
join
(
nat
sorted
(
kernel
.
insn_inames
(
insn
)))
options
=
[
Fore
.
GREEN
+
insn
.
id
+
Style
.
RESET_ALL
]
options
=
[
Fore
.
GREEN
+
insn
.
id
+
Style
.
RESET_ALL
]
if
insn
.
priority
:
if
insn
.
priority
:
...
...
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