I’m not familiar with the full details of the code, but naively I would expect
this could be fixed with a single line of code (diff below). Indeed this does
work for me, but perhaps it breaks something else?
Best, Dustin
git diff pyopencl/__init__.py
diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py
index e23a365..977aaf4 100644
--- a/pyopencl/__init__.py
+++ b/pyopencl/__init__.py
@@ -334,6 +334,8 @@ class Program(object):
# but this will give an error if the kernel is invalid.
knl.num_args
knl._source = getattr(self, "_source", None)
+
+ setattr(self, attr, knl)
return knl
except LogicError:
raise AttributeError("'%s' was not found as a program “
> On Feb 14, 2016, at 7:20 AM, Andreas Kloeckner <[email protected]>
> wrote:
>
> Dustin Kleckner <[email protected]> writes:
>
>> Thanks for the quick reply — that fixed it.
>>
>> Just out of curiosity, is there a compelling reason not to cache the
>> kernel code in the program objects, and then quickly returning
>> repeated calls? I generally wouldn’t expect calling a method
>> repeatedly to be significant slower than getting a copy and then
>> calling it. I guess what you’re saying is that I shouldn’t think of
>> “pgm.sum” as a method, but rather as an argument-less function that
>> returns a method? In this case shouldn’t I expect the syntax to be
>> “sum_knl = prg.sum()”?
>
> I'll think about it. It won't work in the case where the kernel came out
> of a GetInfo query and we don't know the associated (Python-side)
> Program object. But in the most common cases it should be doable. Could
> you put up a bug on Github so I remember to look into this?
>
> Andreas
_______________________________________________
PyOpenCL mailing list
[email protected]
https://lists.tiker.net/listinfo/pyopencl