rocr/driver: add memory residency management interface in driver
This commit introduces MakeMemoryResident and MakeMemoryUnresident functions to KfdDriver and XdnaDriver classes. - Added implementations in amd_kfd_driver.cpp - Added stubs in amd_xdna_driver.cpp returning HSA_STATUS_ERROR - Updated header files amd_kfd_driver.h and amd_xdna_driver.h - Removed MakeKfdMemoryResident/Unresident from amd_memory_region.cpp Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>
This commit is contained in:
1 parent
ab6bda7e96
commit
6c87f5b5ce
8 files changed
+77
-40
No files matched your search
@@ -638,6 +638,31 @@ hsa_status_t KfdDriver::DeregisterMemory(void* ptr) const {
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
hsa_status_t KfdDriver::MakeMemoryResident(const void* mem, size_t size, uint64_t* alternate_va,
|
||||
const HsaMemMapFlags* mem_flags, uint32_t num_nodes,
|
||||
const uint32_t* nodes) const {
|
||||
if (mem_flags == nullptr && nodes == nullptr) {
|
||||
if (HSAKMT_CALL(hsaKmtMapMemoryToGPU(const_cast<void*>(mem), size, alternate_va)) !=
|
||||
HSAKMT_STATUS_SUCCESS) {
|
||||
return HSA_STATUS_ERROR;
|
||||
}
|
||||
} else if (mem_flags != nullptr && nodes != nullptr) {
|
||||
if (!MakeKfdMemoryResident(num_nodes, nodes, mem, size, alternate_va, *mem_flags)) {
|
||||
return HSA_STATUS_ERROR;
|
||||
}
|
||||
} else {
|
||||
debug_print("Invalid memory flags ptr:%p nodes ptr:%p\n", mem_flags, nodes);
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
hsa_status_t KfdDriver::MakeMemoryUnresident(const void* mem) const {
|
||||
HSAKMT_CALL(hsaKmtUnmapMemoryToGPU(const_cast<void*>(mem)));
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
hsa_status_t KfdDriver::IsModelEnabled(bool* enable) const {
|
||||
// AIE does not support streaming performance monitor.
|
||||
HSAKMT_STATUS status = HSAKMT_STATUS_ERROR;
|
||||
|
||||
@@ -908,5 +908,13 @@ hsa_status_t XdnaDriver::RegisterMemory(void* ptr, uint64_t size, HsaMemFlags me
|
||||
|
||||
hsa_status_t XdnaDriver::DeregisterMemory(void* ptr) const { return HSA_STATUS_ERROR; }
|
||||
|
||||
hsa_status_t XdnaDriver::MakeMemoryResident(const void* mem, size_t size, uint64_t* alternate_va,
|
||||
const HsaMemMapFlags* mem_flags, uint32_t num_nodes,
|
||||
const uint32_t* nodes) const {
|
||||
return HSA_STATUS_ERROR;
|
||||
}
|
||||
|
||||
hsa_status_t XdnaDriver::MakeMemoryUnresident(const void* mem) const { return HSA_STATUS_ERROR; }
|
||||
|
||||
} // namespace AMD
|
||||
} // namespace rocr
|
||||
Reference in new issue
Block a user