From 381e886886dc87823769c5f20d0ecb29dd117afa Mon Sep 17 00:00:00 2001 From: Lucas C Wilcox Date: Wed, 23 Nov 2016 21:12:21 -0800 Subject: [PATCH] Don't count mapped allocations (#42) Mapped allocations don't use device memory, so we will not count them with the device memory counter. --- src/base.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/base.cpp b/src/base.cpp index 64c39e262..460704301 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -1588,7 +1588,8 @@ namespace occa { void memory::free() { checkIfInitialized(); - mHandle->dHandle->bytesAllocated -= (mHandle->size); + if(!mHandle->isMapped()) + mHandle->dHandle->bytesAllocated -= (mHandle->size); if(mHandle->uvaPtr) { uvaMap.erase(mHandle->uvaPtr); @@ -1617,7 +1618,8 @@ namespace occa { void memory::detach() { checkIfInitialized(); - mHandle->dHandle->bytesAllocated -= (mHandle->size); + if(!mHandle->isMapped()) + mHandle->dHandle->bytesAllocated -= (mHandle->size); if(mHandle->uvaPtr) { uvaMap.erase(mHandle->uvaPtr); @@ -2260,8 +2262,6 @@ namespace occa { mem.mHandle = dHandle->mappedAlloc(bytes, src); mem.mHandle->dHandle = dHandle; - dHandle->bytesAllocated += bytes; - return mem; }