Skip to content

Commit

Permalink
OpenCL maintenance 5.2
Browse files Browse the repository at this point in the history
We have some remaining issues with certain drivers/platforms/vendors, to allow runtime checks for
possibly avoiding critical OpenCL code we need more information kept in the OpenCL device struct.
  • Loading branch information
jenshannoschwalm authored and TurboGit committed Mar 1, 2025
1 parent 591e1e0 commit ca55f74
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/common/opencl.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ static gboolean _opencl_device_init(dt_opencl_t *cl,
cl->dev[dev].used_global_mem = 0;
cl->dev[dev].nvidia_sm_20 = FALSE;
cl->dev[dev].fullname = NULL;
cl->dev[dev].platform = NULL;
cl->dev[dev].device_version = NULL;
cl->dev[dev].cname = NULL;
cl->dev[dev].options = NULL;
cl->dev[dev].cflags = NULL;
Expand All @@ -493,6 +495,7 @@ static gboolean _opencl_device_init(dt_opencl_t *cl,
cl->dev[dev].asyncmode = FALSE;
cl->dev[dev].disabled = FALSE;
cl->dev[dev].headroom = 0;
cl->dev[dev].vendor_id = 0;
cl->dev[dev].tunehead = FALSE;
cl_device_id devid = cl->dev[dev].devid = devices[k];

Expand Down Expand Up @@ -634,8 +637,10 @@ static gboolean _opencl_device_init(dt_opencl_t *cl,
cl->crc = crc32(cl->crc, (const unsigned char *)platform_name, strlen(platform_name));
cl->crc = crc32(cl->crc, (const unsigned char *)device_name, strlen(device_name));

cl->dev[dev].platform = strdup(platform_name);
cl->dev[dev].fullname = strdup(fullname);
cl->dev[dev].cname = strdup(cname);
cl->dev[dev].vendor_id = vendor_id;

const gboolean newdevice = dt_opencl_read_device_config(dev);
dt_print_nts(DT_DEBUG_OPENCL,
Expand All @@ -646,7 +651,7 @@ static gboolean _opencl_device_init(dt_opencl_t *cl,
DT_CLDEVICE_HEAD, cl->dev[dev].cname);
dt_print_nts(DT_DEBUG_OPENCL,
" PLATFORM, VENDOR & ID: %s, %s%s, ID=%d\n",
platform_display_name, is_mesa ? "Mesa:" : "", platform_vendor, vendor_id);
cl->dev[dev].platform, is_mesa ? "Mesa:" : "", platform_vendor, vendor_id);
dt_print_nts(DT_DEBUG_OPENCL,
" CANONICAL NAME: %s\n", cl->dev[dev].cname);

Expand All @@ -671,6 +676,7 @@ static gboolean _opencl_device_init(dt_opencl_t *cl,
cl->dev[dev].disabled |= TRUE;
goto end;
}
cl->dev[dev].device_version = strdup(deviceversion);

(cl->dlocl->symbols->dt_clGetDeviceInfo)(devid, CL_DEVICE_TYPE,
sizeof(cl_device_type), &type, NULL);
Expand Down Expand Up @@ -707,7 +713,7 @@ static gboolean _opencl_device_init(dt_opencl_t *cl,
cl->dev[dev].micro_nap = (is_cpu_device) ? 1000 : 250;

dt_print_nts(DT_DEBUG_OPENCL, " DRIVER VERSION: %s\n", driverversion);
dt_print_nts(DT_DEBUG_OPENCL, " DEVICE VERSION: %s%s\n", deviceversion,
dt_print_nts(DT_DEBUG_OPENCL, " DEVICE VERSION: %s%s\n", cl->dev[dev].device_version,
cl->dev[dev].nvidia_sm_20 ? ", SM_20 SUPPORT" : "");
dt_print_nts(DT_DEBUG_OPENCL, " DEVICE_TYPE: %s%s%s%s\n",
((type & CL_DEVICE_TYPE_CPU) == CL_DEVICE_TYPE_CPU) ? "CPU" : "",
Expand Down Expand Up @@ -1510,6 +1516,8 @@ void dt_opencl_init(
free(cl->dev[i].eventtags);
}
free((void *)(cl->dev[i].fullname));
free((void *)(cl->dev[i].device_version));
free((void *)(cl->dev[i].platform));
free((void *)(cl->dev[i].cname));
free((void *)(cl->dev[i].options));
free((void *)(cl->dev[i].cflags));
Expand Down Expand Up @@ -1597,6 +1605,8 @@ void dt_opencl_cleanup(dt_opencl_t *cl)
}

free((void *)(cl->dev[i].fullname));
free((void *)(cl->dev[i].device_version));
free((void *)(cl->dev[i].platform));
free((void *)(cl->dev[i].cname));
free((void *)(cl->dev[i].options));
free((void *)(cl->dev[i].cflags));
Expand Down
5 changes: 5 additions & 0 deletions src/common/opencl.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ typedef struct dt_opencl_device_t
int maxeventslot;
gboolean nvidia_sm_20;
const char *fullname;
const char *platform;
const char *device_version;
const char *cname;
const char *options;
const char *cflags;
Expand Down Expand Up @@ -196,6 +198,9 @@ typedef struct dt_opencl_device_t
// all memory.
int headroom;

// lets keep the vendor for runtime checks
int vendor_id;

float advantage;
} dt_opencl_device_t;

Expand Down

0 comments on commit ca55f74

Please sign in to comment.