Code generation fails when specifying kernel_data
If kernel_data
is explicitly specified, then the code generation fails with an unhelpful error message about accessing an out of bounds array element. Code generation succeeds when kernel_data
is removed. Full output and code below.
Traceback (most recent call last):
File "/home/njchris2/miniconda3/envs/dgfem/lib/python3.7/site-packages/pytools/__init__.py", line 582, in wrapper
return getattr(obj, cache_dict_name)[key]
AttributeError: 'PyOpenCLKernelExecutor' object has no attribute '_memoize_dic_kernel_info'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "loopy_kernels.py", line 128, in <module>
(evt, result) = axpy(queue, a=a, x=x, y=y)
File "/home/njchris2/miniconda3/envs/dgfem/lib/python3.7/site-packages/loopy/kernel/__init__.py", line 1408, in __call__
return kex(*args, **kwargs)
File "/home/njchris2/miniconda3/envs/dgfem/lib/python3.7/site-packages/loopy/target/pyopencl_execution.py", line 351, in __call__
kernel_info = self.kernel_info(self.arg_to_dtype_set(kwargs))
File "/home/njchris2/miniconda3/envs/dgfem/lib/python3.7/site-packages/pytools/__init__.py", line 584, in wrapper
result = function(obj, *args, **kwargs)
File "/home/njchris2/miniconda3/envs/dgfem/lib/python3.7/site-packages/loopy/target/pyopencl_execution.py", line 279, in kernel_info
kernel = self.get_typed_and_scheduled_kernel(arg_to_dtype_set)
File "/home/njchris2/miniconda3/envs/dgfem/lib/python3.7/site-packages/loopy/target/execution.py", line 783, in get_typed_and_scheduled_kernel
kernel = self.get_typed_and_scheduled_kernel_uncached(arg_to_dtype_set)
File "/home/njchris2/miniconda3/envs/dgfem/lib/python3.7/site-packages/loopy/target/execution.py", line 762, in get_typed_and_scheduled_kernel_uncached
kernel = get_one_scheduled_kernel(kernel)
File "/home/njchris2/miniconda3/envs/dgfem/lib/python3.7/site-packages/loopy/schedule/__init__.py", line 2049, in get_one_scheduled_kernel
result = _get_one_scheduled_kernel_inner(kernel)
File "/home/njchris2/miniconda3/envs/dgfem/lib/python3.7/site-packages/loopy/schedule/__init__.py", line 2028, in _get_one_scheduled_kernel_inner
return next(iter(generate_loop_schedules(kernel)))
File "/home/njchris2/miniconda3/envs/dgfem/lib/python3.7/site-packages/loopy/schedule/__init__.py", line 1838, in generate_loop_schedules
for sched in generate_loop_schedules_inner(kernel, debug_args=debug_args):
File "/home/njchris2/miniconda3/envs/dgfem/lib/python3.7/site-packages/loopy/schedule/__init__.py", line 1849, in generate_loop_schedules_inner
pre_schedule_checks(kernel)
File "/home/njchris2/miniconda3/envs/dgfem/lib/python3.7/site-packages/loopy/check.py", line 662, in pre_schedule_checks
check_bounds(kernel)
File "/home/njchris2/miniconda3/envs/dgfem/lib/python3.7/site-packages/loopy/check.py", line 384, in check_bounds
insn.with_transformed_expressions(run_acm)
File "/home/njchris2/miniconda3/envs/dgfem/lib/python3.7/site-packages/loopy/kernel/instruction.py", line 964, in with_transformed_expressions
assignee=f(self.assignee, *args),
File "/home/njchris2/miniconda3/envs/dgfem/lib/python3.7/site-packages/loopy/check.py", line 381, in run_acm
acm(expr)
File "/home/njchris2/miniconda3/envs/dgfem/lib/python3.7/site-packages/pymbolic/mapper/__init__.py", line 134, in __call__
return method(expr, *args, **kwargs)
File "/home/njchris2/miniconda3/envs/dgfem/lib/python3.7/site-packages/loopy/check.py", line 366, in map_subscript
% (expr, self.insn_id))
loopy.diagnostic.LoopyError: 'result[i]' in instruction 'insn' accesses out-of-bounds array element
SEMPY_SCALAR = np.float64
def gen_axpy_knl(n):
knl = lp.make_kernel(
"""
{[i]: 0<=i<n}
""",
"""
result[i] = a*x[i] + y[i]
""",
kernel_data = [
lp.GlobalArg("result", SEMPY_SCALAR, shape=(n,), order="C"),
lp.ValueArg("a", SEMPY_SCALAR),
lp.GlobalArg("x", SEMPY_SCALAR, shape=(n,), order="C"),
lp.GlobalArg("y", SEMPY_SCALAR, shape=(n,), order="C")
],
assumptions="n > 0",
default_offset=None,
name="axpy"
)
return knl
if __name__ == "__main__":
axpy = gen_axpy_knl(100)
print(axpy)
a = SEMPY_SCALAR(1.0)
x = np.ones(100, SEMPY_SCALAR)
y = np.ones(100, SEMPY_SCALAR)
result = np.empty(100, SEMPY_SCALAR)
(evt, result) = axpy(queue, a=a, x=x, y=y)
print(result)
Edited by Nicholas Christensen