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
b8c98645
Commit
b8c98645
authored
13 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Add user interface for dim length prescription, test for workgroup prescribed too small.
parent
ca93d84e
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
MEMO
+2
-2
2 additions, 2 deletions
MEMO
loopy/check.py
+0
-3
0 additions, 3 deletions
loopy/check.py
loopy/codegen/__init__.py
+1
-1
1 addition, 1 deletion
loopy/codegen/__init__.py
loopy/kernel.py
+19
-5
19 additions, 5 deletions
loopy/kernel.py
test/test_loopy.py
+32
-0
32 additions, 0 deletions
test/test_loopy.py
with
54 additions
and
11 deletions
MEMO
+
2
−
2
View file @
b8c98645
...
...
@@ -42,8 +42,6 @@ Things to consider
To-do
^^^^^
- user interface for dim length prescription
- Deal with equality constraints.
(These arise, e.g., when partitioning a loop of length 16 into 16s.)
...
...
@@ -86,6 +84,8 @@ Future ideas
Dealt with
^^^^^^^^^^
- user interface for dim length prescription
- Restrict-to-sequential and tagging have nothing to do with each other.
-> Removed SequentialTag and turned it into a separate computed kernel
property.
...
...
This diff is collapsed.
Click to expand it.
loopy/check.py
+
0
−
3
View file @
b8c98645
...
...
@@ -146,9 +146,6 @@ def check_for_write_races(kernel):
# }}}
# {{{ sanity-check for implemented domains of each instruction
def
check_implemented_domains
(
kernel
,
implemented_domains
):
...
...
This diff is collapsed.
Click to expand it.
loopy/codegen/__init__.py
+
1
−
1
View file @
b8c98645
...
...
@@ -318,7 +318,7 @@ def generate_code(kernel):
# }}}
from
loopy.check
import
check_implemented_domains
#
assert check_implemented_domains(kernel, gen_code.implemented_domains)
assert
check_implemented_domains
(
kernel
,
gen_code
.
implemented_domains
)
return
str
(
mod
)
...
...
This diff is collapsed.
Click to expand it.
loopy/kernel.py
+
19
−
5
View file @
b8c98645
...
...
@@ -438,6 +438,9 @@ class LoopKernel(Record):
'
bulk
'
slabs with fewer conditionals.
:ivar temporary_variables:
:ivar iname_to_tag:
:ivar local_sizes: A dictionary from integers to integers, mapping
workgroup axes to ther sizes, e.g. *{0: 16}* forces axis 0 to be
length 16.
The following two instance variables are only used until :func:`loopy.kernel.make_kernel` is
finished:
...
...
@@ -449,7 +452,7 @@ class LoopKernel(Record):
preamble
=
None
,
assumptions
=
None
,
iname_slab_increments
=
{},
temporary_variables
=
{},
workgroup
_size
=
None
,
local
_size
s
=
None
,
iname_to_tag
=
{},
iname_to_tag_requests
=
None
):
"""
:arg domain: a :class:`islpy.BasicSet`, or a string parseable to a basic set by the isl.
...
...
@@ -585,7 +588,7 @@ class LoopKernel(Record):
assumptions
=
assumptions
,
iname_slab_increments
=
iname_slab_increments
,
temporary_variables
=
temporary_variables
,
workgroup_size
=
workgroup
_size
,
local_sizes
=
local
_size
s
,
iname_to_tag
=
iname_to_tag
,
iname_to_tag_requests
=
iname_to_tag_requests
)
...
...
@@ -761,11 +764,22 @@ class LoopKernel(Record):
max_dims
=
self
.
device
.
max_work_item_dimensions
def
to_dim_tuple
(
size_dict
,
which
):
def
to_dim_tuple
(
size_dict
,
which
,
forced_sizes
=
{}):
forced_sizes
=
forced_sizes
.
copy
()
size_list
=
[]
sorted_axes
=
sorted
(
size_dict
.
iterkeys
())
while
sorted_axes
:
while
sorted_axes
or
forced_sizes
:
cur_axis
=
sorted_axes
.
pop
(
0
)
if
len
(
size_list
)
in
forced_sizes
:
size_list
.
append
(
isl
.
PwAff
.
from_aff
(
isl
.
Aff
.
zero_on_domain
(
self
.
space
.
params
())
+
forced_sizes
.
pop
(
len
(
size_list
))))
continue
while
cur_axis
>
len
(
size_list
):
from
loopy
import
LoopyAdvisory
from
warnings
import
warn
...
...
@@ -782,7 +796,7 @@ class LoopKernel(Record):
return
tuple
(
size_list
)
return
(
to_dim_tuple
(
global_sizes
,
"
global
"
),
to_dim_tuple
(
local_sizes
,
"
local
"
))
to_dim_tuple
(
local_sizes
,
"
local
"
,
forced_sizes
=
self
.
local_sizes
))
def
get_grid_sizes_as_exprs
(
self
,
ignore_auto
=
False
):
grid_size
,
group_size
=
self
.
get_grid_sizes
(
ignore_auto
=
ignore_auto
)
...
...
This diff is collapsed.
Click to expand it.
test/test_loopy.py
+
32
−
0
View file @
b8c98645
...
...
@@ -38,6 +38,38 @@ def test_owed_barriers(ctx_factory):
def
test_wg_too_small
(
ctx_factory
):
dtype
=
np
.
float32
ctx
=
ctx_factory
()
order
=
"
C
"
queue
=
cl
.
CommandQueue
(
ctx
,
properties
=
cl
.
command_queue_properties
.
PROFILING_ENABLE
)
knl
=
lp
.
make_kernel
(
ctx
.
devices
[
0
],
"
{[i]: 0<=i<100}
"
,
[
"
[i:l.0] <float32> z[i] = a[i]
"
],
[
lp
.
ArrayArg
(
"
a
"
,
dtype
,
shape
=
(
100
,)),
],
local_sizes
=
{
0
:
16
})
kernel_gen
=
lp
.
generate_loop_schedules
(
knl
)
kernel_gen
=
lp
.
check_kernels
(
kernel_gen
)
for
gen_knl
in
kernel_gen
:
try
:
compiled
=
lp
.
CompiledKernel
(
ctx
,
gen_knl
)
except
RuntimeError
,
e
:
assert
"
implemented and desired
"
in
str
(
e
)
pass
# expected!
else
:
assert
False
# expecting an error
if
__name__
==
"
__main__
"
:
import
sys
if
len
(
sys
.
argv
)
>
1
:
...
...
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