diff --git a/loopy/compiled.py b/loopy/compiled.py index 2859a20476e20b8f9bfe059ff82a0cc47f4dcfb6..3f858536745f04e74e5c28760bce942645112cb4 100644 --- a/loopy/compiled.py +++ b/loopy/compiled.py @@ -370,8 +370,7 @@ def fill_rand(ary): class TestArgInfo(Record): pass -def make_ref_args(kernel, queue, parameters, - fill_value): +def make_ref_args(kernel, queue, parameters, fill_value): from loopy.kernel.data import ValueArg, GlobalArg, ImageArg from pymbolic import evaluate @@ -420,10 +419,17 @@ def make_ref_args(kernel, queue, parameters, alloc_size = sum(astrd*(alen-1) for alen, astrd in zip(shape, strides)) + 1 - itemsize = arg.dtype.itemsize + dtype = arg.dtype + if dtype is None: + raise RuntimeError("dtype for argument '%s' is not yet " + "known. Perhaps you want to use loopy.add_argument_dtypes " + "or loopy.infer_argument_dtypes?" + % arg.name) + + itemsize = dtype.itemsize numpy_strides = [itemsize*s for s in strides] - storage_array = cl_array.empty(queue, alloc_size, arg.dtype) + storage_array = cl_array.empty(queue, alloc_size, dtype) ary = cl_array.as_strided(storage_array, shape, numpy_strides) if is_output: @@ -431,11 +437,11 @@ def make_ref_args(kernel, queue, parameters, raise RuntimeError("write-mode images not supported in " "automatic testing") - if arg.dtype.isbuiltin: + if dtype.isbuiltin: storage_array.fill(fill_value) else: from warnings import warn - warn("Cannot pre-fill array of dtype '%s'" % arg.dtype) + warn("Cannot pre-fill array of dtype '%s'" % dtype) ref_args[arg.name] = ary else: @@ -619,7 +625,8 @@ def auto_test_vs_ref(ref_knl, ctx, kernel_gen, op_count=[], op_label=[], paramet print_ref_code=False, print_code=True, warmup_rounds=2, edit_code=False, dump_binary=False, codegen_kwargs={}, options=[], - fills_entire_output=True, do_check=True, check_result=None): + fills_entire_output=True, do_check=True, check_result=None + ): """Compare results of `ref_knl` to the kernels generated by the generator `kernel_gen`.