[Beignet] [Patch v2 06/10] runtime: fix clLinkProgram bug.
xionghu.luo at intel.com
xionghu.luo at intel.com
Wed Nov 25 22:00:01 PST 2015
From: Luo Xionghu <xionghu.luo at intel.com>
clLinkProgram need check the existence of "-cl-kernel-arg-info"
build_option of all the input_programs. User may link two SPIR
program and call clGetKernelArgInfo to query kernel args.
Signed-off-by: Luo Xionghu <xionghu.luo at intel.com>
---
src/cl_program.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/cl_program.c b/src/cl_program.c
index 63e05f7..598261d 100644
--- a/src/cl_program.c
+++ b/src/cl_program.c
@@ -625,6 +625,8 @@ cl_program_link(cl_context context,
err = CL_INVALID_LINKER_OPTIONS;
goto error;
}
+ const char kernel_arg_option[] = "-cl-kernel-arg-info";
+ cl_bool option_exist = CL_TRUE;
for(i = 0; i < num_input_programs; i++) {
//num_input_programs >0 and input_programs MUST not NULL, so compare with input_programs[0] directly.
if(input_programs[i]->binary_type == CL_PROGRAM_BINARY_TYPE_LIBRARY ||
@@ -632,6 +634,9 @@ cl_program_link(cl_context context,
input_programs[i]->binary_type == CL_PROGRAM_BINARY_TYPE_INTERMEDIATE) {
avialable_program++;
}
+ if(input_programs[i]->build_opts == NULL || strstr(input_programs[i]->build_opts, kernel_arg_option) == NULL ) {
+ option_exist = CL_FALSE;
+ }
}
//None of program contain a compilerd binary or library.
@@ -651,6 +656,11 @@ cl_program_link(cl_context context,
goto error;
}
+ if(option_exist) {
+ TRY_ALLOC (p->build_opts, cl_calloc(strlen(kernel_arg_option) + 1, sizeof(char)));
+ memcpy(p->build_opts, kernel_arg_option, strlen(kernel_arg_option));
+ }
+
if (!check_cl_version_option(p, options)) {
err = CL_BUILD_PROGRAM_FAILURE;
goto error;
--
1.9.1
More information about the Beignet
mailing list