Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix opencl checksum calculation #18181

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/common/opencl.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ static gboolean _opencl_device_init(dt_opencl_t *cl,
cl->dev[dev].fullname = NULL;
cl->dev[dev].cname = NULL;
cl->dev[dev].options = NULL;
cl->dev[dev].cflags = NULL;
cl->dev[dev].memory_in_use = 0;
cl->dev[dev].peak_memory = 0;
cl->dev[dev].used_available = 0;
Expand Down Expand Up @@ -951,10 +952,12 @@ static gboolean _opencl_device_init(dt_opencl_t *cl,
gchar *my_option = g_strdup(compile_opt);
dt_conf_set_string(compile_option_name_cname, my_option);

cl->dev[dev].options = g_strdup_printf("-w %s %s -D%s=1 -I%s",
my_option,
cl->dev[dev].nvidia_sm_20 ? " -DNVIDIA_SM_20=1" : "",
_opencl_get_vendor_by_id(vendor_id), escapedkerneldir);
cl->dev[dev].cflags = g_strdup_printf("-w %s%s -D%s=1",
my_option,
cl->dev[dev].nvidia_sm_20 ? " -DNVIDIA_SM_20=1" : "",
_opencl_get_vendor_by_id(vendor_id));
cl->dev[dev].options = g_strdup_printf("%s -I%s",
cl->dev[dev].cflags, escapedkerneldir);

dt_print_nts(DT_DEBUG_OPENCL, " CL COMPILER OPTION: %s\n", my_option);
dt_print_nts(DT_DEBUG_OPENCL, " CL COMPILER COMMAND: %s\n", cl->dev[dev].options);
Expand Down Expand Up @@ -1519,6 +1522,7 @@ void dt_opencl_init(
free((void *)(cl->dev[i].fullname));
free((void *)(cl->dev[i].cname));
free((void *)(cl->dev[i].options));
free((void *)(cl->dev[i].cflags));
}
}

Expand Down Expand Up @@ -1611,6 +1615,7 @@ void dt_opencl_cleanup(dt_opencl_t *cl)
free((void *)(cl->dev[i].fullname));
free((void *)(cl->dev[i].cname));
free((void *)(cl->dev[i].options));
free((void *)(cl->dev[i].cflags));
}
free(cl->dev_priority_image);
free(cl->dev_priority_preview);
Expand Down Expand Up @@ -2195,6 +2200,8 @@ static gboolean _opencl_load_program(const int dev,
size_t len;

cl_device_id devid = cl->dev[dev].devid;

// We include driver & platform version in checksum
(cl->dlocl->symbols->dt_clGetDeviceInfo)
(devid, CL_DRIVER_VERSION, end - start, start, &len);
start += len;
Expand All @@ -2207,7 +2214,8 @@ static gboolean _opencl_load_program(const int dev,
(platform, CL_PLATFORM_VERSION, end - start, start, &len);
start += len;

len = g_strlcpy(start, cl->dev[dev].options, end - start);
// Include compiler flags for checksum
len = g_strlcpy(start, cl->dev[dev].cflags, end - start);
start += len;

/* make sure that the md5sums of all the includes are applied as well */
Expand Down
1 change: 1 addition & 0 deletions src/common/opencl.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ typedef struct dt_opencl_device_t
const char *fullname;
const char *cname;
const char *options;
const char *cflags;
cl_int summary;
size_t memory_in_use;
size_t peak_memory;
Expand Down
Loading