Added new API, hipMemPtrGetInfo

1. This API returns memory allocation size of pointer
2. Added test to check its functionality

Change-Id: I87976d817b5a6ca5530336c09e7cb0420601cb2c


[ROCm/hip commit: 1546732604]
This commit is contained in:
Aditya Atluri
2017-03-07 13:46:29 -06:00
parent 6cbeeb8e59
commit fe81d08987
4 changed files with 77 additions and 1 deletions
+21
View File
@@ -1024,6 +1024,27 @@ hipError_t hipMemGetInfo (size_t *free, size_t *total)
return ihipLogStatus(e);
}
hipError_t hipMemPtrGetInfo(void *ptr, size_t *size)
{
HIP_INIT_API(ptr, size);
hipError_t e = hipSuccess;
if(ptr != nullptr && size != nullptr){
hc::accelerator acc;
hc::AmPointerInfo amPointerInfo(NULL, NULL, 0, acc, 0, 0);
am_status_t status = hc::am_memtracker_getinfo(&amPointerInfo, ptr);
if(status == AM_SUCCESS){
*size = amPointerInfo._sizeBytes;
}else{
e = hipErrorInvalidValue;
}
}else{
e = hipErrorInvalidValue;
}
return ihipLogStatus(e);
}
hipError_t hipFree(void* ptr)
{
HIP_INIT_API(ptr);