diff options
author | Mai Lavelle <mai.lavelle@gmail.com> | 2016-05-30 01:02:05 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2016-06-08 22:45:40 +0300 |
commit | fa713b616bfab21f7b792bf24742507a13ba4418 (patch) | |
tree | 6dd1e1f71459acf08fe8c244ca37dc9fd1f61d30 | |
parent | ee1949201a779f05d52235c8c3db67ddb18e53b5 (diff) |
Cycles: Add human readable sizes to debug output
Some of these values can get quite large and are hard to read, adding this
makes it easy to read them at a glance.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D2039
-rw-r--r-- | intern/cycles/bvh/bvh_build.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/device/device_cpu.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/device/device_cuda.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/device/device_multi.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/device/device_network.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/device/device_opencl.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/render/scene.cpp | 9 | ||||
-rw-r--r-- | intern/cycles/util/util_string.cpp | 40 | ||||
-rw-r--r-- | intern/cycles/util/util_string.h | 5 |
9 files changed, 70 insertions, 10 deletions
diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp index 8dbd5abc183..87a889955fe 100644 --- a/intern/cycles/bvh/bvh_build.cpp +++ b/intern/cycles/bvh/bvh_build.cpp @@ -328,11 +328,11 @@ BVHNode* BVHBuild::run() VLOG(1) << "BVH build statistics:\n" << " Build time: " << time_dt() - build_start_time << "\n" << " Total number of nodes: " - << rootnode->getSubtreeSize(BVH_STAT_NODE_COUNT) << "\n" + << string_human_readable_number(rootnode->getSubtreeSize(BVH_STAT_NODE_COUNT)) << "\n" << " Number of inner nodes: " - << rootnode->getSubtreeSize(BVH_STAT_INNER_COUNT) << "\n" + << string_human_readable_number(rootnode->getSubtreeSize(BVH_STAT_INNER_COUNT)) << "\n" << " Number of leaf nodes: " - << rootnode->getSubtreeSize(BVH_STAT_LEAF_COUNT) << "\n" + << string_human_readable_number(rootnode->getSubtreeSize(BVH_STAT_LEAF_COUNT)) << "\n" << " Allocation slop factor: " << ((prim_type.capacity() != 0) ? (float)prim_type.size() / prim_type.capacity() diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index 275ee028eb4..aed86d8d853 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -155,7 +155,9 @@ public: InterpolationType interpolation, ExtensionType extension) { - VLOG(1) << "Texture allocate: " << name << ", " << mem.memory_size() << " bytes."; + VLOG(1) << "Texture allocate: " << name << ", " + << string_human_readable_number(mem.memory_size()) << " bytes. (" + << string_human_readable_size(mem.memory_size()) << ")"; kernel_tex_copy(&kernel_globals, name, mem.data_pointer, diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 9a78d055580..d7ed7b4f853 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -493,7 +493,9 @@ public: InterpolationType interpolation, ExtensionType extension) { - VLOG(1) << "Texture allocate: " << name << ", " << mem.memory_size() << " bytes."; + VLOG(1) << "Texture allocate: " << name << ", " + << string_human_readable_number(mem.memory_size()) << " bytes. (" + << string_human_readable_size(mem.memory_size()) << ")"; /* Check if we are on sm_30 or above. * We use arrays and bindles textures for storage there */ diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp index 434d0085d39..c4f8d9e16e0 100644 --- a/intern/cycles/device/device_multi.cpp +++ b/intern/cycles/device/device_multi.cpp @@ -175,7 +175,9 @@ public: interpolation, ExtensionType extension) { - VLOG(1) << "Texture allocate: " << name << ", " << mem.memory_size() << " bytes."; + VLOG(1) << "Texture allocate: " << name << ", " + << string_human_readable_number(mem.memory_size()) << " bytes. (" + << string_human_readable_size(mem.memory_size()) << ")"; foreach(SubDevice& sub, devices) { mem.device_pointer = 0; diff --git a/intern/cycles/device/device_network.cpp b/intern/cycles/device/device_network.cpp index cf4a05de8fc..3eb5ad2d2db 100644 --- a/intern/cycles/device/device_network.cpp +++ b/intern/cycles/device/device_network.cpp @@ -168,7 +168,9 @@ public: InterpolationType interpolation, ExtensionType extension) { - VLOG(1) << "Texture allocate: " << name << ", " << mem.memory_size() << " bytes."; + VLOG(1) << "Texture allocate: " << name << ", " + << string_human_readable_number(mem.memory_size()) << " bytes. (" + << string_human_readable_size(mem.memory_size()) << ")"; thread_scoped_lock lock(rpc_lock); diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp index 1b4e5421b5a..c7dcf7602df 100644 --- a/intern/cycles/device/device_opencl.cpp +++ b/intern/cycles/device/device_opencl.cpp @@ -1187,7 +1187,9 @@ public: InterpolationType /*interpolation*/, ExtensionType /*extension*/) { - VLOG(1) << "Texture allocate: " << name << ", " << mem.memory_size() << " bytes."; + VLOG(1) << "Texture allocate: " << name << ", " + << string_human_readable_number(mem.memory_size()) << " bytes. (" + << string_human_readable_size(mem.memory_size()) << ")"; mem_alloc(mem, MEM_READ_ONLY); mem_copy_to(mem); assert(mem_map.find(name) == mem_map.end()); diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp index b0052c30af4..e8367e1eb36 100644 --- a/intern/cycles/render/scene.cpp +++ b/intern/cycles/render/scene.cpp @@ -242,9 +242,14 @@ void Scene::device_update(Device *device_, Progress& progress) } if(print_stats) { + size_t mem_used = util_guarded_get_mem_used(); + size_t mem_peak = util_guarded_get_mem_peak(); + VLOG(1) << "System memory statistics after full device sync:\n" - << " Usage: " << util_guarded_get_mem_used() << "\n" - << " Peak: " << util_guarded_get_mem_peak(); + << " Usage: " << string_human_readable_number(mem_used) + << " (" << string_human_readable_size(mem_used) << ")\n" + << " Peak: " << string_human_readable_number(mem_peak) + << " (" << string_human_readable_size(mem_peak) << ")"; } } diff --git a/intern/cycles/util/util_string.cpp b/intern/cycles/util/util_string.cpp index b3a8c6d7c2e..e16a83d56d0 100644 --- a/intern/cycles/util/util_string.cpp +++ b/intern/cycles/util/util_string.cpp @@ -239,5 +239,45 @@ string string_to_ansi(const string& str) #endif /* _WIN32 */ +string string_human_readable_size(size_t size) +{ + static const char suffixes[] = "BKMGTPEZY"; + + const char* suffix = suffixes; + size_t r = 0; + + while(size >= 1024) { + r = size % 1024; + size /= 1024; + suffix++; + } + + if(*suffix != 'B') + return string_printf("%.2f%c", double(size*1024+r)/1024.0, *suffix); + else + return string_printf("%zu", size); +} + +string string_human_readable_number(size_t num) +{ + /* add thousands separators */ + char buf[32]; + + char* p = buf+31; + *p = '\0'; + + int i = -1; + while(num) { + if(++i && i % 3 == 0) + *(--p) = ','; + + *(--p) = '0' + (num % 10); + + num /= 10; + } + + return p; +} + CCL_NAMESPACE_END diff --git a/intern/cycles/util/util_string.h b/intern/cycles/util/util_string.h index c4b51bda432..d3b5248c380 100644 --- a/intern/cycles/util/util_string.h +++ b/intern/cycles/util/util_string.h @@ -62,6 +62,11 @@ string string_from_wstring(const wstring& path); string string_to_ansi(const string& str); #endif +/* Make a string from a size in bytes in human readable form */ +string string_human_readable_size(size_t size); +/* Make a string from a unitless quantity in human readable form */ +string string_human_readable_number(size_t num); + CCL_NAMESPACE_END #endif /* __UTIL_STRING_H__ */ |