From 1df08626c896d6a89beedc098a1fa7bfda00be27 Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Mon, 26 Jun 2017 15:29:38 -0500 Subject: [PATCH] Add support of HIP_HIDDEN_FREE_MEM, to deduct the returned available memory from hipMemGetInfo API, measured in MB. Change-Id: I7a8260c12e032e04e26611db4c38c893a29f2653 --- src/hip_hcc.cpp | 5 +++-- src/hip_hcc_internal.h | 2 +- src/hip_memory.cpp | 4 ++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/hip_hcc.cpp b/src/hip_hcc.cpp index 061714070e..364db80537 100644 --- a/src/hip_hcc.cpp +++ b/src/hip_hcc.cpp @@ -78,6 +78,7 @@ int HIP_FORCE_P2P_HOST = 0; int HIP_FAIL_SOC = 0; int HIP_DENY_PEER_ACCESS = 0; +int HIP_HIDDEN_FREE_MEM = 0; // Force async copies to actually use the synchronous copy interface. int HIP_FORCE_SYNC_COPY = 0; @@ -1204,8 +1205,8 @@ void HipReadEnv() tokenize(HIP_LAUNCH_BLOCKING_KERNELS, ',', &g_hipLaunchBlockingKernels); } READ_ENV_I(release, HIP_API_BLOCKING, 0, "Make HIP APIs 'host-synchronous', so they block until completed. Impacts hipMemcpyAsync, hipMemsetAsync." ); - - + + READ_ENV_I(release, HIP_HIDDEN_FREE_MEM, 0, "Amount of memory to hide from the free memory reported by hipMemGetInfo, specified in MB. Impacts hipMemGetInfo." ); READ_ENV_C(release, HIP_DB, 0, "Print debug info. Bitmask (HIP_DB=0xff) or flags separated by '+' (HIP_DB=api+sync+mem+copy)", HIP_DB_callback); if ((HIP_DB & (1<_acc, &deviceMemSize, &hostMemSize, &userMemSize); *free = device->_props.totalGlobalMem - deviceMemSize; + + // Deduct the amount of memory from the free memory reported from the system + if(HIP_HIDDEN_FREE_MEM) + *free -= (size_t)HIP_HIDDEN_FREE_MEM*1024*1024; } else { e = hipErrorInvalidValue;