Explicit page table update on all devices

HMM with xnack enabled should automatically update page tables,
but currently it doesn't perform that. For now, runtime will
force page table update on all devices unconditionally.

Change-Id: Idfa6e1c145e6c114856214dce042b8a8349e5c58
Этот коммит содержится в:
German Andryeyev
2021-01-12 00:20:20 -05:00
родитель 318eecfc87
Коммит 7d3aaa7a39
2 изменённых файлов: 11 добавлений и 12 удалений
+11 -4
Просмотреть файл
@@ -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<Device*>(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) {
-8
Просмотреть файл
@@ -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)) {