Skip to content

Commit 92fa22d

Browse files
committed
Fix, test set_arg with None argument
Closes gh-897
1 parent 38909ad commit 92fa22d

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/wrap_cl_part_2.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,10 @@ void pyopencl_expose_part_2(py::module_ &m)
605605
{ knl.set_arg_buf_pack(i, typechar, arg); },
606606
indices_chars_and_args);
607607
})
608-
.DEF_SIMPLE_METHOD(set_arg)
608+
.def("set_arg", &cls::set_arg,
609+
py::arg("arg_index"),
610+
py::arg("arg").none(true)
611+
)
609612
#if PYOPENCL_CL_VERSION >= 0x1020
610613
.DEF_SIMPLE_METHOD(get_arg_info)
611614
#endif

test/test_wrapper.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,21 @@ def test_buffer_release(ctx_factory: cl.CtxFactory):
15601560
b.release()
15611561

15621562

1563+
def test_set_arg_none(ctx_factory: cl.CtxFactory):
1564+
# https://github.com/inducer/pyopencl/issues/897
1565+
ctx = ctx_factory()
1566+
prg = cl.Program(ctx, """
1567+
__kernel void sum(
1568+
__global const float *a_g, __global const float *b_g, __global float *res_g)
1569+
{
1570+
int gid = get_global_id(0);
1571+
res_g[gid] = a_g[gid] + b_g[gid];
1572+
}
1573+
""").build()
1574+
1575+
prg.sum.set_arg(0, None)
1576+
1577+
15631578
if __name__ == "__main__":
15641579
import sys
15651580
if len(sys.argv) > 1:

0 commit comments

Comments
 (0)