diff options
Diffstat (limited to 'intern/cycles/util')
-rw-r--r-- | intern/cycles/util/util_system.cpp | 21 | ||||
-rw-r--r-- | intern/cycles/util/util_system.h | 2 |
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__ */ |