Fix Cycles CUDA suboptimal performance on Windows 10 with recent graphics cards

When compute preemption is available we schedule more work which is more
efficient. However the CUDA driver appears to be incorrectly reporting this as
unavailable, even though it should be supported starting with Windows 10 1803
and Pascal and Turing (10x0 and 20x0) graphics cards.

This reduces render time by about a 25% difference on our benchmark scenes. On
Linux compute preemption appears to be reported correctly.
This commit is contained in:
Brecht Van Lommel 2019-06-18 18:30:48 +02:00
parent 1dab26afb9
commit b10921f0cc
Notes: blender-bot 2023-02-14 07:53:51 +01:00
Referenced by issue #66041, Cycles Cuda error
4 changed files with 71 additions and 0 deletions

View File

@ -47,6 +47,7 @@
#include "util/util_system.h"
#include "util/util_types.h"
#include "util/util_time.h"
#include "util/util_windows.h"
#include "kernel/split/kernel_split_data_types.h"
@ -2659,6 +2660,14 @@ void device_cuda_info(vector<DeviceInfo> &devices)
cuDeviceGetAttribute(&timeout_attr, CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT, num);
cuDeviceGetAttribute(&preempt_attr, CU_DEVICE_ATTRIBUTE_COMPUTE_PREEMPTION_SUPPORTED, num);
/* The CUDA driver reports compute preemption as not being available on
* Windows 10 even when it is, due to an issue in application profiles.
* Detect case where we expect it to be available and override. */
if (preempt_attr == 0 && (major >= 6) && system_windows_version_at_least(10, 17134)) {
VLOG(1) << "Assuming device has compute preemption on Windows 10.";
preempt_attr = 1;
}
if (timeout_attr && !preempt_attr) {
VLOG(1) << "Device is recognized as display.";
info.description += " (Display)";
@ -2666,6 +2675,7 @@ void device_cuda_info(vector<DeviceInfo> &devices)
display_devices.push_back(info);
}
else {
VLOG(1) << "Device has compute preemption or is not used for display.";
devices.push_back(info);
}
VLOG(1) << "Added device \"" << name << "\" with id \"" << info.id << "\".";

View File

@ -25,6 +25,7 @@ set(SRC
util_thread.cpp
util_time.cpp
util_transform.cpp
util_windows.cpp
)
set(LIB

View File

@ -0,0 +1,54 @@
/*
* Copyright 2019-2019 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef _WIN32
#include <windows.h>
#endif
#include "util_windows.h"
CCL_NAMESPACE_BEGIN
bool system_windows_version_at_least(int major, int build)
{
#ifdef _WIN32
HMODULE hMod = ::GetModuleHandleW(L"ntdll.dll");
if (hMod == 0) {
return false;
}
typedef NTSTATUS(WINAPI * RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
RtlGetVersionPtr rtl_get_version = (RtlGetVersionPtr)::GetProcAddress(hMod, "RtlGetVersion");
if (rtl_get_version == NULL) {
return false;
}
RTL_OSVERSIONINFOW rovi = {0};
rovi.dwOSVersionInfoSize = sizeof(rovi);
if (rtl_get_version(&rovi) != 0) {
return false;
}
return (rovi.dwMajorVersion > major ||
(rovi.dwMajorVersion == major && rovi.dwBuildNumber >= build));
#else
(void)major;
(void)build;
return false;
#endif
}
CCL_NAMESPACE_END

View File

@ -33,4 +33,10 @@
#endif /* _WIN32 */
CCL_NAMESPACE_BEGIN
bool system_windows_version_at_least(int major, int build);
CCL_NAMESPACE_END
#endif /* __UTIL_WINDOWS_H__ */