From 98f4c461d0be9b57e15bd68aa36ec3fd75896121 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Fri, 18 Jul 2014 04:25:45 -0700 Subject: [PATCH] client: group new (non-NVIDIA, non-AMD, non-INTEL) OpenCL device types by vendor name string rather than by CL_DEVICE_VENDOR_ID. This assumes that OpenCL reports identical vendor name strings for all devices from the same vendor on a given host. I incorrectly thought CL_DEVICE_VENDOR_ID was a numeric ID of the vendor which would be the same for each device from that vendor, but it is actually a unique numeric ID assigned by a given vendor to each device on a particular host. --- client/gpu_detect.cpp | 4 +++- client/gpu_opencl.cpp | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/client/gpu_detect.cpp b/client/gpu_detect.cpp index 1eb668fcae..ec41838249 100644 --- a/client/gpu_detect.cpp +++ b/client/gpu_detect.cpp @@ -478,7 +478,9 @@ int COPROCS::read_coproc_info_file(vector &warnings) { if (other_opencls[vendor_index].size() == 0) { continue; // Should never happen } - if (other_opencls[vendor_index][0].vendor_id == other_opencl.vendor_id) { + // Assumes that OpenCL reports identical vendor name strings + // for all devices from the same vendor on a given host. + if (!strcmp(other_opencls[vendor_index][0].vendor, other_opencl.vendor)) { break; // This vector contains coproc(s) from same vendor } } diff --git a/client/gpu_opencl.cpp b/client/gpu_opencl.cpp index 83f5cd3f4c..23b309d9bb 100644 --- a/client/gpu_opencl.cpp +++ b/client/gpu_opencl.cpp @@ -373,7 +373,13 @@ void COPROCS::get_opencl( // TODO: Eliminate this, or improve it #if TEST_OTHER_COPROC_LOGIC - safe_strcpy(prop.vendor, "Some Other GPU"); + if (is_NVIDIA(prop.vendor)) { + safe_strcpy(prop.vendor, "FAKE VENDOR X"); + } else if (is_AMD(prop.vendor)) { + safe_strcpy(prop.vendor, "FAKE VENDOR Y"); + } else { + safe_strcpy(prop.vendor, "FAKE VENDOR Z"); + } #endif prop.is_used = COPROC_UNUSED; @@ -532,7 +538,9 @@ void COPROCS::get_opencl( if (other_opencls[vendor_index].size() == 0) { continue; // Should never happen } - if (other_opencls[vendor_index][0].vendor_id == prop.vendor_id) { + // Assumes that OpenCL reports identical vendor name strings + // for all devices from the same vendor on a given host. + if (!strcmp(other_opencls[vendor_index][0].vendor, prop.vendor)) { break; // This vector contains coproc(s) from same vendor } }