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
8a75fd1a
Commit
8a75fd1a
authored
11 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
PEP8 loopy.kernel. Move name generator to pytools.
parent
d3faf041
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
loopy/kernel/__init__.py
+18
-19
18 additions, 19 deletions
loopy/kernel/__init__.py
loopy/kernel/creation.py
+0
-33
0 additions, 33 deletions
loopy/kernel/creation.py
with
18 additions
and
52 deletions
loopy/kernel/__init__.py
+
18
−
19
View file @
8a75fd1a
...
...
@@ -25,15 +25,12 @@ THE SOFTWARE.
"""
import
numpy
as
np
from
pytools
import
Record
,
memoize_method
import
islpy
as
isl
from
islpy
import
dim_type
from
loopy.kernel.creation
import
UniqueNameGenerator
,
generate_unique_possibilities
from
pytools
import
UniqueNameGenerator
,
generate_unique_possibilities
from
loopy.kernel.data
import
(
default_function_mangler
,
...
...
@@ -46,11 +43,10 @@ from loopy.kernel.data import (
)
class
CannotBranchDomainTree
(
RuntimeError
):
pass
# {{{ loop kernel object
class
LoopKernel
(
Record
):
...
...
@@ -74,8 +70,8 @@ class LoopKernel(Record):
The following arguments are not user-facing:
:ivar substitutions: a mapping from substitution names to
:class:`SubstitutionRule`
objects
:ivar substitutions: a mapping from substitution names to
:class:`SubstitutionRule`
objects
:ivar iname_slab_increments: a dictionary mapping inames to (lower_incr,
upper_incr) tuples that will be separated out in the execution to generate
'
bulk
'
slabs with fewer conditionals.
...
...
@@ -116,8 +112,8 @@ class LoopKernel(Record):
# a way to forward sub-kernel grid size requests.
get_grid_sizes
=
None
):
"""
:arg domain: a :class:`islpy.BasicSet`, or a string parseable to
a basic set by the isl.
Example:
"
{[i,j]: 0<=i < 10 and 0<= j < 9}
"
:arg domain: a :class:`islpy.BasicSet`, or a string parseable to
a basic set by the isl.
Example:
"
{[i,j]: 0<=i < 10 and 0<= j < 9}
"
"""
if
cache_manager
is
None
:
...
...
@@ -162,7 +158,8 @@ class LoopKernel(Record):
dom0_space
.
get_ctx
(),
dom0_space
.
dim
(
dim_type
.
param
))
for
i
in
xrange
(
dom0_space
.
dim
(
dim_type
.
param
)):
assumptions_space
=
assumptions_space
.
set_dim_name
(
dim_type
.
param
,
i
,
dom0_space
.
get_dim_name
(
dim_type
.
param
,
i
))
dim_type
.
param
,
i
,
dom0_space
.
get_dim_name
(
dim_type
.
param
,
i
))
assumptions
=
isl
.
BasicSet
.
universe
(
assumptions_space
)
elif
isinstance
(
assumptions
,
str
):
...
...
@@ -251,7 +248,8 @@ class LoopKernel(Record):
def
get_var_name_generator
(
self
):
return
UniqueNameGenerator
(
self
.
all_variable_names
())
def
make_unique_instruction_id
(
self
,
insns
=
None
,
based_on
=
"
insn
"
,
extra_used_ids
=
set
()):
def
make_unique_instruction_id
(
self
,
insns
=
None
,
based_on
=
"
insn
"
,
extra_used_ids
=
set
()):
if
insns
is
None
:
insns
=
self
.
instructions
...
...
@@ -410,7 +408,7 @@ class LoopKernel(Record):
domains (those which get most say on the actual dim_type of an iname)
must be later in the order.
"""
assert
isinstance
(
domains
,
tuple
)
# for caching
assert
isinstance
(
domains
,
tuple
)
# for caching
if
not
domains
:
return
isl
.
BasicSet
.
universe
(
isl
.
Space
.
set_alloc
(
...
...
@@ -555,7 +553,8 @@ class LoopKernel(Record):
@memoize_method
def
reader_map
(
self
):
"""
:return: a dict that maps variable names to ids of insns that read that variable.
:return: a dict that maps variable names to ids of insns that read that
variable.
"""
result
=
{}
...
...
@@ -570,7 +569,8 @@ class LoopKernel(Record):
@memoize_method
def
writer_map
(
self
):
"""
:return: a dict that maps variable names to ids of insns that write to that variable.
:return: a dict that maps variable names to ids of insns that write
to that variable.
"""
result
=
{}
...
...
@@ -699,8 +699,8 @@ class LoopKernel(Record):
elif
isinstance
(
tag
,
LocalIndexTag
):
tgt_dict
=
local_sizes
elif
isinstance
(
tag
,
AutoLocalIndexTagBase
)
and
not
ignore_auto
:
raise
RuntimeError
(
"
cannot find grid sizes if automatic
local index tags are
"
"
present
"
)
raise
RuntimeError
(
"
cannot find grid sizes if automatic
"
"
local index tags are
present
"
)
else
:
tgt_dict
=
None
...
...
@@ -737,8 +737,7 @@ class LoopKernel(Record):
cur_axis
=
None
if
len
(
size_list
)
in
forced_sizes
:
size_list
.
append
(
forced_sizes
.
pop
(
len
(
size_list
)))
size_list
.
append
(
forced_sizes
.
pop
(
len
(
size_list
)))
continue
assert
cur_axis
is
not
None
...
...
This diff is collapsed.
Click to expand it.
loopy/kernel/creation.py
+
0
−
33
View file @
8a75fd1a
...
...
@@ -36,39 +36,6 @@ import re
# {{{ tool: unique name generation
def
generate_unique_possibilities
(
prefix
):
yield
prefix
try_num
=
0
while
True
:
yield
"
%s_%d
"
%
(
prefix
,
try_num
)
try_num
+=
1
class
UniqueNameGenerator
:
def
__init__
(
self
,
existing_names
):
self
.
existing_names
=
existing_names
.
copy
()
def
is_name_conflicting
(
self
,
name
):
return
name
in
self
.
existing_names
def
add_name
(
self
,
name
):
if
self
.
is_name_conflicting
(
name
):
raise
ValueError
(
"
name
'
%s
'
conflicts with existing names
"
)
self
.
existing_names
.
add
(
name
)
def
add_names
(
self
,
names
):
for
name
in
names
:
self
.
add_name
(
name
)
def
__call__
(
self
,
based_on
=
"
var
"
):
for
var_name
in
generate_unique_possibilities
(
based_on
):
if
not
self
.
is_name_conflicting
(
var_name
):
break
self
.
existing_names
.
add
(
var_name
)
return
var_name
_IDENTIFIER_RE
=
re
.
compile
(
r
"
\b([a-zA-Z_][a-zA-Z0-9_]*)\b
"
)
...
...
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