Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ut createkernels #279

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions tests/test_openclhpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4571,6 +4571,78 @@ void testgetObjectInfo() {
TEST_ASSERT_EQUAL(type, CL_GL_OBJECT_BUFFER);
TEST_ASSERT_EQUAL(bufobj, 0);
}

static cl_int clCreateKernelsInProgram_testcreateKernels(
cl_program program, cl_uint num_kernels, cl_kernel *kernels,
cl_uint *num_kernels_ret, int num_calls) {
switch (num_calls) {
case 0:
TEST_ASSERT_EQUAL(make_program(0), program);
TEST_ASSERT_EQUAL(0, num_kernels);
if (num_kernels_ret != nullptr)
{
*num_kernels_ret = 3;
}
return CL_SUCCESS;
case 1:
TEST_ASSERT_EQUAL(3, num_kernels);
TEST_ASSERT_EQUAL(nullptr, num_kernels_ret);
for (unsigned int i = 0; i < num_kernels; i++)
{
kernels[i] = make_kernel(i);
}

return CL_SUCCESS;
case 2:
TEST_ASSERT_EQUAL(make_program(1), program);
TEST_ASSERT_EQUAL(0, num_kernels);
TEST_ASSERT_NOT_NULL(num_kernels_ret);
if (num_kernels_ret != nullptr)
{
*num_kernels_ret = 0;
}

return CL_INVALID_PROGRAM_EXECUTABLE;
case 3:
TEST_ASSERT_EQUAL(nullptr, program);
TEST_ASSERT_EQUAL(0, num_kernels);
TEST_ASSERT_NOT_NULL(num_kernels_ret);
if (num_kernels_ret != nullptr)
{
*num_kernels_ret = 0;
}

return CL_INVALID_PROGRAM;
default:
return CL_SUCCESS;
}
}

void testCreateKernels() {
cl_int ret = 0;
cl::vector<cl::Kernel> kernels;

clCreateKernelsInProgram_StubWithCallback(clCreateKernelsInProgram_testcreateKernels);

ret = programPool[0].createKernels(&kernels);
TEST_ASSERT_EQUAL(CL_SUCCESS, ret);
TEST_ASSERT_EQUAL(3, kernels.size());
for (unsigned int i = 0; i < kernels.size(); i++)
{
kernels[i]() = nullptr;
}
kernels.clear();

ret = programPool[1].createKernels(&kernels);
TEST_ASSERT_EQUAL(CL_INVALID_PROGRAM_EXECUTABLE, ret);
TEST_ASSERT_EQUAL(true, kernels.empty());

cl::Program invalidProgram;
ret = invalidProgram.createKernels(&kernels);
TEST_ASSERT_EQUAL(CL_INVALID_PROGRAM, ret);
TEST_ASSERT_EQUAL(true, kernels.empty());
}

#if CL_HPP_TARGET_OPENCL_VERSION >= 210
static cl_int clGetHostTimer_testgetHostTimer(cl_device_id device,
cl_ulong *host_timestamp,
Expand Down