Skip to content

Commit 9c238ef

Browse files
sambachaPetarKirov
authored andcommitted
fix(clGetDeviceIDs): check error
Applying fix from https://github.com/wjmelements see <johguse#23> 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 ``` johguse/ERADICATE2@master...wjmelements:ERADICATE2:clGetDeviceIDs-error#files_bucket
1 parent 0f409ab commit 9c238ef

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

eradicate2.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ std::vector<cl_device_id> getAllDevices(cl_device_type deviceType = CL_DEVICE_TY
4747
clGetDeviceIDs(*it, deviceType, 0, NULL, &countDevice);
4848

4949
std::vector<cl_device_id> deviceIds(countDevice);
50-
clGetDeviceIDs(*it, deviceType, countDevice, deviceIds.data(), &countDevice);
50+
if (clGetDeviceIDs(*it, deviceType, countDevice, deviceIds.data(), &countDevice) != CL_SUCCESS) {
51+
continue;
52+
}
53+
5154

5255
std::copy( deviceIds.begin(), deviceIds.end(), std::back_inserter(vDevices) );
5356
}
@@ -297,7 +300,7 @@ int main(int argc, char * * argv) {
297300
const auto globalMemSize = clGetWrapper<cl_ulong>(clGetDeviceInfo, deviceId, CL_DEVICE_GLOBAL_MEM_SIZE);
298301

299302
std::cout << " GPU" << i << ": " << strName << ", " << globalMemSize << " bytes available, " << computeUnits << " compute units" << std::endl;
300-
vDevices.push_back(vFoundDevices[i]);
303+
vDevices.push_back(deviceId);
301304
mDeviceIndex[vFoundDevices[i]] = i;
302305
}
303306

0 commit comments

Comments
 (0)