diff --git a/rocclr/device/rocm/rocdevice.cpp b/rocclr/device/rocm/rocdevice.cpp index a19987e3c2..c06b7d879e 100644 --- a/rocclr/device/rocm/rocdevice.cpp +++ b/rocclr/device/rocm/rocdevice.cpp @@ -2130,7 +2130,17 @@ bool Device::SetSvmAttributesInt(const void* dev_ptr, size_t count, if (use_cpu) { attr.push_back({HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE_IN_PLACE, getCpuAgent().handle}); } else { - attr.push_back({HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE_IN_PLACE, getBackendDevice().handle}); + if (first_alloc) { + // Provide access to all possible devices. + //! @note: HMM should support automatic page table update with xnack enabled, + //! but currently it doesn't and runtime explicitly enables access from all devices + for (const auto dev : devices()) { + attr.push_back({HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE_IN_PLACE, + static_cast(dev)->getBackendDevice().handle}); + } + } else { + attr.push_back({HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE_IN_PLACE, getBackendDevice().handle}); + } } break; case amd::MemoryAdvice::UnsetAccessedBy: @@ -2257,9 +2267,6 @@ bool Device::SvmAllocInit(void* memory, size_t size) const { if (settings().hmmFlags_ & Settings::Hmm::EnableSystemMemory) { advice = amd::MemoryAdvice::UnsetPreferredLocation; SetSvmAttributesInt(memory, size, advice); - } else { - advice = amd::MemoryAdvice::SetPreferredLocation; - SetSvmAttributesInt(memory, size, advice); } if ((settings().hmmFlags_ & Settings::Hmm::EnableMallocPrefetch) == 0) { diff --git a/rocclr/device/rocm/rocmemory.cpp b/rocclr/device/rocm/rocmemory.cpp index 9c1055d140..d8f4a0a6ef 100644 --- a/rocclr/device/rocm/rocmemory.cpp +++ b/rocclr/device/rocm/rocmemory.cpp @@ -745,14 +745,6 @@ bool Buffer::create() { } else { deviceMemory_ = owner()->getSvmPtr(); kind_ = MEMORY_KIND_PTRGIVEN; -#if AMD_HMM_SUPPORT - if (memFlags & CL_MEM_ALLOC_HOST_PTR) { - // Currently HMM requires cirtain initial calls to mark sysmem allocation as - // GPU accessible or prefetch memory into the current device - // @note: Skip any allocaiton here, since sysmem was allocated on another device. - dev().SvmAllocInit(deviceMemory_, size()); - } -#endif // AMD_HMM_SUPPORT } if ((deviceMemory_ != nullptr) && (dev().settings().apuSystem_ || !isFineGrain)) {