From 25fe45bb2ab16d71e57bacee46cbf3f1e262e186 Mon Sep 17 00:00:00 2001 From: Ruili Ji Date: Tue, 14 Mar 2023 15:37:44 +0800 Subject: [PATCH] SWDEV-383856 - Remove mmap function for SVM buffer For large bar platform, it's not necessary to mmap memory allocated on VRAM to cpu again Change-Id: I0701680476829d4058b3e7b643e8df657d0c6168 Signed-off-by: Ruili Ji --- rocclr/platform/memory.cpp | 6 +++++- rocclr/platform/memory.hpp | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/rocclr/platform/memory.cpp b/rocclr/platform/memory.cpp index 4d12a2ebea..cea1098b92 100644 --- a/rocclr/platform/memory.cpp +++ b/rocclr/platform/memory.cpp @@ -285,6 +285,9 @@ bool Memory::create(void* initFrom, bool sysMemAlloc, bool skipAlloc, bool force } const std::vector& devices = context_().devices(); + if (devices.size() == 1 && devices[0]->info().largeBar_) { + largeBarSystem_ = 1; + } // Forces system memory allocation on the device, // instead of device memory @@ -500,7 +503,8 @@ bool Memory::usesSvmPointer() const { void Memory::commitSvmMemory() { ScopedLock lock(lockMemoryOps_); - if (!svmPtrCommited_) { + // if VRAM is visible for host, it is not necessary to mmap again + if (!svmPtrCommited_ && !largeBarSystem_) { amd::Os::commitMemory(svmHostAddress_, size_, amd::Os::MEM_PROT_RW); svmPtrCommited_ = true; } diff --git a/rocclr/platform/memory.hpp b/rocclr/platform/memory.hpp index ba89e18cca..1837698e95 100644 --- a/rocclr/platform/memory.hpp +++ b/rocclr/platform/memory.hpp @@ -201,6 +201,7 @@ class Memory : public amd::RuntimeObject { uint32_t canBeCached_ : 1; //!< flag to if the object can be cached uint32_t p2pAccess_ : 1; //!< Memory object allows P2P access uint32_t ipcShared_ : 1; //!< Memory shared between processes + uint32_t largeBarSystem_ : 1; //!< VRAM is visiable for host }; uint32_t flagsEx_; };