diff options
author | Laszlo Nemeth <nemeth@numbertext.org> | 2016-07-25 16:02:10 +0300 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-07-25 19:39:50 +0000 |
commit | 0a2cefe5b6fa010f02da6eecae85c09b308f9fd1 (patch) | |
tree | 0c01ae4592d1156b0ba9d0cfff0a13436e7421a1 /opencl | |
parent | e13db0f16c4ac5a243587e881d7b18979d07f478 (diff) |
Need to try to avoid TDR also with NVIDIA cards on Windows 7 or earlier
(TDR is Timeout detection and recovery, was introduced in Vista.)
Change-Id: I0be565036c72dadcbec40b6fb9d5154dfacd0860
Reviewed-on: https://gerrit.libreoffice.org/27519
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'opencl')
-rw-r--r-- | opencl/source/openclwrapper.cxx | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/opencl/source/openclwrapper.cxx b/opencl/source/openclwrapper.cxx index 123c2c9a3fb9..d8d16c392991 100644 --- a/opencl/source/openclwrapper.cxx +++ b/opencl/source/openclwrapper.cxx @@ -42,6 +42,10 @@ #define OPENCL_DLL_NAME "libOpenCL.so.1" #endif +#ifdef _WIN32_WINNT_WINBLUE +#include <VersionHelpers.h> +#endif + #define DEVICE_NAME_LENGTH 1024 #define DRIVER_VERSION_LENGTH 1024 #define PLATFORM_VERSION_LENGTH 1024 @@ -455,6 +459,8 @@ void checkDeviceForDoubleSupport(cl_device_id deviceId, bool& bKhrFp64, bool& bA bool initOpenCLRunEnv( GPUEnv *gpuInfo ) { OpenCLZone zone; + cl_uint nPreferredVectorWidthFloat; + char pName[64]; bool bKhrFp64 = false; bool bAmdFp64 = false; @@ -464,11 +470,38 @@ bool initOpenCLRunEnv( GPUEnv *gpuInfo ) gpuInfo->mnKhrFp64Flag = bKhrFp64; gpuInfo->mnAmdFp64Flag = bAmdFp64; - gpuInfo->mnPreferredVectorWidthFloat = 0; + gpuInfo->mbNeedsTDRAvoidance = false; clGetDeviceInfo(gpuInfo->mpDevID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, sizeof(cl_uint), - &gpuInfo->mnPreferredVectorWidthFloat, nullptr); + &nPreferredVectorWidthFloat, nullptr); + clGetPlatformInfo(gpuInfo->mpPlatformID, CL_PLATFORM_NAME, 64, + pName, nullptr); + + bool bIsNotWinOrIsWin8OrGreater = true; + +// the Win32 SDK 8.1 deprecates GetVersionEx() +#ifdef _WIN32_WINNT_WINBLUE + bIsNotWinOrIsWin8OrGreater = IsWindows8OrGreater(); +#elif defined (_WIN32) + OSVERSIONINFO aVersionInfo; + memset( &aVersionInfo, 0, sizeof(aVersionInfo) ); + aVersionInfo.dwOSVersionInfoSize = sizeof( aVersionInfo ); + if (GetVersionEx( &aVersionInfo )) + { + // Windows 7 or lower? + if (aVersionInfo.dwMajorVersion < 6 || + (aVersionInfo.dwMajorVersion == 6 && aVersionInfo.dwMinorVersion < 2)) + bIsNotWinOrIsWin8OrGreater = false; + } +#endif + // Heuristic: Certain old low-end OpenCL implementations don't + // work for us with too large group lengths. Looking at the preferred + // float vector width seems to be a way to detect these devices, except + // the non-working NVIDIA cards on Windows older than version 8. + gpuInfo->mbNeedsTDRAvoidance = ( nPreferredVectorWidthFloat == 4 ) || + ( !bIsNotWinOrIsWin8OrGreater && + OUString::createFromAscii(pName).indexOf("NVIDIA") > -1 ); return false; } |