diff --git a/src/common/dlopencl.c b/src/common/dlopencl.c index 0f3cfb4f1de6..6d59c717cf66 100644 --- a/src/common/dlopencl.c +++ b/src/common/dlopencl.c @@ -1,6 +1,6 @@ /* This file is part of darktable, - Copyright (C) 2011-2023 darktable developers. + Copyright (C) 2011-2026 darktable developers. darktable is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +22,10 @@ #include "common/dynload.h" #include "common/dlopencl.h" +#ifdef __APPLE__ +#include +#endif + #include #include #include @@ -36,6 +40,19 @@ static const char *ocllib[] = { "/System/Library/Frameworks/OpenCL.framework/Ver static const char *ocllib[] = { "libOpenCL", "libOpenCL.so", "libOpenCL.so.1", NULL }; #endif +void dt_dlopencl_close(dt_dlopencl_t *ocl) +{ + free(ocl->symbols); + g_free(ocl->library); +#ifndef __APPLE__ + if(!g_module_close(ocl->gmodule)) + dt_print(DT_DEBUG_OPENCL, "Couldn't close OpenCL library"); +#else + if(dlclose(ocl->gmodule)) + dt_print(DT_DEBUG_OPENCL, "Couldn't close OpenCL library"); +#endif + free(ocl); +} /* only for debugging: default noop function for all unassigned function pointers */ void dt_dlopencl_noop(void) @@ -63,9 +80,9 @@ dt_dlopencl_t *dt_dlopencl_init(const char *name) library = name; module = dt_gmodule_open(library); if(module == NULL) - dt_print(DT_DEBUG_OPENCL, "[dt_dlopencl_init] could not find specified opencl runtime library '%s'", library); + dt_print_nts(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, "[dt_dlopencl_init] could not find specified opencl runtime library '%s'\n", library); else - dt_print(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, "[dt_dlopencl_init] found specified opencl runtime library '%s'", library); + dt_print_nts(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, "[dt_dlopencl_init] found specified opencl runtime library '%s'\n", library); } else { @@ -75,15 +92,18 @@ dt_dlopencl_t *dt_dlopencl_init(const char *name) library = *iter; module = dt_gmodule_open(library); if(module == NULL) - dt_print(DT_DEBUG_OPENCL, "[dt_dlopencl_init] could not find default opencl runtime library '%s'", library); + dt_print_nts(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, "[dt_dlopencl_init] could not find default opencl runtime library '%s'\n", library); else - dt_print(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, "[dt_dlopencl_init] found default opencl runtime library '%s'", library); + dt_print_nts(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, "[dt_dlopencl_init] found default opencl runtime library '%s'\n", library); iter++; } } if(module == NULL) + { + dt_print_nts(DT_DEBUG_ALWAYS, "[dt_dlopencl_init] could not find any opencl runtime library\n"); return NULL; + } /* now bind symbols */ ocl = malloc(sizeof(dt_dlopencl_t)); @@ -98,6 +118,7 @@ dt_dlopencl_t *dt_dlopencl_init(const char *name) if(ocl->symbols == NULL) { + dt_print_nts(DT_DEBUG_ALWAYS, "[dt_dlopencl_init] could not find symbols in opencl runtime library\n"); free(ocl); free(module); return NULL; @@ -209,7 +230,9 @@ dt_dlopencl_t *dt_dlopencl_init(const char *name) ocl->have_opencl = success; if(!success) - dt_print(DT_DEBUG_OPENCL, "[opencl_init] could not load all required symbols from library"); + dt_print_nts(DT_DEBUG_OPENCL, "[opencl_init] could not load all required symbols from library\n"); + else + ocl->gmodule = module->gmodule; free(module); diff --git a/src/common/dlopencl.h b/src/common/dlopencl.h index b30703857204..9d8434c60de3 100644 --- a/src/common/dlopencl.h +++ b/src/common/dlopencl.h @@ -208,13 +208,16 @@ typedef struct dt_dlopencl_symbols_t dt_clEnqueueWaitForEvents_t dt_clEnqueueWaitForEvents; } dt_dlopencl_symbols_t; - - typedef struct dt_dlopencl_t { gboolean have_opencl; dt_dlopencl_symbols_t *symbols; char *library; +#ifndef __APPLE__ + GModule *gmodule; +#else + void *gmodule; +#endif } dt_dlopencl_t; /* default noop function for all unassigned function pointers */ @@ -223,6 +226,9 @@ void dt_dlopencl_noop(void); /* dynamically load OpenCL library and bind needed functions */ dt_dlopencl_t *dt_dlopencl_init(const char *); +/* dynamically close OpenCL library opened by dt_dlopencl_init() */ +void dt_dlopencl_close(dt_dlopencl_t *ocl); + #endif // HAVE_OPENCL // clang-format off diff --git a/src/common/opencl.c b/src/common/opencl.c index a1f5ca4a6cc2..a3ccbd42caf9 100644 --- a/src/common/opencl.c +++ b/src/common/opencl.c @@ -544,7 +544,6 @@ static gboolean _opencl_device_init(dt_opencl_t *cl, char *filename = calloc(PATH_MAX, sizeof(char)); char *confentry = calloc(PATH_MAX, sizeof(char)); char *binname = calloc(PATH_MAX, sizeof(char)); - dt_print_nts(DT_DEBUG_OPENCL, "\n[dt_opencl_device_init]\n"); // test GPU availability, vendor, memory, image support etc: (cl->dlocl->symbols->dt_clGetDeviceInfo)(devid, CL_DEVICE_AVAILABLE, @@ -1061,9 +1060,9 @@ static gboolean _opencl_device_init(dt_opencl_t *cl, if(!programname || programname[0] == '\0' || prog < 0) { - dt_print(DT_DEBUG_OPENCL, + dt_print_nts(DT_DEBUG_OPENCL, "[dt_opencl_device_init] malformed entry in programs.conf `%s';" - " ignoring it!", confentry); + " ignoring it!\n", confentry); continue; } @@ -1071,16 +1070,16 @@ static gboolean _opencl_device_init(dt_opencl_t *cl, "%s" G_DIR_SEPARATOR_S "%s", kerneldir, programname); snprintf(binname, PATH_MAX * sizeof(char), "%s" G_DIR_SEPARATOR_S "%s.bin", cachedir, programname); - dt_print(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, - "[dt_opencl_device_init] testing program `%s' ..", programname); + dt_print_nts(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, + "[dt_opencl_device_init] testing program `%s' ..\n", programname); gboolean loaded_cached; char md5sum[33]; if(_opencl_load_program(dev, prog, programname, filename, binname, cachedir, md5sum, includemd5, &loaded_cached) && _opencl_build_program(dev, prog, binname, cachedir, md5sum, loaded_cached)) { - dt_print(DT_DEBUG_OPENCL, - "[dt_opencl_device_init] failed to compile program `%s'!", + dt_print_nts(DT_DEBUG_OPENCL, + "[dt_opencl_device_init] failed to compile program `%s'!\n", programname); fclose(f); g_strfreev(tokens); @@ -1093,7 +1092,7 @@ static gboolean _opencl_device_init(dt_opencl_t *cl, fclose(f); dt_print_nts(DT_DEBUG_OPENCL, - " KERNEL LOADING TIME: %2.4lf sec\n", dt_get_lap_time(&tstart)); + " KERNEL LOADING TIME: %2.4lf sec\n", dt_get_lap_time(&tstart)); } else { @@ -1165,14 +1164,14 @@ void dt_opencl_init(dt_opencl_t *cl, if(exclude_opencl) { - dt_print(DT_DEBUG_OPENCL, - "[opencl_init] opencl disabled due to explicit user request"); + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_init] opencl disabled due to explicit user request\n"); goto finally; } if(!opencl_requested) - dt_print(DT_DEBUG_OPENCL, - "[opencl_init] opencl disabled via darktable preferences"); + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_init] opencl disabled via darktable preferences\n"); // look for explicit definition of opencl_runtime library in preferences const char *library = dt_conf_get_string_const("opencl_library"); @@ -1182,17 +1181,17 @@ void dt_opencl_init(dt_opencl_t *cl, if(cl->dlocl == NULL) { logerror = _("no working OpenCL library found"); - dt_print(DT_DEBUG_OPENCL, + dt_print_nts(DT_DEBUG_OPENCL, "[opencl_init] no working opencl '%s' library found." - " Continue with opencl disabled", + " Continue with opencl disabled\n", (strlen(library) == 0) ? "default path" : library); goto finally; } else { - dt_print(DT_DEBUG_OPENCL, + dt_print_nts(DT_DEBUG_OPENCL, "[opencl_init] opencl library '%s' found on your system and loaded," - " preference '%s'", + " preference '%s'\n", cl->dlocl->library, (strlen(library) == 0) ? "default path" : library); } @@ -1212,8 +1211,8 @@ void dt_opencl_init(dt_opencl_t *cl, cl_int err = (cl->dlocl->symbols->dt_clGetPlatformIDs)(0, NULL, &num_platforms); if((err != CL_SUCCESS) || (num_platforms == 0)) { - dt_print(DT_DEBUG_OPENCL, - "[opencl_init] %i platforms detected, error: %s", + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_init] %i platforms detected, error: %s\n", num_platforms, cl_errstr(err)); goto finally; } @@ -1223,19 +1222,19 @@ void dt_opencl_init(dt_opencl_t *cl, (DT_OPENCL_MAX_PLATFORMS, all_platforms, &num_platforms); if(err != CL_SUCCESS) { - dt_print(DT_DEBUG_OPENCL, - "[opencl_init] could not get platforms IDs: %s", cl_errstr(err)); + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_init] could not get platforms IDs: %s\n", cl_errstr(err)); goto finally; } if(num_platforms == 0) { - dt_print(DT_DEBUG_OPENCL, "[opencl_init] no opencl platform available"); + dt_print_nts(DT_DEBUG_OPENCL, "[opencl_init] no opencl platform available\n"); goto finally; } logerror = NULL; - dt_print(DT_DEBUG_OPENCL, - "[opencl_init] found %d platform%s", + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_init] found %d platform%s\n", num_platforms, num_platforms > 1 ? "s" : ""); // safety check for platforms; we must not have several versions for the same platform @@ -1252,8 +1251,8 @@ void dt_opencl_init(dt_opencl_t *cl, for(int k = 0; k < n; k++) { if(!strcmp(platforms + n * DT_OPENCL_CBUFFSIZE, platforms + k * DT_OPENCL_CBUFFSIZE)) - dt_print(DT_DEBUG_OPENCL, - "[opencl_init] possibly a multiple platform problem for `%s'", + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_init] WARNING: possibly a multiple platform problem for `%s'\n", platforms + n * DT_OPENCL_CBUFFSIZE); } } @@ -1304,18 +1303,18 @@ void dt_opencl_init(dt_opencl_t *cl, { if(!valid_platform) { - dt_print(DT_DEBUG_OPENCL, - "[check platform] platform '%s' with key '%s' is NOT active", + dt_print_nts(DT_DEBUG_OPENCL, + "[check platform] platform '%s' with key '%s' is NOT active\n", platform_name, platform_key); } else if((errn == CL_SUCCESS) && (errv == CL_SUCCESS)) - dt_print(DT_DEBUG_OPENCL, - "[opencl_init] no devices found for %s (vendor) - %s (name)", + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_init] no devices found for %s (vendor) - %s (name)\n", platform_vendor, platform_name); else { - dt_print(DT_DEBUG_OPENCL, - "[opencl_init] no devices found for unknown platform"); + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_init] no devices found for unknown platform\n"); logerror = _("no devices found for unknown platform"); } all_num_devices[n] = 0; @@ -1329,8 +1328,8 @@ void dt_opencl_init(dt_opencl_t *cl, if(err != CL_SUCCESS) { all_num_devices[n] = 0; - dt_print(DT_DEBUG_OPENCL, - "[opencl_init] could not get profile for platform '%s': %s", + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_init] could not get profile for platform '%s': %s\n", platform_name, cl_errstr(err)); } else @@ -1338,8 +1337,8 @@ void dt_opencl_init(dt_opencl_t *cl, if(strcmp("FULL_PROFILE", profile) != 0) { all_num_devices[n] = 0; - dt_print(DT_DEBUG_OPENCL, - "[opencl_init] platform '%s' is not FULL_PROFILE", + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_init] platform '%s' is NOT FULL_PROFILE\n", platform_name); } } @@ -1361,7 +1360,7 @@ void dt_opencl_init(dt_opencl_t *cl, cl->dev = NULL; free(devices); devices = NULL; - dt_print(DT_DEBUG_OPENCL, + dt_print_nts(DT_DEBUG_ALWAYS, "[opencl_init] could not allocate memory for device resources"); logerror = _("not enough memory for OpenCL devices"); goto finally; @@ -1382,8 +1381,8 @@ void dt_opencl_init(dt_opencl_t *cl, if(err != CL_SUCCESS) { num_devices -= all_num_devices[n]; - dt_print(DT_DEBUG_OPENCL, - "[opencl_init] could not get devices list: %s", + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_init] could not get devices list: %s\n", cl_errstr(err)); } devs += all_num_devices[n]; @@ -1449,8 +1448,8 @@ void dt_opencl_init(dt_opencl_t *cl, } finally: - dt_print(DT_DEBUG_OPENCL, - "[opencl_init] FINALLY: opencl PREFERENCE=%s is %sAVAILABLE and %sENABLED.", + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_init] FINALLY: opencl PREFERENCE=%s is %sAVAILABLE and %sENABLED.\n", opencl_requested ? "ON" : "OFF", cl->inited ? "" : "NOT ", cl->enabled ? "" : "NOT "); @@ -1502,8 +1501,8 @@ void dt_opencl_init(dt_opencl_t *cl, dt_conf_set_string("opencl_checksum", checksum); // set scheduling profile to "default" dt_conf_set_string("opencl_scheduling_profile", "default"); - dt_print(DT_DEBUG_OPENCL, - "[opencl_init] set scheduling profile to default, setup has changed."); + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_init] set scheduling profile to default, setup has changed.\n"); dt_control_log(_("OpenCL scheduling profile set to default, setup has changed")); } // apply config settings for scheduling profile: sets device @@ -1659,9 +1658,7 @@ void dt_opencl_cleanup(dt_opencl_t *cl) if(cl->dlocl) { - free(cl->dlocl->symbols); - g_free(cl->dlocl->library); - free(cl->dlocl); + dt_dlopencl_close(cl->dlocl); } free(cl->dev); @@ -2105,15 +2102,15 @@ static FILE *_fopen_stat(const char *filename, struct stat *st) FILE *f = g_fopen(filename, "rb"); if(!f) { - dt_print(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, - "[opencl_fopen_stat] could not open file `%s'!", filename); + dt_print_nts(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, + "[opencl_fopen_stat] could not open file `%s'\n", filename); return NULL; } const int fd = fileno(f); if(fstat(fd, st) < 0) { - dt_print(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, - "[opencl_fopen_stat] could not stat file `%s'!", filename); + dt_print_nts(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, + "[opencl_fopen_stat] could not stat file `%s'\n", filename); return NULL; } return f; @@ -2141,8 +2138,8 @@ static void _opencl_md5sum(const char **files, if(!f) { - dt_print(DT_DEBUG_OPENCL, - "[opencl_md5sums] could not open file `%s'!", filename); + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_md5sums] could not open file `%s'\n", filename); *md5sums = NULL; continue; } @@ -2152,8 +2149,8 @@ static void _opencl_md5sum(const char **files, if(!file) { - dt_print(DT_DEBUG_OPENCL, - "[opencl_md5sums] could not allocate buffer for file `%s'!", filename); + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_md5sums] could not allocate buffer for file `%s'\n", filename); *md5sums = NULL; fclose(f); continue; @@ -2165,8 +2162,8 @@ static void _opencl_md5sum(const char **files, if(rd != filesize) { free(file); - dt_print(DT_DEBUG_OPENCL, - "[opencl_md5sums] could not read all of file `%s'!", filename); + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_md5sums] could not read all of file `%s'\n", filename); *md5sums = NULL; continue; } @@ -2196,17 +2193,17 @@ static gboolean _opencl_load_program(const int dev, if(prog < 0 || prog >= DT_OPENCL_MAX_PROGRAMS) { - dt_print(DT_DEBUG_OPENCL, - "[opencl_load_source] invalid program number `%d' of file `%s'!", prog, + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_load_source] invalid program number `%d' of file `%s'\n", prog, filename); return FALSE; } if(cl->dev[dev].program_used[prog]) { - dt_print(DT_DEBUG_OPENCL, + dt_print_nts(DT_DEBUG_OPENCL, "[opencl_load_source] program number `%d' already in use" - " when loading file `%s'!", prog, + " when loading file `%s'\n", prog, filename); return FALSE; } @@ -2223,9 +2220,8 @@ static gboolean _opencl_load_program(const int dev, if(rd != filesize) { free(file); - dt_print(DT_DEBUG_OPENCL, - "[opencl_load_source] could not read all" - " of file `%s' for program number %d!", + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_load_source] could not read all of file `%s' for program number %d\n", filename, prog); return FALSE; } @@ -2304,8 +2300,8 @@ static gboolean _opencl_load_program(const int dev, rd = 0; if(rd != cached_filesize) { - dt_print(DT_DEBUG_OPENCL, - "[opencl_load_program] could not read all of file '%s' MD5: %s!", + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_load_program] could not read all of file '%s' MD5: %s\n", binname, md5sum); } else @@ -2315,9 +2311,9 @@ static gboolean _opencl_load_program(const int dev, (const unsigned char **)&cached_content, NULL, &err); if(err != CL_SUCCESS) { - dt_print(DT_DEBUG_OPENCL, + dt_print_nts(DT_DEBUG_OPENCL, "[opencl_load_program] could not load cached binary" - " program from file '%s' MD5: '%s'! (%s)", + " program from file '%s' MD5: '%s'! (%s)\n", binname, md5sum, cl_errstr(err)); } else @@ -2351,7 +2347,7 @@ static gboolean _opencl_load_program(const int dev, g_unlink(dup); #endif //!defined(_WIN32) - dt_print(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, + dt_print_nts(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, "[opencl_load_program] could not load cached binary program," " trying to compile source\n"); @@ -2362,8 +2358,8 @@ static gboolean _opencl_load_program(const int dev, free(file); if((err != CL_SUCCESS) || (cl->dev[dev].program[prog] == NULL)) { - dt_print(DT_DEBUG_OPENCL, - "[opencl_load_source] could not create program from file `%s'! (%s)", + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_load_source] could not create program from file `%s'! (%s)\n", filename, cl_errstr(err)); return FALSE; } @@ -2375,13 +2371,13 @@ static gboolean _opencl_load_program(const int dev, else { free(file); - dt_print(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, + dt_print_nts(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, "[opencl_load_program] loaded cached" - " binary program from file '%s' MD5: '%s' ", binname, md5sum); + " binary program from file '%s' MD5: '%s'\n", binname, md5sum); } - dt_print(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, - "[opencl_load_program] successfully loaded program from '%s' MD5: '%s'", + dt_print_nts(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, + "[opencl_load_program] successfully loaded program from '%s' MD5: '%s'\n", filename, md5sum); return TRUE; @@ -2417,26 +2413,26 @@ static gboolean _opencl_build_program(const int dev, } if(err != CL_SUCCESS) - dt_print(DT_DEBUG_OPENCL, - "[opencl_build_program] could not build program: %s", cl_errstr(err)); + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_build_program] could not build program: %s\n", cl_errstr(err)); else - dt_print(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, - "[opencl_build_program] successfully built program"); + dt_print_nts(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, + "[opencl_build_program] successfully built program\n"); cl_build_status build_status; (cl->dlocl->symbols->dt_clGetProgramBuildInfo)(program, cl->dev[dev].devid, CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL); - dt_print(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, - "[opencl_build_program] BUILD STATUS: %d", build_status); + dt_print_nts(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, + "[opencl_build_program] BUILD STATUS: %d\n", build_status); char *build_log; size_t ret_val_size; (cl->dlocl->symbols->dt_clGetProgramBuildInfo)(program, cl->dev[dev].devid, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size); - if(ret_val_size != SIZE_MAX) + if(ret_val_size > 2 && ret_val_size < 0x100000) // we don't want to see nothing or crazy things { build_log = malloc(sizeof(char) * (ret_val_size + 1)); if(build_log) @@ -2447,8 +2443,8 @@ static gboolean _opencl_build_program(const int dev, build_log[ret_val_size] = '\0'; - dt_print(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, "BUILD LOG:"); - dt_print(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, "%s", build_log); + dt_print_nts(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, "BUILD LOG:\n"); + dt_print_nts(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, "%s\n", build_log); free(build_log); } @@ -2459,8 +2455,8 @@ static gboolean _opencl_build_program(const int dev, if(!loaded_cached) { - dt_print(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, - "[opencl_build_program] saving binary"); + dt_print_nts(DT_DEBUG_OPENCL | DT_DEBUG_VERBOSE, + "[opencl_build_program] saving binary\n"); cl_uint numdev = 0; err = (cl->dlocl->symbols->dt_clGetProgramInfo)(program, CL_PROGRAM_NUM_DEVICES, @@ -2468,8 +2464,8 @@ static gboolean _opencl_build_program(const int dev, &numdev, NULL); if(err != CL_SUCCESS) { - dt_print(DT_DEBUG_OPENCL, - "[opencl_build_program] CL_PROGRAM_NUM_DEVICES failed: %s", + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_build_program] CL_PROGRAM_NUM_DEVICES failed: %s\n", cl_errstr(err)); return TRUE; } @@ -2480,8 +2476,8 @@ static gboolean _opencl_build_program(const int dev, devices, NULL); if(err != CL_SUCCESS) { - dt_print(DT_DEBUG_OPENCL, - "[opencl_build_program] CL_PROGRAM_DEVICES failed: %s", cl_errstr(err)); + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_build_program] CL_PROGRAM_DEVICES failed: %s\n", cl_errstr(err)); free(devices); return TRUE; } @@ -2492,8 +2488,8 @@ static gboolean _opencl_build_program(const int dev, binary_sizes, NULL); if(err != CL_SUCCESS) { - dt_print(DT_DEBUG_OPENCL, - "[opencl_build_program] CL_PROGRAM_BINARY_SIZES failed: %s", + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_build_program] CL_PROGRAM_BINARY_SIZES failed: %s\n", cl_errstr(err)); free(binary_sizes); free(devices); @@ -2508,8 +2504,8 @@ static gboolean _opencl_build_program(const int dev, binaries, NULL); if(err != CL_SUCCESS) { - dt_print(DT_DEBUG_OPENCL, - "[opencl_build_program] CL_PROGRAM_BINARIES failed: %s", + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_build_program] CL_PROGRAM_BINARIES failed: %s\n", cl_errstr(err)); goto ret; } @@ -2558,8 +2554,8 @@ static gboolean _opencl_build_program(const int dev, free(binary_sizes); free(devices); if(err != CL_SUCCESS) - dt_print(DT_DEBUG_OPENCL, - "[dt_opencl_build_program] problems while writing OpenCL kernel files"); + dt_print_nts(DT_DEBUG_OPENCL, + "[dt_opencl_build_program] problems while writing OpenCL kernel files\n"); } return err != CL_SUCCESS; @@ -2576,8 +2572,8 @@ int dt_opencl_create_kernel(const int prog, if(k >= DT_OPENCL_MAX_KERNELS) { - dt_print(DT_DEBUG_OPENCL, - "[opencl_create_kernel] too many kernels! can't create kernel `%s'", + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_create_kernel] too many kernels! can't create kernel `%s'\n", name); return -1; } @@ -2608,8 +2604,8 @@ static gboolean _check_kernel(const int dev, (cl->dev[dev].program[prog], cl->name_saved[kernel], &err); if(err != CL_SUCCESS) { - dt_print(DT_DEBUG_OPENCL, - "[opencl_create_kernel] could not create kernel `%s' for '%s' id=%d: (%s)", + dt_print_nts(DT_DEBUG_OPENCL, + "[opencl_create_kernel] could not create kernel `%s' for '%s' id=%d: (%s)\n", cl->name_saved[kernel], cl->dev[dev].fullname, dev, cl_errstr(err)); cl->dev[dev].kernel_used[kernel] = FALSE; cl->name_saved[kernel] = NULL; // don't try again @@ -2700,8 +2696,8 @@ cl_int _opencl_set_kernel_arg(const int dev, if(err != CL_SUCCESS) dt_print(DT_DEBUG_OPENCL, - "[opencl_set_kernel_arg] error kernel `%s' (%i) on device %d: %s", - darktable.opencl->name_saved[kernel], kernel, dev, cl_errstr(err)); + "[opencl_set_kernel_arg] error kernel `%s' (%i) on device `%s' id=%d: %s", + darktable.opencl->name_saved[kernel], kernel, cl->dev[dev].fullname, dev, cl_errstr(err)); return err; }