From 82f9bb00802e9fbe1813040397c15c8dfa8f86f4 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Thu, 27 Sep 2012 14:13:37 -0500 Subject: [PATCH] Make option to warn about numpy arrays in loopy kernel calling seq. --- loopy/compiled.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/loopy/compiled.py b/loopy/compiled.py index c8c58df06..3051b854e 100644 --- a/loopy/compiled.py +++ b/loopy/compiled.py @@ -142,6 +142,7 @@ class CompiledKernel: wait_for = kwargs.pop("wait_for", None) out_host = kwargs.pop("out_host", None) no_run = kwargs.pop("no_run", None) + warn_numpy = kwargs.pop("warn_numpy", None) import loopy as lp @@ -169,8 +170,12 @@ class CompiledKernel: if isinstance(val, np.ndarray): # synchronous, so nothing to worry about val = cl_array.to_device(queue, val, allocator=allocator) - elif val is not None: encountered_numpy = True + if warn_numpy: + from warnings import warn + warn("argument '%s' was passed as a numpy array, " + "performing implicit transfer" % arg.name, + stacklevel=2) if val is None: if not is_written: @@ -224,7 +229,6 @@ class CompiledKernel: def print_code(self): print get_highlighted_code(self.code) - # }}} @@ -700,9 +704,9 @@ def auto_test_vs_ref(ref_knl, ctx, kernel_gen, op_count=[], op_label=[], paramet rates = "" for cnt, lbl in zip(op_count, op_label): - rates += " %g %s/s" % (cnt/elapsed, lbl) + rates += " %g %s/s" % (cnt/elapsed_wall, lbl) - print "elapsed: %g s event, %s s other-event %g s wall (%d rounds)%s" % ( + print "elapsed: %g s event, %s s marker-event %g s wall (%d rounds)%s" % ( elapsed, elapsed_evt_2, elapsed_wall, timing_rounds, rates) if do_check: -- GitLab