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:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-11-05 12:04:57 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-11-05 12:04:57 +0400
commit6eec49ed20fb3a8032718d5f4b9a3e774098df3f (patch)
treec5531a6a4b37ecdb2e2786e44b651fda58d704ae /intern/cycles/device
parentd71004ea692179310d316305f3a0c9c688812da6 (diff)
Cycles: memory usage report
This commit adds memory usage information while rendering. It reports memory used by device, meaning: - For CPU it'll report real memory consumption - For GPU rendering it'll report GPU memory consumption, but it'll also mean the same memory is used from host side. This information displays information about memory requested by Cycles, not memory really allocated on a device. Real memory usage might be higher because of memory fragmentation or optimistic memory allocator. There's really nothing we can do against this. Also in contrast with blender internal's render cycles memory usage does not include memory used by scene, only memory needed by cycles itself will be displayed. So don't freak out if memory usage reported by cycles would be much lower than blender internal's. This commit also adds RenderEngine.update_memory_stats callback which is used to tell memory consumption from external engine to blender. This information is used to generate information line after rendering is finished.
Diffstat (limited to 'intern/cycles/device')
-rw-r--r--intern/cycles/device/device.cpp12
-rw-r--r--intern/cycles/device/device.h8
-rw-r--r--intern/cycles/device/device_cpu.cpp14
-rw-r--r--intern/cycles/device/device_cuda.cpp20
-rw-r--r--intern/cycles/device/device_intern.h10
-rw-r--r--intern/cycles/device/device_multi.cpp10
-rw-r--r--intern/cycles/device/device_network.cpp8
-rw-r--r--intern/cycles/device/device_opencl.cpp11
8 files changed, 61 insertions, 32 deletions
diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp
index 5d3f23d954a..550da2982a3 100644
--- a/intern/cycles/device/device.cpp
+++ b/intern/cycles/device/device.cpp
@@ -78,36 +78,36 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w
glDisable(GL_BLEND);
}
-Device *Device::create(DeviceInfo& info, bool background, int threads)
+Device *Device::create(DeviceInfo& info, Stats &stats, bool background, int threads)
{
Device *device;
switch(info.type) {
case DEVICE_CPU:
- device = device_cpu_create(info, threads);
+ device = device_cpu_create(info, stats, threads);
break;
#ifdef WITH_CUDA
case DEVICE_CUDA:
if(cuLibraryInit())
- device = device_cuda_create(info, background);
+ device = device_cuda_create(info, stats, background);
else
device = NULL;
break;
#endif
#ifdef WITH_MULTI
case DEVICE_MULTI:
- device = device_multi_create(info, background);
+ device = device_multi_create(info, stats, background);
break;
#endif
#ifdef WITH_NETWORK
case DEVICE_NETWORK:
- device = device_network_create(info, "127.0.0.1");
+ device = device_network_create(info, stats, "127.0.0.1");
break;
#endif
#ifdef WITH_OPENCL
case DEVICE_OPENCL:
if(clLibraryInit())
- device = device_opencl_create(info, background);
+ device = device_opencl_create(info, stats, background);
else
device = NULL;
break;
diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index 2ee2e044618..95da0a89833 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -25,6 +25,7 @@
#include "device_task.h"
#include "util_list.h"
+#include "util_stats.h"
#include "util_string.h"
#include "util_thread.h"
#include "util_types.h"
@@ -72,7 +73,7 @@ public:
class Device {
protected:
- Device() {}
+ Device(Stats &stats_) : stats(stats_) {}
bool background;
string error_msg;
@@ -84,6 +85,9 @@ public:
DeviceInfo info;
virtual const string& error_message() { return error_msg; }
+ /* statistics */
+ Stats &stats;
+
/* regular memory */
virtual void mem_alloc(device_memory& mem, MemoryType type) = 0;
virtual void mem_copy_to(device_memory& mem) = 0;
@@ -130,7 +134,7 @@ public:
virtual int device_number(Device *sub_device) { return 0; }
/* static */
- static Device *create(DeviceInfo& info, bool background = true, int threads = 0);
+ static Device *create(DeviceInfo& info, Stats &stats, bool background = true, int threads = 0);
static DeviceType type_from_string(const char *name);
static string string_from_type(DeviceType type);
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index b727a83d024..519c458ffdf 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -45,7 +45,7 @@ public:
TaskPool task_pool;
KernelGlobals *kg;
- CPUDevice(int threads_num)
+ CPUDevice(Stats &stats, int threads_num) : Device(stats)
{
kg = kernel_globals_create();
@@ -67,6 +67,8 @@ public:
void mem_alloc(device_memory& mem, MemoryType type)
{
mem.device_pointer = mem.data_pointer;
+
+ stats.mem_alloc(mem.memory_size());
}
void mem_copy_to(device_memory& mem)
@@ -87,6 +89,8 @@ public:
void mem_free(device_memory& mem)
{
mem.device_pointer = 0;
+
+ stats.mem_free(mem.memory_size());
}
void const_copy_to(const char *name, void *host, size_t size)
@@ -98,11 +102,15 @@ public:
{
kernel_tex_copy(kg, name, mem.data_pointer, mem.data_width, mem.data_height);
mem.device_pointer = mem.data_pointer;
+
+ stats.mem_alloc(mem.memory_size());
}
void tex_free(device_memory& mem)
{
mem.device_pointer = 0;
+
+ stats.mem_free(mem.memory_size());
}
void *osl_memory()
@@ -283,9 +291,9 @@ public:
}
};
-Device *device_cpu_create(DeviceInfo& info, int threads)
+Device *device_cpu_create(DeviceInfo& info, Stats &stats, int threads)
{
- return new CPUDevice(threads);
+ return new CPUDevice(stats, threads);
}
void device_cpu_info(vector<DeviceInfo>& devices)
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index 04b4cb0950a..d797c0f09ca 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -157,7 +157,7 @@ public:
cuda_assert(cuCtxSetCurrent(NULL));
}
- CUDADevice(DeviceInfo& info, bool background_)
+ CUDADevice(DeviceInfo& info, Stats &stats, bool background_) : Device(stats)
{
background = background_;
@@ -316,8 +316,10 @@ public:
{
cuda_push_context();
CUdeviceptr device_pointer;
- cuda_assert(cuMemAlloc(&device_pointer, mem.memory_size()))
+ size_t size = mem.memory_size();
+ cuda_assert(cuMemAlloc(&device_pointer, size))
mem.device_pointer = (device_ptr)device_pointer;
+ stats.mem_alloc(size);
cuda_pop_context();
}
@@ -356,6 +358,8 @@ public:
cuda_pop_context();
mem.device_pointer = 0;
+
+ stats.mem_free(mem.memory_size());
}
}
@@ -424,6 +428,8 @@ public:
cuda_assert(cuTexRefSetFlags(texref, CU_TRSF_NORMALIZED_COORDINATES))
mem.device_pointer = (device_ptr)handle;
+
+ stats.mem_alloc(size);
}
else {
cuda_pop_context();
@@ -463,6 +469,8 @@ public:
tex_interp_map.erase(tex_interp_map.find(mem.device_pointer));
mem.device_pointer = 0;
+
+ stats.mem_free(mem.memory_size());
}
else {
tex_interp_map.erase(tex_interp_map.find(mem.device_pointer));
@@ -707,6 +715,8 @@ public:
mem.device_pointer = pmem.cuTexId;
pixel_mem_map[mem.device_pointer] = pmem;
+ stats.mem_alloc(mem.memory_size());
+
return;
}
else {
@@ -762,6 +772,8 @@ public:
pixel_mem_map.erase(pixel_mem_map.find(mem.device_pointer));
mem.device_pointer = 0;
+ stats.mem_free(mem.memory_size());
+
return;
}
@@ -896,9 +908,9 @@ public:
}
};
-Device *device_cuda_create(DeviceInfo& info, bool background)
+Device *device_cuda_create(DeviceInfo& info, Stats &stats, bool background)
{
- return new CUDADevice(info, background);
+ return new CUDADevice(info, stats, background);
}
void device_cuda_info(vector<DeviceInfo>& devices)
diff --git a/intern/cycles/device/device_intern.h b/intern/cycles/device/device_intern.h
index e3601aa8ad4..02fbac6860e 100644
--- a/intern/cycles/device/device_intern.h
+++ b/intern/cycles/device/device_intern.h
@@ -23,11 +23,11 @@ CCL_NAMESPACE_BEGIN
class Device;
-Device *device_cpu_create(DeviceInfo& info, int threads);
-Device *device_opencl_create(DeviceInfo& info, bool background);
-Device *device_cuda_create(DeviceInfo& info, bool background);
-Device *device_network_create(DeviceInfo& info, const char *address);
-Device *device_multi_create(DeviceInfo& info, bool background);
+Device *device_cpu_create(DeviceInfo& info, Stats &stats, int threads);
+Device *device_opencl_create(DeviceInfo& info, Stats &stats, bool background);
+Device *device_cuda_create(DeviceInfo& info, Stats &stats, bool background);
+Device *device_network_create(DeviceInfo& info, Stats &stats, const char *address);
+Device *device_multi_create(DeviceInfo& info, Stats &stats, bool background);
void device_cpu_info(vector<DeviceInfo>& devices);
void device_opencl_info(vector<DeviceInfo>& devices);
diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp
index 546ffe5e4b9..807bfe578f3 100644
--- a/intern/cycles/device/device_multi.cpp
+++ b/intern/cycles/device/device_multi.cpp
@@ -46,14 +46,14 @@ public:
list<SubDevice> devices;
device_ptr unique_ptr;
- MultiDevice(DeviceInfo& info, bool background_)
- : unique_ptr(1)
+ MultiDevice(DeviceInfo& info, Stats &stats, bool background_)
+ : Device(stats), unique_ptr(1)
{
Device *device;
background = background_;
foreach(DeviceInfo& subinfo, info.multi_devices) {
- device = Device::create(subinfo, background);
+ device = Device::create(subinfo, stats, background);
devices.push_back(SubDevice(device));
}
@@ -314,9 +314,9 @@ public:
}
};
-Device *device_multi_create(DeviceInfo& info, bool background)
+Device *device_multi_create(DeviceInfo& info, Stats &stats, bool background)
{
- return new MultiDevice(info, background);
+ return new MultiDevice(info, stats, background);
}
static bool device_multi_add(vector<DeviceInfo>& devices, DeviceType type, bool with_display, bool with_advanced_shading, const char *id_fmt, int num)
diff --git a/intern/cycles/device/device_network.cpp b/intern/cycles/device/device_network.cpp
index 931890b5859..a5e0d39df73 100644
--- a/intern/cycles/device/device_network.cpp
+++ b/intern/cycles/device/device_network.cpp
@@ -32,8 +32,8 @@ public:
boost::asio::io_service io_service;
tcp::socket socket;
- NetworkDevice(const char *address)
- : socket(io_service)
+ NetworkDevice(Stats &stats, const char *address)
+ : Device(stats), socket(io_service)
{
stringstream portstr;
portstr << SERVER_PORT;
@@ -202,9 +202,9 @@ public:
}
};
-Device *device_network_create(DeviceInfo& info, const char *address)
+Device *device_network_create(DeviceInfo& info, Stats &stats, const char *address)
{
- return new NetworkDevice(address);
+ return new NetworkDevice(stats, address);
}
void device_network_info(vector<DeviceInfo>& devices)
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index aa4f17ea325..69287f1a8bd 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -144,7 +144,8 @@ public:
}
}
- OpenCLDevice(DeviceInfo& info, bool background_)
+ OpenCLDevice(DeviceInfo& info, Stats &stats, bool background_)
+ : Device(stats)
{
background = background_;
cpPlatform = NULL;
@@ -473,6 +474,8 @@ public:
mem.device_pointer = (device_ptr)clCreateBuffer(cxContext, CL_MEM_READ_WRITE, size, NULL, &ciErr);
opencl_assert(ciErr);
+
+ stats.mem_alloc(size);
}
void mem_copy_to(device_memory& mem)
@@ -506,6 +509,8 @@ public:
ciErr = clReleaseMemObject(CL_MEM_PTR(mem.device_pointer));
mem.device_pointer = 0;
opencl_assert(ciErr);
+
+ stats.mem_free(mem.memory_size());
}
}
@@ -728,9 +733,9 @@ public:
}
};
-Device *device_opencl_create(DeviceInfo& info, bool background)
+Device *device_opencl_create(DeviceInfo& info, Stats &stats, bool background)
{
- return new OpenCLDevice(info, background);
+ return new OpenCLDevice(info, stats, background);
}
void device_opencl_info(vector<DeviceInfo>& devices)