Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/wrap_cl_part_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,10 @@ void pyopencl_expose_part_2(py::module_ &m)
{ knl.set_arg_buf_pack(i, typechar, arg); },
indices_chars_and_args);
})
.DEF_SIMPLE_METHOD(set_arg)
.def("set_arg", &cls::set_arg,
py::arg("arg_index"),
py::arg("arg").none(true)
)
#if PYOPENCL_CL_VERSION >= 0x1020
.DEF_SIMPLE_METHOD(get_arg_info)
#endif
Expand Down
15 changes: 15 additions & 0 deletions test/test_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
except cl.LogicError:
pass

prg.mult(queue, a.shape, None, a_buf, np.float32(2), np.int32(3))

Check warning on line 397 in test/test_wrapper.py

View workflow job for this annotation

GitHub Actions / Pytest Mac POCL

Kernel 'mult' has been retrieved more than once. Each retrieval creates a new, independent kernel, at possibly considerable expense. To avoid the expense, reuse the retrieved kernel instance. To avoid this warning, use cl.Kernel(prg, name).

Check warning on line 397 in test/test_wrapper.py

View workflow job for this annotation

GitHub Actions / Pytest Mac POCL

Kernel 'mult' has been retrieved more than once. Each retrieval creates a new, independent kernel, at possibly considerable expense. To avoid the expense, reuse the retrieved kernel instance. To avoid this warning, use cl.Kernel(prg, name).

a_result = np.empty_like(a)
cl.enqueue_copy(queue, a_buf, a_result).wait()
Expand Down Expand Up @@ -1560,6 +1560,21 @@
b.release()


def test_set_arg_none(ctx_factory: cl.CtxFactory):
# https://github.com/inducer/pyopencl/issues/897
ctx = ctx_factory()
prg = cl.Program(ctx, """
__kernel void sum(
__global const float *a_g, __global const float *b_g, __global float *res_g)
{
int gid = get_global_id(0);
res_g[gid] = a_g[gid] + b_g[gid];
}
""").build()

prg.sum.set_arg(0, None)


if __name__ == "__main__":
import sys
if len(sys.argv) > 1:
Expand Down
Loading