Skip to content

Commit

Permalink
add a test for new program build interface
Browse files Browse the repository at this point in the history
  • Loading branch information
bashbaug committed Jun 10, 2020
1 parent f5df4d0 commit f1bbd85
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
5 changes: 3 additions & 2 deletions include/CL/cl2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6633,7 +6633,9 @@ class Program : public detail::Wrapper<cl_program>
notifyFptr,
data);

return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
BuildLogType buildLog(1);
buildLog.push_back(std::make_pair(device, getBuildInfo<CL_PROGRAM_BUILD_LOG>(device)));
return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, buildLog);
}

cl_int build(
Expand All @@ -6649,7 +6651,6 @@ class Program : public detail::Wrapper<cl_program>
notifyFptr,
data);


return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
}

Expand Down
55 changes: 53 additions & 2 deletions tests/test_cl2hpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1645,9 +1645,8 @@ void testCopyHostToBuffer()

}


/****************************************************************************
* Tests for getBuildInfo
* Tests for building Programs
****************************************************************************/

static cl_int clGetDeviceInfo_testGetBuildInfo(
Expand Down Expand Up @@ -1717,6 +1716,58 @@ void testGetBuildInfo()
dev() = NULL;
}

static cl_int clBuildProgram_testBuildProgram(
cl_program program,
cl_uint num_devices,
const cl_device_id * device_list,
const char * options,
void (CL_CALLBACK * pfn_notify)(cl_program program, void * user_data),
void * user_data,
int num_calls)
{
TEST_ASSERT_EQUAL(program, make_program(0));
TEST_ASSERT_NOT_EQUAL(num_devices, 0);
TEST_ASSERT_NOT_EQUAL(device_list, NULL);
TEST_ASSERT_EQUAL(options, NULL);
TEST_ASSERT_EQUAL(pfn_notify, NULL);
TEST_ASSERT_EQUAL(user_data, NULL);

for (cl_uint i = 0; i < num_devices; i++) {
TEST_ASSERT_EQUAL(device_list[i], make_device_id(i));
}

return CL_SUCCESS;
}

void testBuildProgramSingleDevice()
{
cl_program program = make_program(0);
cl_device_id device_id = make_device_id(0);
int sc = 0;

// Creating a device queries the platform version:
clGetDeviceInfo_StubWithCallback(clGetDeviceInfo_platform);
clGetPlatformInfo_StubWithCallback(clGetPlatformInfo_version_1_2);

clBuildProgram_StubWithCallback(clBuildProgram_testBuildProgram);

// Building the program queries the program build log:
clRetainDevice_ExpectAndReturn(make_device_id(0), CL_SUCCESS);
clGetProgramBuildInfo_StubWithCallback(clGetProgramBuildInfo_testGetBuildInfo);
clGetProgramBuildInfo_StubWithCallback(clGetProgramBuildInfo_testGetBuildInfo);
clReleaseDevice_ExpectAndReturn(make_device_id(0), CL_SUCCESS);
clReleaseDevice_ExpectAndReturn(make_device_id(0), CL_SUCCESS);

clReleaseProgram_ExpectAndReturn(program, CL_SUCCESS);

cl::Program prog(program);
cl::Device dev(device_id);

cl_int errcode = prog.build(dev);

TEST_ASSERT_EQUAL(errcode, CL_SUCCESS);
}

/**
* Stub implementation of clGetCommandQueueInfo that returns first one image then none
*/
Expand Down

0 comments on commit f1bbd85

Please sign in to comment.