summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--opencl/source/opencl_device.cxx11
-rw-r--r--opencl/source/openclwrapper.cxx2
2 files changed, 10 insertions, 3 deletions
diff --git a/opencl/source/opencl_device.cxx b/opencl/source/opencl_device.cxx
index bfe81b5dee23..a653ac71016c 100644
--- a/opencl/source/opencl_device.cxx
+++ b/opencl/source/opencl_device.cxx
@@ -636,10 +636,15 @@ ds_device getDeviceSelection(
}
/* Final device selection */
- selectedDevice = aProfile->devices[bestDeviceIdx];
- bIsDeviceSelected = true;
+ if (bestDeviceIdx >=0 && static_cast< std::vector<ds_device>::size_type> ( bestDeviceIdx ) < aProfile->devices.size() )
+ {
+ selectedDevice = aProfile->devices[bestDeviceIdx];
+ bIsDeviceSelected = true;
- writeDevicesLog(aProfile, sProfilePath, bestDeviceIdx);
+ writeDevicesLog(aProfile, sProfilePath, bestDeviceIdx);
+ } else {
+ selectedDevice.eType = DeviceType::NativeCPU;
+ }
}
return selectedDevice;
}
diff --git a/opencl/source/openclwrapper.cxx b/opencl/source/openclwrapper.cxx
index 1655cb61c84c..ab65091d3e66 100644
--- a/opencl/source/openclwrapper.cxx
+++ b/opencl/source/openclwrapper.cxx
@@ -703,6 +703,8 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv
OUString path;
osl::FileBase::getSystemPathFromFileURL(url,path);
ds_device aSelectedDevice = getDeviceSelection(path, bForceEvaluation);
+ if ( aSelectedDevice.eType != DeviceType::OpenCLDevice)
+ return false;
pDeviceId = aSelectedDevice.aDeviceID;
}