This is an automated email from the ASF dual-hosted git repository.
moreau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git
The following commit(s) were added to refs/heads/master by this push:
new 44cb105 [VTA] improved virtual memory mapping (#4545)
44cb105 is described below
commit 44cb10540d9010f028cc36da32e118830ae8fe21
Author: Liangfu Chen <[email protected]>
AuthorDate: Sun Dec 22 06:19:56 2019 +0800
[VTA] improved virtual memory mapping (#4545)
* [VTA] improved virtual memory mapping
* Update virtual_memory.cc
---
vta/src/vmem/virtual_memory.cc | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/vta/src/vmem/virtual_memory.cc b/vta/src/vmem/virtual_memory.cc
index 20ffd00..0bf2382 100644
--- a/vta/src/vmem/virtual_memory.cc
+++ b/vta/src/vmem/virtual_memory.cc
@@ -66,9 +66,19 @@ void* VirtualMemoryManager::GetAddr(uint64_t phy_addr) {
vta_phy_addr_t VirtualMemoryManager::GetPhyAddr(void* buf) {
std::lock_guard<std::mutex> lock(mutex_);
auto it = pmap_.find(buf);
- CHECK(it != pmap_.end());
+ uint64_t offset = 0;
+ if (it == pmap_.end()) {
+ for (it = pmap_.begin(); it != pmap_.end(); it++) {
+ uint64_t bytes = it->second->num_pages << kPageBits;
+ if ((buf >= it->first) && (buf < static_cast<char*>(it->first) + bytes))
{
+ offset = static_cast<char*>(buf) - static_cast<char*>(it->first);
+ break;
+ }
+ }
+ CHECK(it != pmap_.end());
+ }
Page* p = it->second.get();
- return (p->ptable_begin + 1) << kPageBits;
+ return ((p->ptable_begin + 1) << kPageBits) + offset;
}
/*!