From 6d1d6b9cfb4957f629727e0babbf0937ee3dbfd4 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Sat, 17 Sep 2016 23:54:20 +0530 Subject: [PATCH] Added return error code hipErrorInvalidValue in hipMemGetInfo Change-Id: If01b012136b655ff8eb4878eb703dfe3e6a36530 [ROCm/clr commit: 8842a0d5b874d9208a339f79f3a5dae356057263] --- projects/clr/hipamd/include/hcc_detail/hip_runtime_api.h | 2 +- projects/clr/hipamd/src/hip_memory.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/projects/clr/hipamd/include/hcc_detail/hip_runtime_api.h b/projects/clr/hipamd/include/hcc_detail/hip_runtime_api.h index 3de715cbbc..71732eb8e3 100644 --- a/projects/clr/hipamd/include/hcc_detail/hip_runtime_api.h +++ b/projects/clr/hipamd/include/hcc_detail/hip_runtime_api.h @@ -1112,7 +1112,7 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t st * Return snapshot of free memory, and total allocatable memory on the device. * * Returns in *free a snapshot of the current free memory. - * @returns #hipSuccess, #hipErrorInvalidDevice, #hipErrorInvalidValue (if free != NULL due to bugs) + * @returns #hipSuccess, #hipErrorInvalidDevice, #hipErrorInvalidValue * @warning On HCC, the free memory only accounts for memory allocated by this process and may be optimistic. **/ hipError_t hipMemGetInfo (size_t * free, size_t * total) ; diff --git a/projects/clr/hipamd/src/hip_memory.cpp b/projects/clr/hipamd/src/hip_memory.cpp index 0478ff26d7..0cc53f7754 100644 --- a/projects/clr/hipamd/src/hip_memory.cpp +++ b/projects/clr/hipamd/src/hip_memory.cpp @@ -864,6 +864,9 @@ hipError_t hipMemGetInfo (size_t *free, size_t *total) if (total) { *total = device->_props.totalGlobalMem; } + else { + e = hipErrorInvalidValue; + } if (free) { // TODO - replace with kernel-level for reporting free memory: @@ -872,6 +875,9 @@ hipError_t hipMemGetInfo (size_t *free, size_t *total) *free = device->_props.totalGlobalMem - deviceMemSize; } + else { + e = hipErrorInvalidValue; + } } else { e = hipErrorInvalidDevice;