SWDEV-467102 - Hidden heap init for graph capture

If the graph has kernels that does device side allocation,  during packet capture, heap is
allocated because heap pointer has to be added to the AQL packet, and initialized during
graph launch.

Handle race with wait when 2 kernels with device heap are enqueued on multiple streams.

Change-Id: I45933b77fcaf7bc8fdf1bc906462e32b5d8d3688


[ROCm/clr commit: 57156c524d]
This commit is contained in:
Anusha GodavarthySurya
2024-06-11 11:59:05 +00:00
committed by Anusha Godavarthy Surya
parent c8bc9e3f2e
commit 291f079669
9 changed files with 57 additions and 17 deletions
+14 -4
View File
@@ -3511,7 +3511,7 @@ bool Device::IsValidAllocation(const void* dev_ptr, size_t size, hsa_amd_pointer
// ================================================================================================
void Device::HiddenHeapAlloc(const VirtualGPU& gpu) {
auto HeapAllocZeroOut = [this, &gpu]() -> bool {
auto HeapAllocOnly = [this, &gpu]() -> bool {
// Allocate initial heap for device memory allocator
static constexpr size_t HeapBufferSize = 128 * Ki;
heap_buffer_ = createMemory(HeapBufferSize);
@@ -3523,12 +3523,22 @@ void Device::HiddenHeapAlloc(const VirtualGPU& gpu) {
LogError("Heap buffer allocation failed!");
return false;
}
bool result = static_cast<const KernelBlitManager&>(gpu.blitMgr()).initHeap(
heap_buffer_, initial_heap_buffer_, HeapBufferSize, initial_heap_size_ / (2 * Mi));
return true;
};
std::call_once(heap_allocated_, HeapAllocOnly);
}
// ================================================================================================
void Device::HiddenHeapInit(const VirtualGPU& gpu) {
auto HeapZeroOut = [this, &gpu]() -> bool {
static constexpr size_t HeapBufferSize = 128 * Ki;
bool result = static_cast<const KernelBlitManager&>(gpu.blitMgr())
.initHeap(heap_buffer_, initial_heap_buffer_, HeapBufferSize,
initial_heap_size_ / (2 * Mi));
return result;
};
std::call_once(heap_initialized_, HeapAllocZeroOut);
std::call_once(heap_initialized_, HeapZeroOut);
}
// ================================================================================================