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
+11 -5
View File
@@ -264,6 +264,7 @@ const HSAILProgram& HSAILKernel::prog() const {
return reinterpret_cast<const HSAILProgram&>(prog_);
}
// ================================================================================================
hsa_kernel_dispatch_packet_t* HSAILKernel::loadArguments(VirtualGPU& gpu, const amd::Kernel& kernel,
const amd::NDRangeContainer& sizes,
const_address params,
@@ -359,10 +360,14 @@ hsa_kernel_dispatch_packet_t* HSAILKernel::loadArguments(VirtualGPU& gpu, const
case amd::KernelParameterDescriptor::HiddenMultiGridSync:
break;
case amd::KernelParameterDescriptor::HiddenHeap:
if (gpu.dev().HeapBuffer() != nullptr) {
// Allocate hidden heap for HIP applications only
if ((amd::IS_HIP) && (palDevice().HeapBuffer() == nullptr)) {
const_cast<Device&>(palDevice()).HiddenHeapAlloc();
}
if (palDevice().HeapBuffer() != nullptr) {
// Add heap pointer to the code
size_t heap_ptr = static_cast<size_t>(gpu.dev().HeapBuffer()->virtualAddress());
gpu.addVmMemory(reinterpret_cast<Memory*>(gpu.dev().HeapBuffer()));
size_t heap_ptr = static_cast<size_t>(palDevice().HeapBuffer()->virtualAddress());
gpu.addVmMemory(reinterpret_cast<Memory*>(palDevice().HeapBuffer()));
WriteAqlArgAt(hidden_arguments, heap_ptr, it.size_, it.offset_);
}
break;
@@ -425,12 +430,12 @@ hsa_kernel_dispatch_packet_t* HSAILKernel::loadArguments(VirtualGPU& gpu, const
break;
case amd::KernelParameterDescriptor::HiddenPrivateBase:
WriteAqlArgAt(hidden_arguments,
(gpu.dev().properties().gpuMemoryProperties.privateApertureBase >> AddressShift),
(palDevice().properties().gpuMemoryProperties.privateApertureBase >> AddressShift),
it.size_, it.offset_);
break;
case amd::KernelParameterDescriptor::HiddenSharedBase:
WriteAqlArgAt(hidden_arguments,
(gpu.dev().properties().gpuMemoryProperties.sharedApertureBase >> AddressShift),
(palDevice().properties().gpuMemoryProperties.sharedApertureBase >> AddressShift),
it.size_, it.offset_);
break;
case amd::KernelParameterDescriptor::HiddenQueuePtr:
@@ -485,6 +490,7 @@ hsa_kernel_dispatch_packet_t* HSAILKernel::loadArguments(VirtualGPU& gpu, const
return hsaDisp;
}
// ================================================================================================
const LightningProgram& LightningKernel::prog() const {
return reinterpret_cast<const LightningProgram&>(prog_);
}