diff options
-rw-r--r-- | opencl/source/opencl_device.cxx | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/opencl/source/opencl_device.cxx b/opencl/source/opencl_device.cxx index 0a0d28ee4200..3dc9a29413ad 100644 --- a/opencl/source/opencl_device.cxx +++ b/opencl/source/opencl_device.cxx @@ -327,7 +327,8 @@ ds_status evaluateScoreForDevice(ds_device& rDevice, std::unique_ptr<LibreOffice timer kernelTime; timerStart(&kernelTime); - for (unsigned long j = 0; j < testData->outputSize; j++) + unsigned long j; + for (j = 0; j < testData->outputSize; j++) { double fAverage = 0.0f; double fMin = DBL_MAX; @@ -340,15 +341,25 @@ ds_status evaluateScoreForDevice(ds_device& rDevice, std::unique_ptr<LibreOffice } fAverage /= testData->inputSize; testData->output[j] = fAverage + (fMin * fSoP); + // Don't run for much longer than one second + if (j > 0 && j % 100 == 0) + { + rDevice.fTime = timerCurrent(&kernelTime); + if (rDevice.fTime >= 1) + break; + } } + rDevice.fTime = timerCurrent(&kernelTime); + + // Scale time to how long it would have taken to go all the way to outputSize + rDevice.fTime /= ((double) j / testData->outputSize); + // InterpretTail - the S/W fallback is nothing like as efficient // as any good openCL implementation: no SIMD, tons of branching // in the inner loops etc. Generously characterise it as only 10x // slower than the above. float fInterpretTailFactor = 10.0; - - rDevice.fTime = timerCurrent(&kernelTime); rDevice.fTime *= fInterpretTailFactor; rDevice.bErrors = false; } |