Fix for hipPointerGetAttributes [github#2137]

Change-Id: I5295575638ecc4d3b7129552a9c26c6f6a7195fc


[ROCm/hip commit: 5c7b7d1dd2]
Esse commit está contido em:
Sarbojit Sarkar
2020-09-01 05:49:23 -04:00
commit de Sarbojit Sarkar
commit 00632b266c
+8 -2
Ver Arquivo
@@ -2029,14 +2029,20 @@ hipError_t hipHostGetDevicePointer(void** devicePointer, void* hostPointer, unsi
hipError_t hipPointerGetAttributes(hipPointerAttribute_t* attributes, const void* ptr) {
HIP_INIT_API(hipPointerGetAttributes, attributes, ptr);
if (attributes == nullptr || ptr == nullptr) {
HIP_RETURN(hipErrorInvalidValue);
}
size_t offset = 0;
amd::Memory* memObj = getMemoryObject(ptr, offset);
int device = 0;
memset(attributes, 0, sizeof(hipPointerAttribute_t));
if (memObj != nullptr) {
attributes->memoryType = (CL_MEM_SVM_FINE_GRAIN_BUFFER & memObj->getMemFlags())? hipMemoryTypeHost : hipMemoryTypeDevice;
attributes->hostPointer = memObj->getSvmPtr();
attributes->devicePointer = memObj->getSvmPtr();
if (attributes->memoryType == hipMemoryTypeHost) {
attributes->hostPointer = static_cast<char*>(memObj->getSvmPtr()) + offset;
}
attributes->devicePointer = static_cast<char*>(memObj->getSvmPtr()) + offset;
attributes->isManaged = 0;
attributes->allocationFlags = memObj->getMemFlags() >> 16;