From ef8674a48888e2601653fd6481b6542914ffd97c Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 11 Dec 2019 16:40:06 +0000 Subject: pickBestDevice return is ignored MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit so might as well return the BestDeviceIndex instead of passing it by ref Change-Id: Ic92fa3b5bfe3d319ff9fcb61b7f5404b5a624be5 Reviewed-on: https://gerrit.libreoffice.org/84971 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- opencl/source/opencl_device.cxx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'opencl') diff --git a/opencl/source/opencl_device.cxx b/opencl/source/opencl_device.cxx index 85a5b3ef6ec9..fe6f92a34ee6 100644 --- a/opencl/source/opencl_device.cxx +++ b/opencl/source/opencl_device.cxx @@ -333,11 +333,11 @@ ds_status profileDevices(std::unique_ptr const & pProfile, std::uniq } /* Pick best device */ -ds_status pickBestDevice(std::unique_ptr const & profile, int& rBestDeviceIndex) +int pickBestDevice(std::unique_ptr const & profile) { double bestScore = DBL_MAX; - rBestDeviceIndex = -1; + int nBestDeviceIndex = -1; for (std::vector::size_type d = 0; d < profile->devices.size(); d++) @@ -390,18 +390,18 @@ ds_status pickBestDevice(std::unique_ptr const & profile, int& rBest if (fScore < bestScore) { bestScore = fScore; - rBestDeviceIndex = d; + nBestDeviceIndex = d; } } - if (rBestDeviceIndex != -1 && profile->devices[rBestDeviceIndex].eType == DeviceType::OpenCLDevice) + if (nBestDeviceIndex != -1 && profile->devices[nBestDeviceIndex].eType == DeviceType::OpenCLDevice) { - SAL_INFO("opencl.device", "Selected Device[" << rBestDeviceIndex << "]: " << profile->devices[rBestDeviceIndex].sDeviceName << "(OpenCL)."); + SAL_INFO("opencl.device", "Selected Device[" << nBestDeviceIndex << "]: " << profile->devices[nBestDeviceIndex].sDeviceName << "(OpenCL)."); } else { - SAL_INFO("opencl.device", "Selected Device[" << rBestDeviceIndex << "]: CPU (Native)."); + SAL_INFO("opencl.device", "Selected Device[" << nBestDeviceIndex << "]: CPU (Native)."); } - return DS_SUCCESS; + return nBestDeviceIndex; } /* Return device ID for matching device name */ @@ -566,8 +566,7 @@ ds_device const & getDeviceSelection( } /* Pick best device */ - int bestDeviceIdx; - pickBestDevice(aProfile, bestDeviceIdx); + int bestDeviceIdx = pickBestDevice(aProfile); /* Override if necessary */ char* overrideDeviceStr = getenv("SC_OPENCL_DEVICE_OVERRIDE"); -- cgit