From fbd3750a67787ba1eb6ab30f0c45b5d59ddf1500 Mon Sep 17 00:00:00 2001 From: Vikas Katariya Date: Mon, 10 May 2021 16:22:39 +0100 Subject: [PATCH] Add test covergae for `clCloneKernel` with no args Clone a kernel with no args and enqueue. The test uses `test_kernel_empty` kernel program with no arguments. Signed-off-by: Vikas Katariya --- test_conformance/api/test_clone_kernel.cpp | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/test_conformance/api/test_clone_kernel.cpp b/test_conformance/api/test_clone_kernel.cpp index 1a94ff2e7f..9754df4880 100644 --- a/test_conformance/api/test_clone_kernel.cpp +++ b/test_conformance/api/test_clone_kernel.cpp @@ -93,6 +93,7 @@ const char* clone_kernel_test_kernel[] = { "{\n" " buffer->store[0] = iarg;\n" "}\n" + "__kernel void test_kernel_empty(){}\n" }; typedef struct @@ -682,6 +683,60 @@ int test_cloned_kernel_exec_info(cl_device_id deviceID, cl_context context, return TEST_PASS; } +int test_empty_enqueue_helper(cl_command_queue queue, cl_kernel* srcKernel) +{ + cl_int error; + size_t ndrange1 = 1; + + // enqueue - srcKernel + error = clEnqueueNDRangeKernel(queue, *srcKernel, 1, NULL, &ndrange1, NULL, + 0, NULL, NULL); + test_error(error, "clEnqueueNDRangeKernel failed"); + + error = clFinish(queue); + test_error(error, "clFinish failed"); + + return TEST_PASS; +} + +int test_cloned_kernel_empty_args(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) +{ + cl_int error; + clProgramWrapper program; + clKernelWrapper srcKernel; + + // Create srcKernel to test with + error = create_single_kernel_helper(context, &program, &srcKernel, 1, + clone_kernel_test_kernel, + "test_kernel_empty"); + test_error(error, + "Unable to create srcKernel for test_cloned_kernel_empty_args"); + + // enqueue - srcKernel + if (test_empty_enqueue_helper(queue, &srcKernel) != 0) + { + test_fail("test_empty_enqueue_helper failed for srcKernel.\n"); + } + + // clone the srcKernel + clKernelWrapper cloneKernel_1 = clCloneKernel(srcKernel, &error); + test_error(error, "clCloneKernel failed for cloneKernel_1"); + + if (test_empty_enqueue_helper(queue, &cloneKernel_1) != 0) + { + test_fail("test_empty_enqueue_helper failed for cloneKernel_1.\n"); + } + + // enqueue - srcKernel again + if (test_empty_enqueue_helper(queue, &srcKernel) != 0) + { + test_fail("test_empty_enqueue_helper failed for srcKernel on retry.\n"); + } + + return TEST_PASS; +} + int test_clone_kernel(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) { @@ -702,5 +757,11 @@ int test_clone_kernel(cl_device_id deviceID, cl_context context, test_fail("clCloneKernel test_cloned_kernel_exec_info failed.\n"); } + if (test_cloned_kernel_empty_args(deviceID, context, queue, num_elements) + != 0) + { + test_fail("clCloneKernel test_cloned_kernel_empty_args failed.\n"); + } + return TEST_PASS; }