rocr/driver: add scratch memory allocation into driver interface
Add AllocateScratchMemory interface to Driver base class and implement it
in both KFD and XDNA drivers. This change encapsulates the low-level
scratch memory allocation details within driver implementations, making
the code more maintainable and the interface cleaner.
The main changes include:
- Add AllocateScratchMemory virtual method to Driver interface
- Implement the interface in KfdDriver with existing allocation logic
- Add stub implementation in XdnaDriver
- Update GpuAgent to use the new interface instead of direct KMT calls
Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>
[ROCm/ROCR-Runtime commit: da8dd9e1e3]
Tento commit je obsažen v:
odevzdal
Huang, Honglei1
rodič
a0ef6f6473
revize
1ad79f04d0
@@ -491,11 +491,6 @@ void GpuAgent::InitRegionList() {
|
||||
}
|
||||
|
||||
void GpuAgent::InitScratchPool() {
|
||||
HsaMemFlags flags;
|
||||
flags.Value = 0;
|
||||
flags.ui32.Scratch = 1;
|
||||
flags.ui32.HostAccess = 1;
|
||||
|
||||
scratch_per_thread_ =
|
||||
core::Runtime::runtime_singleton_->flag().scratch_mem_size();
|
||||
if (scratch_per_thread_ == 0)
|
||||
@@ -516,14 +511,13 @@ void GpuAgent::InitScratchPool() {
|
||||
#endif
|
||||
|
||||
void* scratch_base = nullptr;
|
||||
HSAKMT_STATUS err =
|
||||
HSAKMT_CALL(hsaKmtAllocMemory(node_id(), max_scratch_len, flags, &scratch_base));
|
||||
assert(err == HSAKMT_STATUS_SUCCESS && "hsaKmtAllocMemory(Scratch) failed");
|
||||
hsa_status_t err = driver().AllocateScratchMemory(node_id(), max_scratch_len, &scratch_base);
|
||||
assert(err == HSA_STATUS_SUCCESS && "AllocateScratchMemory failed");
|
||||
assert(IsMultipleOf(scratch_base, 0x1000) &&
|
||||
"Scratch base is not page aligned!");
|
||||
|
||||
scratch_pool_. ~SmallHeap();
|
||||
if (HSAKMT_STATUS_SUCCESS == err) {
|
||||
if (HSA_STATUS_SUCCESS == err) {
|
||||
new (&scratch_pool_) SmallHeap(scratch_base, max_scratch_len);
|
||||
} else {
|
||||
new (&scratch_pool_) SmallHeap();
|
||||
|
||||
Odkázat v novém úkolu
Zablokovat Uživatele