From 0ae1764aa6fe2db533fb67ae9849f76031dddcfd Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Mon, 12 Dec 2016 20:37:38 +0100 Subject: [PATCH 1/4] Remove ambiguity warning from the scheduler (cherry picked from commit 8640a6d76542e8275fa3048ab435515618e45903) --- doc/tutorial.rst | 13 ++++--------- loopy/schedule/__init__.py | 31 +++++-------------------------- 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/doc/tutorial.rst b/doc/tutorial.rst index d9627deed..9e4bd8c91 100644 --- a/doc/tutorial.rst +++ b/doc/tutorial.rst @@ -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:: diff --git a/loopy/schedule/__init__.py b/loopy/schedule/__init__.py index e23e5f350..0a940d76d 100644 --- a/loopy/schedule/__init__.py +++ b/loopy/schedule/__init__.py @@ -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 -- GitLab From babaa764e4b5f0c2a773418ab6acc0ff141552b1 Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Mon, 12 Dec 2016 20:58:07 +0100 Subject: [PATCH 2/4] Partially restore the generator nature of the scheduler it is needed and useful in tests. (cherry picked from commit 5f071bc3e7b3c49802062b2089348d00688d6b04) --- loopy/schedule/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/loopy/schedule/__init__.py b/loopy/schedule/__init__.py index 0a940d76d..bf51147b5 100644 --- a/loopy/schedule/__init__.py +++ b/loopy/schedule/__init__.py @@ -1763,7 +1763,8 @@ def generate_loop_schedules(kernel, debug_args={}): new_limit = max(rec_limit, len(kernel.instructions) * 2) sys.setrecursionlimit(new_limit) try: - return generate_loop_schedules_inner(kernel, debug_args=debug_args) + for sched in generate_loop_schedules_inner(kernel, debug_args=debug_args): + yield sched finally: sys.setrecursionlimit(rec_limit) @@ -1915,7 +1916,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) - return new_kernel + yield new_kernel debug.start() @@ -1971,7 +1972,7 @@ def get_one_scheduled_kernel(kernel): logger.info("%s: schedule start" % kernel.name) - result = generate_loop_schedules(kernel) + result = next(iter(generate_loop_schedules(kernel))) logger.info("%s: scheduling done after %.2f s" % ( kernel.name, time()-start_time)) -- GitLab From 83dfcca9bcc91f413f51d5fc36b5ef01b1bc46d9 Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Tue, 13 Dec 2016 10:42:07 +0100 Subject: [PATCH 3/4] Bump data model version - again --- loopy/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopy/version.py b/loopy/version.py index b3505973b..503b6c54e 100644 --- a/loopy/version.py +++ b/loopy/version.py @@ -32,4 +32,4 @@ except ImportError: else: _islpy_version = islpy.version.VERSION_TEXT -DATA_MODEL_VERSION = "v51-islpy%s" % _islpy_version +DATA_MODEL_VERSION = "v52-islpy%s" % _islpy_version -- GitLab From 48e2a742a2ec23a725a9891a0df5dadea22d97b4 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sat, 24 Dec 2016 20:48:02 +0100 Subject: [PATCH 4/4] Re-bump data model version --- loopy/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopy/version.py b/loopy/version.py index 503b6c54e..6a02f4d99 100644 --- a/loopy/version.py +++ b/loopy/version.py @@ -32,4 +32,4 @@ except ImportError: else: _islpy_version = islpy.version.VERSION_TEXT -DATA_MODEL_VERSION = "v52-islpy%s" % _islpy_version +DATA_MODEL_VERSION = "v53-islpy%s" % _islpy_version -- GitLab