From c09a975ad0847b95c4372dd1276baa7ffe0ee661 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 25 Jun 2012 12:22:23 -0400 Subject: [PATCH] Allow passing a scheduled-kernel generator to CompiledKernel. --- loopy/compiled.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/loopy/compiled.py b/loopy/compiled.py index 1eebc5952..187c17050 100644 --- a/loopy/compiled.py +++ b/loopy/compiled.py @@ -42,16 +42,26 @@ def _arg_matches_spec(arg, val, other_args): class CompiledKernel: def __init__(self, context, kernel, size_args=None, options=[], edit_code=False, codegen_kwargs={}): + """ + :arg kernel: may be a loopy.LoopKernel, a generator returning kernels + (a warning will be issued if more than one is returned). If the kernel + has not yet been loop-scheduled, that is done, too, with no specific + arguments. + """ import loopy as lp # {{{ do scheduling, if not yet done needs_check = False - if kernel.schedule is None: + if not isinstance(kernel, lp.LoopKernel) or kernel.schedule is None: + if isinstance(kernel, lp.LoopKernel): + # kernel-iterable, really + kernel = lp.generate_loop_schedules(kernel) + kernel_count = 0 - for scheduled_kernel in lp.generate_loop_schedules(kernel): + for scheduled_kernel in kernel: kernel_count += 1 if kernel_count == 1: -- GitLab