Skip to content

Commit

Permalink
OpenCL device_info robustness: Use |= instead of +=
Browse files Browse the repository at this point in the history
Also fix a few weird syntaxes in opencl_common.c

See #5417
  • Loading branch information
magnumripper committed Dec 25, 2024
1 parent cf7bcbc commit ccb69e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
1 change: 0 additions & 1 deletion run/opencl/opencl_device_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#ifndef OPENCL_DEVICE_INFO_H
#define OPENCL_DEVICE_INFO_H

//Copied from opencl_common.h
#define DEV_UNKNOWN 0 //0
#define DEV_CPU (1 << 0) //1
#define DEV_GPU (1 << 1) //2
Expand Down
23 changes: 11 additions & 12 deletions src/opencl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ static cl_ulong gws_test(size_t gws, unsigned int rounds, int sequential_id)
for (i = 0; (*multi_profilingEvent[i]); i++)
number_of_events++;

//** Get execution time **//
/* Get execution time */
for (i = 0; i < number_of_events; i++) {
char mult[32] = "";

Expand Down Expand Up @@ -2155,22 +2155,22 @@ static void load_device_info(int sequential_id)
else if (device == CL_DEVICE_TYPE_ACCELERATOR)
device_info[sequential_id] = DEV_ACCELERATOR;

device_info[sequential_id] += get_vendor_id(sequential_id);
device_info[sequential_id] += get_processor_family(sequential_id);
device_info[sequential_id] += get_byte_addressable(sequential_id);
device_info[sequential_id] |= get_vendor_id(sequential_id);
device_info[sequential_id] |= get_processor_family(sequential_id);
device_info[sequential_id] |= get_byte_addressable(sequential_id);

get_compute_capability(sequential_id, &major, &minor);

if (major) {
device_info[sequential_id] += (major == 2 ? DEV_NV_C2X : 0);
device_info[sequential_id] +=
device_info[sequential_id] |= (major == 2 ? DEV_NV_C2X : 0);
device_info[sequential_id] |=
(major == 3 && minor == 0 ? DEV_NV_C30 : 0);
device_info[sequential_id] +=
device_info[sequential_id] |=
(major == 3 && minor == 2 ? DEV_NV_C32 : 0);
device_info[sequential_id] +=
device_info[sequential_id] |=
(major == 3 && minor == 5 ? DEV_NV_C35 : 0);
device_info[sequential_id] += (major == 5 ? DEV_NV_MAXWELL : 0);
device_info[sequential_id] += (major >= 5 ? DEV_NV_MAXWELL_PLUS : 0);
device_info[sequential_id] |= (major == 5 ? DEV_NV_MAXWELL : 0);
device_info[sequential_id] |= (major >= 5 ? DEV_NV_MAXWELL_PLUS : 0);
}
}

Expand Down Expand Up @@ -2654,8 +2654,7 @@ cl_uint get_processor_family(int sequential_id)
if (*dname)
strlwr(&dname[1]);

if gpu_amd
(device_info[sequential_id]) {
if (gpu_amd(device_info[sequential_id])) {

if ((strstr(dname, "Cedar") || //AMD Radeon VLIW5
strstr(dname, "Redwood") || strstr(dname, "Juniper")
Expand Down

0 comments on commit ccb69e4

Please sign in to comment.