From 16013d8cbd93cc827da03ea54da46c1adbef6b49 Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Wed, 27 Apr 2022 16:33:22 -0500 Subject: [PATCH] prefer keyword arguments to lp.set_options --- doc/tutorial.rst | 30 +++++++++++++++--------------- test/test_callables.py | 4 ++-- test/test_expression.py | 2 +- test/test_target.py | 8 ++++---- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/doc/tutorial.rst b/doc/tutorial.rst index 41d2b0675..7fe11871b 100644 --- a/doc/tutorial.rst +++ b/doc/tutorial.rst @@ -183,7 +183,7 @@ by passing :attr:`loopy.Options.write_code`. .. doctest:: - >>> knl = lp.set_options(knl, "write_code") + >>> knl = lp.set_options(knl, write_code=True) >>> evt, (out,) = knl(queue, a=x_vec_dev) #define lid(N) ((int) get_local_id(N)) #define gid(N) ((int) get_group_id(N)) @@ -391,7 +391,7 @@ Let us take a look at the generated code for the above kernel: .. doctest:: - >>> knl = lp.set_options(knl, "write_code") + >>> knl = lp.set_options(knl, write_code=True) >>> knl = lp.prioritize_loops(knl, "i,j") >>> evt, (out,) = knl(queue, a=a_mat_dev) #define lid(N) ((int) get_local_id(N)) @@ -442,7 +442,7 @@ Now the intended code is generated and our test passes. .. doctest:: - >>> knl = lp.set_options(knl, "write_code") + >>> knl = lp.set_options(knl, write_code=True) >>> evt, (out,) = knl(queue, a=a_mat_dev) #define lid(N) ((int) get_local_id(N)) #define gid(N) ((int) get_group_id(N)) @@ -497,7 +497,7 @@ ambiguous. .. doctest:: - >>> knl = lp.set_options(knl, "write_code") + >>> knl = lp.set_options(knl, write_code=True) >>> evt, (out,) = knl(queue, a=a_mat_dev) #define lid(N) ((int) get_local_id(N)) ... @@ -555,7 +555,7 @@ Consider this example: ... "a[i] = 0", assumptions="n>=1") >>> knl = lp.split_iname(knl, "i", 16) >>> knl = lp.prioritize_loops(knl, "i_outer,i_inner") - >>> knl = lp.set_options(knl, "write_code") + >>> knl = lp.set_options(knl, write_code=True) >>> evt, (out,) = knl(queue, a=x_vec_dev) #define lid(N) ((int) get_local_id(N)) ... @@ -586,7 +586,7 @@ relation to loop nesting. For example, it's perfectly possible to request ... "a[i] = 0", assumptions="n>=1") >>> knl = lp.split_iname(knl, "i", 16) >>> knl = lp.prioritize_loops(knl, "i_inner,i_outer") - >>> knl = lp.set_options(knl, "write_code") + >>> knl = lp.set_options(knl, write_code=True) >>> evt, (out,) = knl(queue, a=x_vec_dev) #define lid(N) ((int) get_local_id(N)) ... @@ -611,7 +611,7 @@ commonly called 'loop tiling': >>> knl = lp.split_iname(knl, "i", 16) >>> knl = lp.split_iname(knl, "j", 16) >>> knl = lp.prioritize_loops(knl, "i_outer,j_outer,i_inner") - >>> knl = lp.set_options(knl, "write_code") + >>> knl = lp.set_options(knl, write_code=True) >>> evt, (out,) = knl(queue, a=a_mat_dev) #define lid(N) ((int) get_local_id(N)) ... @@ -653,7 +653,7 @@ loop's tag to ``"unr"``: >>> knl = lp.split_iname(knl, "i", 4) >>> knl = lp.tag_inames(knl, dict(i_inner="unr")) >>> knl = lp.prioritize_loops(knl, "i_outer,i_inner") - >>> knl = lp.set_options(knl, "write_code") + >>> knl = lp.set_options(knl, write_code=True) >>> evt, (out,) = knl(queue, a=x_vec_dev) #define lid(N) ((int) get_local_id(N)) #define gid(N) ((int) get_group_id(N)) @@ -728,7 +728,7 @@ Let's try this out on our vector fill kernel by creating workgroups of size ... "a[i] = 0", assumptions="n>=0") >>> knl = lp.split_iname(knl, "i", 128, ... outer_tag="g.0", inner_tag="l.0") - >>> knl = lp.set_options(knl, "write_code") + >>> knl = lp.set_options(knl, write_code=True) >>> evt, (out,) = knl(queue, a=x_vec_dev) #define lid(N) ((int) get_local_id(N)) ... @@ -774,7 +774,7 @@ assumption: >>> knl = lp.split_iname(knl, "i", 4) >>> knl = lp.tag_inames(knl, dict(i_inner="unr")) >>> knl = lp.prioritize_loops(knl, "i_outer,i_inner") - >>> knl = lp.set_options(knl, "write_code") + >>> knl = lp.set_options(knl, write_code=True) >>> evt, (out,) = knl(queue, a=x_vec_dev) #define lid(N) ((int) get_local_id(N)) ... @@ -802,7 +802,7 @@ enabling some cost savings: >>> knl = orig_knl >>> knl = lp.split_iname(knl, "i", 4, slabs=(0, 1), inner_tag="unr") - >>> knl = lp.set_options(knl, "write_code") + >>> knl = lp.set_options(knl, write_code=True) >>> knl = lp.prioritize_loops(knl, "i_outer,i_inner") >>> evt, (out,) = knl(queue, a=x_vec_dev) #define lid(N) ((int) get_local_id(N)) @@ -898,7 +898,7 @@ memory, local to each work item. .. doctest:: - >>> knl = lp.set_options(knl, "write_code") + >>> knl = lp.set_options(knl, write_code=True) >>> evt, (out1, out2) = knl(queue, a=x_vec_dev) #define lid(N) ((int) get_local_id(N)) ... @@ -959,7 +959,7 @@ Consider the following example: ... """) >>> knl = lp.tag_inames(knl, dict(i_outer="g.0", i_inner="l.0")) >>> knl = lp.set_temporary_address_space(knl, "a_temp", "local") - >>> knl = lp.set_options(knl, "write_code") + >>> knl = lp.set_options(knl, write_code=True) >>> evt, (out,) = knl(queue, a=x_vec_dev) #define lid(N) ((int) get_local_id(N)) ... @@ -1024,7 +1024,7 @@ transformation exists in :func:`loopy.add_prefetch`: ... out[16*i_outer + i_inner] = sum(k, a[16*i_outer + i_inner]) ... """) >>> knl = lp.tag_inames(knl, dict(i_outer="g.0", i_inner="l.0")) - >>> knl = lp.set_options(knl, "write_code") + >>> knl = lp.set_options(knl, write_code=True) >>> knl_pf = lp.add_prefetch(knl, "a") >>> evt, (out,) = knl_pf(queue, a=x_vec_dev) #define lid(N) ((int) get_local_id(N)) @@ -1482,7 +1482,7 @@ When we ask to see the code, the issue becomes apparent: .. doctest:: - >>> knl = lp.set_options(knl, "write_code") + >>> knl = lp.set_options(knl, write_code=True) >>> from warnings import catch_warnings >>> with catch_warnings(): ... filterwarnings("always", category=lp.LoopyWarning) diff --git a/test/test_callables.py b/test/test_callables.py index 0764d1f63..e092ae0da 100644 --- a/test/test_callables.py +++ b/test/test_callables.py @@ -171,7 +171,7 @@ def test_register_knl_with_hw_axes(ctx_factory, inline): knl = lp.merge([caller_knl, callee_knl]) - knl = lp.set_options(knl, "return_dict") + knl = lp.set_options(knl, return_dict=True) if inline: knl = lp.inline_callable_kernel(knl, "linear_combo") @@ -922,7 +922,7 @@ def test_non1_step_slices(ctx_factory, start, inline): t_unit = lp.merge([t_unit, callee]) - t_unit = lp.set_options(t_unit, "return_dict") + t_unit = lp.set_options(t_unit, return_dict=True) if inline: t_unit = lp.inline_callable_kernel(t_unit, "squared_arange") diff --git a/test/test_expression.py b/test/test_expression.py index e98933575..9b4e1fbc5 100644 --- a/test/test_expression.py +++ b/test/test_expression.py @@ -516,7 +516,7 @@ def test_complex_support(ctx_factory, target): ], target=target(), seq_dependencies=True) - knl = lp.set_options(knl, "return_dict") + knl = lp.set_options(knl, return_dict=True) n = 10 diff --git a/test/test_target.py b/test/test_target.py index b37b60eec..6a0c26fd9 100644 --- a/test/test_target.py +++ b/test/test_target.py @@ -438,7 +438,7 @@ def test_nan_support(ctx_factory, target): [lp.GlobalArg("a", is_input=False, shape=tuple()), ...], seq_dependencies=True, target=target()) - knl = lp.set_options(knl, "return_dict") + knl = lp.set_options(knl, return_dict=True) if target == lp.PyOpenCLTarget: evt, out_dict = knl(queue) @@ -478,7 +478,7 @@ def test_opencl_emits_ternary_operators_correctly(ctx_factory, target): """, seq_dependencies=True, target=target()) - knl = lp.set_options(knl, "return_dict") + knl = lp.set_options(knl, return_dict=True) if target == lp.PyOpenCLTarget: evt, out_dict = knl(queue) @@ -534,7 +534,7 @@ def test_inf_support(ctx_factory, target, dtype): dtype=dtype) ], target=target()) - knl = lp.set_options(knl, "return_dict") + knl = lp.set_options(knl, return_dict=True) if target == lp.PyOpenCLTarget: _, out_dict = knl(queue) @@ -640,7 +640,7 @@ def test_pyopencl_target_with_global_temps_with_base_storage(ctx_factory): ...], seq_dependencies=True) knl = lp.tag_inames(knl, {"i": "g.0", "j": "g.0"}) - knl = lp.set_options(knl, "return_dict") + knl = lp.set_options(knl, return_dict=True) my_allocator = RecordingAllocator(cq) _, out = knl(cq, allocator=my_allocator) -- GitLab