1 /* OpenCL error handling */
11 check_ocl_error(cl_int err, const char *what, const char *func, int line)
13 if (err != CL_SUCCESS) {
16 fprintf(stderr, "%s:%u: %s : error %d\n",
17 func, line, what, err);
20 return err != CL_SUCCESS;
23 const char *current_function;
25 const char *current_param;
28 report_ocl_error(char *dstbuf, size_t sz, cl_int err, const char *fmt)
30 static char full_fmt[1024];
31 if (err != CL_SUCCESS) {
32 snprintf(full_fmt, 1024, "<%s:%" PRIuS ": %s : error %d>",
33 current_function, current_line, fmt, err);
34 snprintf(dstbuf, sz, full_fmt, current_param);
36 return err != CL_SUCCESS;
40 report_ocl_error_old(char *where, size_t sz, cl_int err, const char *what, const char *func, int line)
42 if (err != CL_SUCCESS) {
43 snprintf(where, sz, "<%s:%d: %s : error %d>",
44 func, line, what, err);
46 return err != CL_SUCCESS;
49 #define CHECK_ERROR(what) if (check_ocl_error(error, what, __func__, __LINE__)) exit(1)
51 #define REPORT_ERROR(what) report_ocl_error_old(strbuf, bufsz, error, what, __func__, __LINE__)
52 #define REPORT_ERROR2(what) report_ocl_error(strbuf, bufsz, error, what)