/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hipcub/checkouts/docs-5.4.4/hipcub/include/hipcub/backend/rocprim/util_allocator.hpp Source File#
util_allocator.hpp
77 hipEvent_t ready_event; // Signal when associated stream has run to the point at which this block was freed
82 bytes(0),
85 associated_stream(0),
97 {}
148 {
159 }
172 rounded_bytes = 1;
225 :
227 min_bin(min_bin),
228 max_bin(max_bin),
229 min_bin_bytes(IntPow(bin_growth, min_bin)),
231 max_cached_bytes(max_cached_bytes),
232 skip_cleanup(skip_cleanup),
236 {}
279 mutex.lock();
281 if (debug) _HipcubLog("Changing max_cached_bytes (%lld -> %lld)\n", (long long) this->max_cached_bytes, (long long) max_cached_bytes);
326 search_key.bin = INVALID_BIN;
363 if (debug) _HipcubLog("\tDevice %d reused cached block at %p (%lld bytes) for stream %lld (previously associated with stream %lld).\n",
364 device, search_key.d_ptr, (long long) search_key.bytes, (long long) search_key.associated_stream, (long long) block_itr->associated_stream);
388 if (HipcubDebug(error = hipMalloc(&search_key.d_ptr, search_key.bytes)) == hipErrorMemoryAllocation)
391 if (debug) _HipcubLog("\tDevice %d failed to allocate %lld bytes for stream %lld, retrying after freeing cached allocations",
417 if (debug) _HipcubLog("\tDevice %d freed %lld bytes.\n\t\t %lld available blocks cached (%lld bytes), %lld live blocks (%lld bytes) outstanding.\n",
418 device, (long long) block_itr->bytes, (long long) cached_blocks.size(), (long long) cached_bytes[device].free, (long long) live_blocks.size(), (long long) cached_bytes[device].live);
436 if (HipcubDebug(error = hipEventCreateWithFlags(&search_key.ready_event, hipEventDisableTiming)))
445 if (debug) _HipcubLog("\tDevice %d allocated new device block at %p (%lld bytes associated with stream %lld).\n",
446 device, search_key.d_ptr, (long long) search_key.bytes, (long long) search_key.associated_stream);
458 if (debug) _HipcubLog("\t\t%lld available blocks cached (%lld bytes), %lld live blocks outstanding(%lld bytes).\n",
459 (long long) cached_blocks.size(), (long long) cached_bytes[device].free, (long long) live_blocks.size(), (long long) cached_bytes[device].live);
499 device = entrypoint_device;
517 if ((search_key.bin != INVALID_BIN) && (cached_bytes[device].free + search_key.bytes <= max_cached_bytes))
524 if (debug) _HipcubLog("\tDevice %d returned %lld bytes from associated stream %lld.\n\t\t %lld available blocks cached (%lld bytes), %lld live blocks outstanding. (%lld bytes)\n",
525 device, (long long) search_key.bytes, (long long) search_key.associated_stream, (long long) cached_blocks.size(),
526 (long long) cached_bytes[device].free, (long long) live_blocks.size(), (long long) cached_bytes[device].live);
540 if (HipcubDebug(error = hipEventRecord(search_key.ready_event, search_key.associated_stream))) return error;
552 if (debug) _HipcubLog("\tDevice %d freed %lld bytes from associated stream %lld.\n\t\t %lld available blocks cached (%lld bytes), %lld live blocks (%lld bytes) outstanding.\n",
553 device, (long long) search_key.bytes, (long long) search_key.associated_stream, (long long) cached_blocks.size(), (long long) cached_bytes[device].free, (long long) live_blocks.size(), (long long) cached_bytes[device].live);
600 }
616 if (debug) _HipcubLog("\tDevice %d freed %lld bytes.\n\t\t %lld available blocks cached (%lld bytes), %lld live blocks (%lld bytes) outstanding.\n",
Definition: util_allocator.hpp:70
std::multiset< BlockDescriptor, Compare > CachedBlocks
Set type for cached blocks (ordered by size)
Definition: util_allocator.hpp:156
Definition: util_allocator.hpp:97
std::map< int, TotalBytes > GpuCachedBytes
Map type of device ordinals to the number of cached bytes cached by each device.
Definition: util_allocator.hpp:162
std::multiset< BlockDescriptor, Compare > BusyBlocks
Set type for live blocks (ordered by ptr)
Definition: util_allocator.hpp:159