SWDEV-355281 - Add offset calculation

Calculate memory location offset for requested memory

Change-Id: I7919523df1790d9eaad5827ee5bd98e4263a7554


[ROCm/clr commit: 5d83345c20]
이 커밋은 다음에 포함됨:
German Andryeyev가 2023-01-16 14:19:40 -05:00를 커밋했습니다
1 부모 19c80916fa
커밋 8ad3120e25
2 파일이 변경됨
+6 -2

검색과 일치하는 파일 없음

+4 -1
파일 보기
@@ -296,7 +296,7 @@ void MemObjMap::RemoveMemObj(const void* k) {
}
}
amd::Memory* MemObjMap::FindMemObj(const void* k) {
amd::Memory* MemObjMap::FindMemObj(const void* k, size_t* offset) {
amd::ScopedLock lock(AllocatedLock_);
uintptr_t key = reinterpret_cast<uintptr_t>(k);
auto it = MemObjMap_.upper_bound(key);
@@ -307,6 +307,9 @@ amd::Memory* MemObjMap::FindMemObj(const void* k) {
--it;
amd::Memory* mem = it->second;
if (key >= it->first && key < (it->first + mem->getSize())) {
if (offset != nullptr) {
*offset = key - it->first;
}
// the k is in the range
return mem;
} else {
+2 -1
파일 보기
@@ -1294,7 +1294,8 @@ class MemObjMap : public AllStatic {
amd::Memory* v); //!< add the host mem pointer and buffer in the container
static void RemoveMemObj(const void* k); //!< Remove an entry of mem object from the container
static amd::Memory* FindMemObj(
const void* k); //!< find the mem object based on the input pointer
const void* k, //!< find the mem object based on the input pointer
size_t* offset = nullptr); //!< Offset in the memory location
static void UpdateAccess(amd::Device *peerDev);
static void Purge(amd::Device* dev); //!< Purge all user allocated memories on the given device