From 9b3072ae129b5e0c97a460979164e1320707ceab Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Mon, 17 May 2021 12:42:57 -0400 Subject: [PATCH] SWDEV-240804 - Switch SVM attribute for the first alloc Use HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE flag for the initial allocation instead of HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE_IN_PLACE. Change-Id: Ia52fe205563df1ea916dc2dc81e749e11c16f83d --- rocclr/device/rocm/rocdevice.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/rocclr/device/rocm/rocdevice.cpp b/rocclr/device/rocm/rocdevice.cpp index ae9046652b..a512d2f628 100644 --- a/rocclr/device/rocm/rocdevice.cpp +++ b/rocclr/device/rocm/rocdevice.cpp @@ -2240,24 +2240,25 @@ bool Device::SetSvmAttributesInt(const void* dev_ptr, size_t count, // @note: 0 may cause a failure on old runtimes attr.push_back({HSA_AMD_SVM_ATTRIB_PREFERRED_LOCATION, 0}); break; - case amd::MemoryAdvice::SetAccessedBy: + case amd::MemoryAdvice::SetAccessedBy: { + const uint64_t attrib = (first_alloc) ? HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE : + HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE_IN_PLACE; if (use_cpu) { - attr.push_back({HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE_IN_PLACE, getCpuAgent().handle}); + attr.push_back({attrib, getCpuAgent().handle}); } else { 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}); + attr.push_back({attrib, static_cast(dev)->getBackendDevice().handle}); } } else { - attr.push_back({HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE_IN_PLACE, - getBackendDevice().handle}); + attr.push_back({attrib, getBackendDevice().handle}); } } break; + } case amd::MemoryAdvice::UnsetAccessedBy: // @note: 0 may cause a failure on old runtimes attr.push_back({HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE_IN_PLACE, 0}); @@ -2443,13 +2444,6 @@ bool Device::SvmAllocInit(void* memory, size_t size) const { return false; } - if (settings().hmmFlags_ & Settings::Hmm::EnableSystemMemory) { - advice = amd::MemoryAdvice::UnsetPreferredLocation; - if (!SetSvmAttributesInt(memory, size, advice)) { - return false; - } - } - if ((settings().hmmFlags_ & Settings::Hmm::EnableMallocPrefetch) == 0) { return true; }