MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / setMemoryManager

Method setMemoryManager

src/backend/cpu/device_manager.cpp:152–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152void DeviceManager::setMemoryManager(
153 std::unique_ptr<MemoryManagerBase> newMgr) {
154 std::lock_guard<std::mutex> l(mutex);
155 // It's possible we're setting a memory manager and the default memory
156 // manager still hasn't been initialized, so initialize it anyways so we
157 // don't inadvertently reset to it when we first call memoryManager()
158 memoryManager();
159 // Calls shutdown() on the existing memory manager
160 if (memManager) { memManager->shutdownAllocator(); }
161 memManager = std::move(newMgr);
162 // Set the backend memory manager for this new manager to register native
163 // functions correctly.
164 std::unique_ptr<cpu::Allocator> deviceMemoryManager(new cpu::Allocator());
165 memManager->setAllocator(std::move(deviceMemoryManager));
166 memManager->initialize();
167}
168
169void DeviceManager::setMemoryManagerPinned(
170 std::unique_ptr<MemoryManagerBase> newMgr) {

Callers 1

setMemoryManagerFunction · 0.45

Calls 3

shutdownAllocatorMethod · 0.80
setAllocatorMethod · 0.80
initializeMethod · 0.45

Tested by

no test coverage detected