Skip to content

Commit

Permalink
Add test covergae for clCloneKernel with no args
Browse files Browse the repository at this point in the history
Clone a kernel with no args and enqueue.
The test uses `test_kernel_empty` kernel program with no arguments.

Signed-off-by: Vikas Katariya <vikas.katariya@arm.com>
  • Loading branch information
jainvikas8 committed May 14, 2021
1 parent 9d945cc commit 0dc71f0
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions test_conformance/api/test_clone_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
}

0 comments on commit 0dc71f0

Please sign in to comment.