SWDEV-554608 - Add hipHostRegisterIoMemory for hipHostRegister (#962)

* SWDEV-554608 - Add hipHostRegisterIoMemory for hipHostRegister

* SWDEV-554608 - Add hipHostRegisterIoMemory for hipHostRegister

* SWDEV-554174 Added hipHostRegisterIoMemory flag in test cases

* SWDEV-554174 : Did formatting corrections

* SWDEV-554608 - set HSA_AMD_MEMORY_POOL_UNCACHED_FLAG if IoMemory is set

* SWDEV-554608 - set HSA_AMD_MEMORY_POOL_UNCACHED_FLAG if IoMemory is set

* SWDEV-554608 - Add hipHostRegisterIoMemory for hipHostRegister

---------

Co-authored-by: Anavena Venkatesh <Anavena.Venkatesh@amd.com>
Co-authored-by: Rambabu Swargam <rambabu.swargam@amd.com>
This commit is contained in:
Jimbo
2025-10-22 20:25:59 -04:00
committed by GitHub
vanhempi 79076c4ad5
commit 37f2be9140
11 muutettua tiedostoa jossa 70 lisäystä ja 7 poistoa
@@ -2010,6 +2010,7 @@ hsa_amd_memory_pool_t Device::getHostMemoryPool(MemorySegment mem_seg,
segment = agentInfo->fine_grain_pool;
break;
case kUncachedAtomics:
case kIoMemory:
if (agentInfo->ext_fine_grain_pool.handle != 0) {
ClPrint(amd::LOG_DETAIL_DEBUG, amd::LOG_MEM,
"Using extended fine grained access system memory pool");
@@ -2032,6 +2033,7 @@ void* Device::hostAlloc(size_t size, size_t alignment, MemorySegment mem_seg,
if (mem_seg == kKernArg) {
memFlags |= HSA_AMD_MEMORY_POOL_EXECUTABLE_FLAG;
}
hsa_amd_memory_pool_t pool =
getHostMemoryPool(mem_seg, static_cast<const amd::roc::AgentInfo*>(agentInfo));
hsa_status_t stat = Hsa::memory_pool_allocate(pool, size, memFlags, &ptr);
@@ -2099,8 +2101,13 @@ void* Device::hostNumaAlloc(size_t size, size_t alignment, MemorySegment mem_seg
void* Device::hostLock(void* hostMem, size_t size, const MemorySegment memSegment) const {
hsa_amd_memory_pool_t pool = getHostMemoryPool(memSegment);
void* deviceMemory = nullptr;
uint32_t memFlags = 0;
if (memSegment == kIoMemory) {
memFlags |= HSA_AMD_MEMORY_POOL_UNCACHED_FLAG;
}
hsa_status_t status = Hsa::memory_lock_to_pool(
hostMem, size, const_cast<hsa_agent_t*>(&bkendDevice_), 1, pool, 0, &deviceMemory);
hostMem, size, const_cast<hsa_agent_t*>(&bkendDevice_), 1, pool, memFlags, &deviceMemory);
ClPrint(amd::LOG_DEBUG, amd::LOG_MEM,
"Locking to pool %p, size 0x%zx, hostMem = %p,"
" deviceMemory = %p, memSegment = %d",