Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2017-11-04 02:33:38 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-01-03 01:50:18 +0300
commitc621832d3d358cd7648d60c16e1685050c4f6778 (patch)
tree7db33634ec4eb97c4adc81949ddae7a61f09e38f /intern/cycles/util
parent6699454fb642bfd07e85f8d7bd8f8879878e3fc5 (diff)
Cycles: CUDA support for rendering scenes that don't fit on GPU.
In that case it can now fall back to CPU memory, at the cost of reduced performance. For scenes that fit in GPU memory, this commit should not cause any noticeable slowdowns. We don't use all physical system RAM, since that can cause OS instability. We leave at least half of system RAM or 4GB to other software, whichever is smaller. For image textures in host memory, performance was maybe 20-30% slower in our tests (although this is highly hardware and scene dependent). Once other type of data doesn't fit on the GPU, performance can be e.g. 10x slower, and at that point it's probably better to just render on the CPU. Differential Revision: https://developer.blender.org/D2056
Diffstat (limited to 'intern/cycles/util')
-rw-r--r--intern/cycles/util/util_system.cpp21
-rw-r--r--intern/cycles/util/util_system.h2
2 files changed, 23 insertions, 0 deletions
diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp
index a942d738b8a..9b1b9a60c30 100644
--- a/intern/cycles/util/util_system.cpp
+++ b/intern/cycles/util/util_system.cpp
@@ -292,5 +292,26 @@ bool system_cpu_support_avx2()
#endif
+size_t system_physical_ram()
+{
+#ifdef _WIN32
+ MEMORYSTATUSEX ram;
+ ram.dwLength = sizeof (ram);
+ GlobalMemoryStatusEx(&ram);
+ return ram.ullTotalPhys * 1024;
+#elif defined(__APPLE__)
+ uint64_t ram = 0;
+ size_t len = sizeof(ram);
+ if (sysctlbyname("hw.memsize", &ram, &len, NULL, 0) == 0) {
+ return ram;
+ }
+ return 0;
+#else
+ size_t ps = sysconf(_SC_PAGESIZE);
+ size_t pn = sysconf(_SC_PHYS_PAGES);
+ return ps * pn;
+#endif
+}
+
CCL_NAMESPACE_END
diff --git a/intern/cycles/util/util_system.h b/intern/cycles/util/util_system.h
index db7a45b2d59..e55dd6dd136 100644
--- a/intern/cycles/util/util_system.h
+++ b/intern/cycles/util/util_system.h
@@ -42,6 +42,8 @@ bool system_cpu_support_sse41();
bool system_cpu_support_avx();
bool system_cpu_support_avx2();
+size_t system_physical_ram();
+
CCL_NAMESPACE_END
#endif /* __UTIL_SYSTEM_H__ */