From 4f0604ab4e3bc5e7a84b31ec684fbb836216ec43 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 24 Sep 2012 18:16:02 -0400 Subject: [PATCH] Reject tests that read *and* write arguments. --- loopy/compiled.py | 11 +++++++++++ loopy/kernel.py | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/loopy/compiled.py b/loopy/compiled.py index 563c676d5..55613fc9a 100644 --- a/loopy/compiled.py +++ b/loopy/compiled.py @@ -493,6 +493,17 @@ def auto_test_vs_ref(ref_knl, ctx, kernel_gen, op_count=[], op_label=[], paramet warn("op_label should be a list", stacklevel=2) op_label = [op_label] + read_and_written_args = ( + ref_knl.get_read_variables() + & ref_knl.get_written_variables() + & set(ref_knl.arg_dict)) + + if read_and_written_args: + # FIXME: In principle, that's possible to test + raise RuntimeError("kernel reads *and* writes argument(s) '%s' " + "and therefore cannot be automatically tested" + % ", ".join(read_and_written_args)) + from time import time if check_result is None: diff --git a/loopy/kernel.py b/loopy/kernel.py index 0d3d74d2f..c62eaf3cd 100644 --- a/loopy/kernel.py +++ b/loopy/kernel.py @@ -1395,9 +1395,16 @@ class LoopKernel(Record): return result + @memoize_method + def get_read_variables(self): + result = set() + for insn in self.instructions: + result.update(insn.get_read_var_names()) + return result + @memoize_method def get_written_variables(self): - return set( + return frozenset( insn.get_assignee_var_name() for insn in self.instructions) -- GitLab