snprintf(kernel_file, sizeof(kernel_file), "%s.cl", name);
snprintf(dst_img, sizeof(dst_img), "%s.bmp", name);
snprintf(ref_img, sizeof(ref_img), "%s_ref.bmp", name);
- OCL_CALL (cl_kernel_init, kernel_file, name, SOURCE);
+ OCL_CALL (cl_kernel_init, kernel_file, name, SOURCE, NULL);
OCL_CREATE_BUFFER(buf[0], 0, sz, NULL);
OCL_CALL (clSetKernelArg, kernel, 0, sizeof(cl_mem), &buf[0]);
}
-#define CALL_INFO_AND_RET(TYPE, FUNC, OBJ) \
+#define CALL_INFO_AND_RET(TYPE, FUNC, ...) \
do { \
cl_int ret; \
size_t ret_size; \
\
Info_Result<TYPE>* info = cast_as<TYPE>(x.second); \
- ret = FUNC (OBJ, x.first, \
+ ret = FUNC (__VA_ARGS__, x.first, \
info->size, info->get_ret(), &ret_size); \
OCL_ASSERT((!ret)); \
OCL_ASSERT((info->check_result())); \
MAKE_UTEST_FROM_FUNCTION(get_queue_info);
+/* ***************************************************** *
+ * clGetProgramBuildInfo *
+ * ***************************************************** */
+#define CALL_PROG_BUILD_INFO_AND_RET(TYPE) CALL_INFO_AND_RET(TYPE, \
+ clGetProgramBuildInfo, program, device)
+
+void get_program_build_info(void)
+{
+ map<cl_program_info, void *> maps;
+ cl_build_status expect_status;
+ char build_opt[] = "-emit-llvm";
+ char log[] = "";
+ int sz;
+
+ OCL_CALL (cl_kernel_init, "compiler_if_else.cl", "compiler_if_else", SOURCE, build_opt);
+
+ /* Do our test.*/
+ expect_status = CL_BUILD_SUCCESS;
+ maps.insert(make_pair(CL_PROGRAM_BUILD_STATUS,
+ (void *)(new Info_Result<cl_build_status>(expect_status))));
+ sz = strlen(build_opt) + 1;
+ maps.insert(make_pair(CL_PROGRAM_BUILD_OPTIONS,
+ (void *)(new Info_Result<char *>(build_opt, sz))));
+ sz = strlen(log) + 1;
+ maps.insert(make_pair(CL_PROGRAM_BUILD_LOG, /* not supported now, just "" */
+ (void *)(new Info_Result<char *>(log, sz))));
+
+ std::for_each(maps.begin(), maps.end(), [](pair<cl_program_info, void *> x) {
+ switch (x.first) {
+ case CL_PROGRAM_BUILD_STATUS:
+ CALL_PROG_BUILD_INFO_AND_RET(cl_build_status);
+ break;
+ case CL_PROGRAM_BUILD_OPTIONS:
+ CALL_PROG_BUILD_INFO_AND_RET(char *);
+ break;
+ case CL_PROGRAM_BUILD_LOG:
+ CALL_PROG_BUILD_INFO_AND_RET(char *);
+ break;
+ default:
+ break;
+ }
+ });
+}
+
+MAKE_UTEST_FROM_FUNCTION(get_program_build_info);
}
int
-cl_kernel_init(const char *file_name, const char *kernel_name, int format)
+cl_kernel_init(const char *file_name, const char *kernel_name, int format, const char * build_opt)
{
cl_file_map_t *fm = NULL;
char *ker_path = NULL;
}
/* OCL requires to build the program even if it is created from a binary */
- OCL_CALL (clBuildProgram, program, 1, &device, NULL, NULL, NULL);
+ OCL_CALL (clBuildProgram, program, 1, &device, build_opt, NULL, NULL);
/* Create a kernel from the program */
kernel = clCreateKernel(program, kernel_name, &status);
goto error;
/* Load the kernel */
- if ((status = cl_kernel_init(file_name, kernel_name, format)) != CL_SUCCESS)
+ if ((status = cl_kernel_init(file_name, kernel_name, format, NULL)) != CL_SUCCESS)
goto error;
error:
#define OCL_CREATE_KERNEL(NAME) \
do { \
- OCL_CALL (cl_kernel_init, NAME".cl", NAME, SOURCE); \
+ OCL_CALL (cl_kernel_init, NAME".cl", NAME, SOURCE, NULL); \
} while (0)
#define OCL_CREATE_KERNEL_FROM_FILE(FILE_NAME, KERNEL_NAME) \
do { \
- OCL_CALL(cl_kernel_init, FILE_NAME".cl", KERNEL_NAME, SOURCE); \
+ OCL_CALL(cl_kernel_init, FILE_NAME".cl", KERNEL_NAME, SOURCE, NULL); \
} while (0)
#define OCL_FLUSH() \
extern int cl_ocl_init(void);
/* Init program and kernel for the test */
-extern int cl_kernel_init(const char *file_name, const char *kernel_name, int format);
+extern int cl_kernel_init(const char *file_name,
+ const char *kernel_name, int format, const char * build_opt);
/* init the bunch of global varaibles here */
extern int cl_test_init(const char *file_name, const char *kernel_name, int format);