Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/device/opencl/memory_manager.h
| Show All 20 Lines | |||||
| #include "util/util_map.h" | #include "util/util_map.h" | ||||
| #include "util/util_vector.h" | #include "util/util_vector.h" | ||||
| #include "util/util_string.h" | #include "util/util_string.h" | ||||
| #include "clew.h" | #include "clew.h" | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| class OpenCLDeviceBase; | class OpenCLDevice; | ||||
| class MemoryManager { | class MemoryManager { | ||||
| public: | public: | ||||
| static const int NUM_DEVICE_BUFFERS = 8; | static const int NUM_DEVICE_BUFFERS = 8; | ||||
| struct BufferDescriptor { | struct BufferDescriptor { | ||||
| uint device_buffer; | uint device_buffer; | ||||
| cl_ulong offset; | cl_ulong offset; | ||||
| Show All 30 Lines | struct DeviceBuffer { | ||||
| ~DeviceBuffer() | ~DeviceBuffer() | ||||
| { | { | ||||
| delete buffer; | delete buffer; | ||||
| buffer = NULL; | buffer = NULL; | ||||
| } | } | ||||
| void add_allocation(Allocation& allocation); | void add_allocation(Allocation& allocation); | ||||
| void update_device_memory(OpenCLDeviceBase *device); | void update_device_memory(OpenCLDevice *device); | ||||
| void free(OpenCLDeviceBase *device); | void free(OpenCLDevice *device); | ||||
| }; | }; | ||||
| OpenCLDeviceBase *device; | OpenCLDevice *device; | ||||
| DeviceBuffer device_buffers[NUM_DEVICE_BUFFERS]; | DeviceBuffer device_buffers[NUM_DEVICE_BUFFERS]; | ||||
| typedef unordered_map<string, Allocation> AllocationsMap; | typedef unordered_map<string, Allocation> AllocationsMap; | ||||
| AllocationsMap allocations; | AllocationsMap allocations; | ||||
| bool need_update; | bool need_update; | ||||
| DeviceBuffer* smallest_device_buffer(); | DeviceBuffer* smallest_device_buffer(); | ||||
| public: | public: | ||||
| MemoryManager(OpenCLDeviceBase *device); | MemoryManager(OpenCLDevice *device); | ||||
| void free(); /* Free all memory. */ | void free(); /* Free all memory. */ | ||||
| void alloc(const char *name, device_memory& mem); | void alloc(const char *name, device_memory& mem); | ||||
| bool free(device_memory& mem); | bool free(device_memory& mem); | ||||
| BufferDescriptor get_descriptor(string name); | BufferDescriptor get_descriptor(string name); | ||||
| void update_device_memory(); | void update_device_memory(); | ||||
| void set_kernel_arg_buffers(cl_kernel kernel, cl_uint *narg); | void set_kernel_arg_buffers(cl_kernel kernel, cl_uint *narg); | ||||
| }; | }; | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||