Cycles: Fix wrong numbering of OpenCL devices when some of them are skipped
Skipped devices did not reflect in the device number, which might result in bad array indices. This might also resolve T45037, and need to be ported to a release branch.
This commit is contained in:
@@ -3370,6 +3370,9 @@ void device_opencl_info(vector<DeviceInfo>& devices)
|
|||||||
vector<cl_platform_id> platform_ids;
|
vector<cl_platform_id> platform_ids;
|
||||||
cl_uint num_platforms = 0;
|
cl_uint num_platforms = 0;
|
||||||
|
|
||||||
|
/* Number of the devices we didn't use from the platform. */
|
||||||
|
cl_uint num_skip_devices = 0;
|
||||||
|
|
||||||
/* get devices */
|
/* get devices */
|
||||||
if(clGetPlatformIDs(0, NULL, &num_platforms) != CL_SUCCESS || num_platforms == 0)
|
if(clGetPlatformIDs(0, NULL, &num_platforms) != CL_SUCCESS || num_platforms == 0)
|
||||||
return;
|
return;
|
||||||
@@ -3386,8 +3389,11 @@ void device_opencl_info(vector<DeviceInfo>& devices)
|
|||||||
(getenv("CYCLES_OPENCL_TEST") != NULL) ||
|
(getenv("CYCLES_OPENCL_TEST") != NULL) ||
|
||||||
(getenv("CYCLES_OPENCL_SPLIT_KERNEL_TEST")) != NULL;
|
(getenv("CYCLES_OPENCL_SPLIT_KERNEL_TEST")) != NULL;
|
||||||
|
|
||||||
for(int platform = 0; platform < num_platforms; platform++, num_base += num_devices) {
|
for(int platform = 0;
|
||||||
num_devices = 0;
|
platform < num_platforms;
|
||||||
|
platform++, num_base += num_devices - num_skip_devices)
|
||||||
|
{
|
||||||
|
num_devices = num_skip_devices = 0;
|
||||||
if(clGetDeviceIDs(platform_ids[platform], opencl_device_type(), 0, NULL, &num_devices) != CL_SUCCESS || num_devices == 0)
|
if(clGetDeviceIDs(platform_ids[platform], opencl_device_type(), 0, NULL, &num_devices) != CL_SUCCESS || num_devices == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -3401,6 +3407,7 @@ void device_opencl_info(vector<DeviceInfo>& devices)
|
|||||||
string platform_name = pname;
|
string platform_name = pname;
|
||||||
|
|
||||||
/* add devices */
|
/* add devices */
|
||||||
|
int num_skip_devices = 0;
|
||||||
for(int num = 0; num < num_devices; num++) {
|
for(int num = 0; num < num_devices; num++) {
|
||||||
cl_device_id device_id = device_ids[num];
|
cl_device_id device_id = device_ids[num];
|
||||||
char name[1024] = "\0";
|
char name[1024] = "\0";
|
||||||
@@ -3413,6 +3420,7 @@ void device_opencl_info(vector<DeviceInfo>& devices)
|
|||||||
(platform_name == "AMD Accelerated Parallel Processing" &&
|
(platform_name == "AMD Accelerated Parallel Processing" &&
|
||||||
device_type == CL_DEVICE_TYPE_GPU)))
|
device_type == CL_DEVICE_TYPE_GPU)))
|
||||||
{
|
{
|
||||||
|
++num_skip_devices;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user