SWDEV-339296 - Delay hidden heap allocation till the usage

Move hidden heap creation to the kernel launch to make sure it's
allocated on the actual first usage.

Change-Id: I1b65a82fc06d9129ed45a69765bf14ea3d945b04
This commit is contained in:
German Andryeyev
2022-06-14 12:18:34 -04:00
parent ecea224bcf
commit 4975f69337
7 changed files with 63 additions and 32 deletions
+19 -14
View File
@@ -787,20 +787,6 @@ bool Device::create() {
return false;
}
if (amd::IS_HIP) {
// Allocate initial heap for device memory allocator
static constexpr size_t HeapBufferSize = 128 * Ki;
heap_buffer_ = createMemory(HeapBufferSize);
// Clear memory to 0 for device library logic
if ((heap_buffer_ == nullptr) ||
(HSA_STATUS_SUCCESS != hsa_amd_memory_fill(
reinterpret_cast<void*>(HeapBuffer()->virtualAddress()), 0,
HeapBufferSize / sizeof(uint32_t)))) {
LogError("Heap buffer allocation failed!");
return false;
}
}
return true;
}
@@ -3180,6 +3166,25 @@ bool Device::IsValidAllocation(const void* dev_ptr, size_t size) const {
return false;
}
// ================================================================================================
void Device::HiddenHeapAlloc() {
auto HeapAllocZeroOut = [this]()->bool {
// Allocate initial heap for device memory allocator
static constexpr size_t HeapBufferSize = 128 * Ki;
heap_buffer_ = createMemory(HeapBufferSize);
// Clear memory to 0 for device library logic
if ((heap_buffer_ == nullptr) ||
(HSA_STATUS_SUCCESS != hsa_amd_memory_fill(
reinterpret_cast<void*>(HeapBuffer()->virtualAddress()), 0,
HeapBufferSize / sizeof(uint32_t)))) {
LogError("Heap buffer allocation failed!");
return false;
}
return true;
};
std::call_once(heap_initialized_, HeapAllocZeroOut);
}
// ================================================================================================
ProfilingSignal::~ProfilingSignal() {
if (signal_.handle != 0) {