From e5e46d1d3ade288ad39d40f8fac456dc71203705 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Tue, 7 May 2013 14:33:22 -0400 Subject: [PATCH] Default 'approximately' for ScalarArg to 1000, complain intelligibly when not set. --- loopy/kernel/data.py | 4 ++-- loopy/preprocess.py | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/loopy/kernel/data.py b/loopy/kernel/data.py index bdfadceeb..3ee3002b0 100644 --- a/loopy/kernel/data.py +++ b/loopy/kernel/data.py @@ -266,7 +266,7 @@ class ImageArg(Record): return "" % (self.name, self.dtype) class ValueArg(Record): - def __init__(self, name, dtype=None, approximately=None): + def __init__(self, name, dtype=None, approximately=1000): if dtype is not None: dtype = np.dtype(dtype) @@ -277,7 +277,7 @@ class ValueArg(Record): return "" % (self.name, self.dtype) class ScalarArg(ValueArg): - def __init__(self, name, dtype=None, approximately=None): + def __init__(self, name, dtype=None, approximately=1000): from warnings import warn warn("ScalarArg is a deprecated name of ValueArg", DeprecationWarning, stacklevel=2) diff --git a/loopy/preprocess.py b/loopy/preprocess.py index f67b25e1f..855108311 100644 --- a/loopy/preprocess.py +++ b/loopy/preprocess.py @@ -115,7 +115,7 @@ def infer_types_of_temporaries(kernel): if failed: if item is first_failure: # this item has failed before, give up. - raise RuntimeError("could not determine type of '%s'" % item) + raise RuntimeError("could not determine type of '%s'" % item.name) if first_failure is None: # remember the first failure for this round through the queue @@ -592,10 +592,14 @@ def limit_boostability(kernel): def get_auto_axis_iname_ranking_by_stride(kernel, insn): from loopy.kernel.data import ImageArg, ValueArg - approximate_arg_values = dict( - (arg.name, arg.approximately) - for arg in kernel.args - if isinstance(arg, ValueArg)) + approximate_arg_values = {} + for arg in kernel.args: + if isinstance(arg, ValueArg): + if arg.approximately is not None: + approximate_arg_values[arg.name] = arg.approximately + else: + raise RuntimeError("No approximate arg value specified for '%s'" + % arg.name) # {{{ find all array accesses in insn -- GitLab