From 06d9db43a22711751c19f9cdb8ec30b2ea9ca52c Mon Sep 17 00:00:00 2001 From: Kaushik Kulkarni <kaushikcfd@gmail.com> Date: Wed, 26 May 2021 11:14:26 -0500 Subject: [PATCH] test gbarrier is translated from leaf callees to entrypoints --- test/test_callables.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/test_callables.py b/test/test_callables.py index f79f6e8f1..2118a0fd2 100644 --- a/test/test_callables.py +++ b/test/test_callables.py @@ -562,6 +562,41 @@ def test_callees_with_gbarriers_are_inlined(ctx_factory): assert (expected_out == out.get()).all() +def test_callees_with_gbarriers_are_inlined_with_nested_calls(ctx_factory): + ctx = ctx_factory() + queue = cl.CommandQueue(ctx) + + ones_and_zeros = lp.make_function( + "{[i, j]: 0<=i<6 and 0<=j<3}", + """ + x[i] = 0.0f + ...gbarrier + x[j] = 1.0f + """, + seq_dependencies=True, + name="ones_and_zeros") + + dummy_ones_and_zeros = lp.make_function( + "{[i]: 0<=i<6}", + """ + [i]: y[i] = ones_and_zeros() + """, + name="dummy_ones_and_zeros") + + t_unit = lp.make_kernel( + "{ : }", + """ + y[:] = dummy_ones_and_zeros() + """, [lp.GlobalArg("y", shape=6, dtype=lp.auto)]) + + t_unit = lp.merge([t_unit, dummy_ones_and_zeros, ones_and_zeros]) + evt, (out,) = t_unit(queue) + + expected_out = np.array([1, 1, 1, 0, 0, 0]).astype(np.float32) + + assert (expected_out == out.get()).all() + + def test_inlining_with_indirections(ctx_factory): ctx = ctx_factory() queue = cl.CommandQueue(ctx) -- GitLab