SWDEV-328670 - Pass the size of allocation

The actual size of allocation can be different from the original
request due to alignments. Pass the size of the original request
for validation during the arena object look-up

Change-Id: I30000046b1ec56abe743e43113046144fd3edbc6
This commit is contained in:
German Andryeyev
2022-04-01 11:12:04 -04:00
parent b5d9d61f5d
commit fb835c6f3e
2 changed files with 5 additions and 4 deletions
+4 -3
View File
@@ -28,7 +28,7 @@
#include "amdocl/cl_vk_amd.hpp"
// ================================================================================================
amd::Memory* getMemoryObject(const void* ptr, size_t& offset) {
amd::Memory* getMemoryObject(const void* ptr, size_t& offset, size_t size) {
amd::Memory *memObj = amd::MemObjMap::FindMemObj(ptr);
if (memObj != nullptr) {
const char* hostPtr = reinterpret_cast<const char*>(ptr);
@@ -51,7 +51,8 @@ amd::Memory* getMemoryObject(const void* ptr, size_t& offset) {
}
} else {
// If memObj not found, use arena_mem_obj. arena_mem_obj is null, if HMM and Xnack is disabled.
memObj = (hip::getCurrentDevice()->asContext()->svmDevices()[0])->GetArenaMemObj(ptr, offset);
memObj = (hip::getCurrentDevice()->asContext()->svmDevices()[0])->GetArenaMemObj(
ptr, offset, size);
}
return memObj;
}
@@ -2413,7 +2414,7 @@ hipError_t hipMemsetD32Async(hipDeviceptr_t dst, int value, size_t count,
hipError_t ihipMemset3D_validate(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent,
size_t sizeBytes) {
size_t offset = 0;
amd::Memory* memory = getMemoryObject(pitchedDevPtr.ptr, offset);
amd::Memory* memory = getMemoryObject(pitchedDevPtr.ptr, offset, sizeBytes);
if (memory == nullptr) {
return hipErrorInvalidValue;