From b1573f6367f6c2e13c93a9f85fcf6fc15ee65e07 Mon Sep 17 00:00:00 2001 From: sam bacha Date: Mon, 16 Dec 2024 10:14:13 -0800 Subject: [PATCH] fix(clGetDeviceIDs): check error Applying fix from https://github.com/wjmelements see Fixes: ``` -33 is CL_INVALID_DEVICE. I hunted down the origin of the corruption and determined it was an unhandled error. Changes Check the return value of clGetDeviceIDs ``` https://github.com/johguse/ERADICATE2/compare/master...wjmelements:ERADICATE2:clGetDeviceIDs-error#files_bucket --- eradicate2.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/eradicate2.cpp b/eradicate2.cpp index de36468..34c58f1 100644 --- a/eradicate2.cpp +++ b/eradicate2.cpp @@ -47,7 +47,10 @@ std::vector getAllDevices(cl_device_type deviceType = CL_DEVICE_TY clGetDeviceIDs(*it, deviceType, 0, NULL, &countDevice); std::vector deviceIds(countDevice); - clGetDeviceIDs(*it, deviceType, countDevice, deviceIds.data(), &countDevice); + if (clGetDeviceIDs(*it, deviceType, countDevice, deviceIds.data(), &countDevice) != CL_SUCCESS) { + continue; + } + std::copy( deviceIds.begin(), deviceIds.end(), std::back_inserter(vDevices) ); } @@ -321,7 +324,7 @@ int main(int argc, char * * argv) { const auto globalMemSize = clGetWrapper(clGetDeviceInfo, deviceId, CL_DEVICE_GLOBAL_MEM_SIZE); std::cout << " GPU" << i << ": " << strName << ", " << globalMemSize << " bytes available, " << computeUnits << " compute units" << std::endl; - vDevices.push_back(vFoundDevices[i]); + vDevices.push_back(deviceId); mDeviceIndex[vFoundDevices[i]] = i; }