22 namespace CudaMgr_Namespace {
36 const uint64_t handle,
40 Allocation allocation{size, handle, uuid, device_num, is_slab};
41 CHECK(
map_.try_emplace(device_ptr, std::move(allocation)).second);
47 auto const itr =
map_.find(device_ptr);
57 std::pair<DeviceMemoryAllocationMap::DevicePtr, DeviceMemoryAllocationMap::Allocation>
60 auto itr =
map_.upper_bound(device_ptr);
64 return std::make_pair(itr->first, itr->second);
81 const bool is_slab)
const {
83 cb.second(device_uuid, is_slab);
std::unordered_map< MapChangedCBID, MapChangedCB > map_changed_cbs_
const Map & getMap() const
void notifyMapChanged(const heavyai::UUID device_uuid, const bool is_slab) const
Allocation removeAllocation(const DevicePtr device_ptr)
const MapChangedCBID registerMapChangedCB(MapChangedCB cb)
std::function< void(const heavyai::UUID, const bool)> MapChangedCB
std::map< DevicePtr, Allocation > Map
MapChangedCBID last_map_changed_cbid_
DeviceMemoryAllocationMap()
void unregisterMapChangedCB(const MapChangedCBID cbid)
void addAllocation(const DevicePtr device_ptr, const uint64_t size, const uint64_t handle, const heavyai::UUID uuid, const int device_num, const bool is_slab)
std::pair< DevicePtr, Allocation > getAllocation(const DevicePtr device_ptr)
const bool mapEmpty() const