Skip to content
Snippets Groups Projects
Commit 8640a6d7 authored by Dominic Kempf's avatar Dominic Kempf
Browse files

Remove ambiguity warning from the scheduler

parent a851720c
No related branches found
No related tags found
No related merge requests found
......@@ -456,8 +456,8 @@ control is the nesting of loops. For example, should the *i* loop be nested
around the *j* loop, or the other way around, in the following simple
zero-fill kernel?
It turns out that Loopy will typically choose a loop nesting for us, but it
does not like doing so. Loo.py will react to the following code
It turns out that Loopy will choose a loop nesting for us, but it might be
ambiguous. Consider the following code:
.. doctest::
......@@ -467,13 +467,8 @@ does not like doing so. Loo.py will react to the following code
... a[i,j] = 0
... """)
By saying::
LoopyWarning: kernel scheduling was ambiguous--more than one schedule found, ignoring
And by picking one of the possible loop orderings at random.
The warning (and the nondeterminism it warns about) is easily resolved:
Both nestings of the inames `i` and `j` result in a correct kernel.
This ambiguity can be resolved:
.. doctest::
......
......@@ -1763,8 +1763,7 @@ def generate_loop_schedules(kernel, debug_args={}):
new_limit = max(rec_limit, len(kernel.instructions) * 2)
sys.setrecursionlimit(new_limit)
try:
for sched in generate_loop_schedules_inner(kernel, debug_args=debug_args):
yield sched
return generate_loop_schedules_inner(kernel, debug_args=debug_args)
finally:
sys.setrecursionlimit(rec_limit)
......@@ -1916,7 +1915,7 @@ def generate_loop_schedules_inner(kernel, debug_args={}):
from loopy.schedule.tools import add_extra_args_to_schedule
new_kernel = add_extra_args_to_schedule(new_kernel)
yield new_kernel
return new_kernel
debug.start()
......@@ -1959,7 +1958,7 @@ def get_one_scheduled_kernel(kernel):
if CACHING_ENABLED:
try:
result, ambiguous = schedule_cache[sched_cache_key]
result = schedule_cache[sched_cache_key]
logger.debug("%s: schedule cache hit" % kernel.name)
from_cache = True
......@@ -1967,38 +1966,18 @@ def get_one_scheduled_kernel(kernel):
pass
if not from_cache:
ambiguous = False
kernel_count = 0
from time import time
start_time = time()
logger.info("%s: schedule start" % kernel.name)
for scheduled_kernel in generate_loop_schedules(kernel):
kernel_count += 1
if kernel_count == 1:
# use the first schedule
result = scheduled_kernel
if kernel_count == 2:
ambiguous = True
break
result = generate_loop_schedules(kernel)
logger.info("%s: scheduling done after %.2f s" % (
kernel.name, time()-start_time))
if ambiguous:
from warnings import warn
from loopy.diagnostic import LoopyWarning
warn("scheduling for kernel '%s' was ambiguous--more than one "
"schedule found, ignoring" % kernel.name, LoopyWarning,
stacklevel=2)
if CACHING_ENABLED and not from_cache:
schedule_cache[sched_cache_key] = result, ambiguous
schedule_cache[sched_cache_key] = result
return result
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment