[arrayfire] 146/284: Renamed internal memFree functions
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Sun Feb 7 18:59:28 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/experimental
in repository arrayfire.
commit 33fbf33e4383b610f01efe0294a246574f260b56
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date: Fri Jan 1 16:01:26 2016 -0500
Renamed internal memFree functions
* FreeUnlinked -> FreeLocked
---
src/api/c/device.cpp | 2 +-
src/backend/cpu/memory.cpp | 8 ++++----
src/backend/cpu/memory.hpp | 7 ++++++-
src/backend/cuda/memory.cpp | 10 +++++-----
src/backend/cuda/memory.hpp | 6 +++++-
src/backend/opencl/memory.cpp | 14 +++++++-------
src/backend/opencl/memory.hpp | 12 ++++++++++--
7 files changed, 38 insertions(+), 21 deletions(-)
diff --git a/src/api/c/device.cpp b/src/api/c/device.cpp
index 007e0ab..8f33299 100644
--- a/src/api/c/device.cpp
+++ b/src/api/c/device.cpp
@@ -310,7 +310,7 @@ af_err af_alloc_pinned(void **ptr, const dim_t bytes)
af_err af_free_device(void *ptr)
{
try {
- memFreeUnlinked<char>((char *)ptr, true);
+ memFreeLocked<char>((char *)ptr, true);
} CATCHALL;
return AF_SUCCESS;
}
diff --git a/src/backend/cpu/memory.cpp b/src/backend/cpu/memory.cpp
index e2204ec..625f9b2 100644
--- a/src/backend/cpu/memory.cpp
+++ b/src/backend/cpu/memory.cpp
@@ -196,7 +196,7 @@ T* memAlloc(const size_t &elements)
}
template<typename T>
-void memFreeUnlinked(T *ptr, bool free_unlinked)
+void memFreeLocked(T *ptr, bool freeLocked)
{
std::lock_guard<std::mutex> lock(memory_map_mutex);
@@ -205,7 +205,7 @@ void memFreeUnlinked(T *ptr, bool free_unlinked)
if (iter != memory_map.end()) {
iter->second.mngr_lock = false;
- if ((iter->second).user_lock && !free_unlinked) return;
+ if ((iter->second).user_lock && !freeLocked) return;
iter->second.user_lock = false;
used_bytes -= iter->second.bytes;
@@ -219,7 +219,7 @@ void memFreeUnlinked(T *ptr, bool free_unlinked)
template<typename T>
void memFree(T *ptr)
{
- memFreeUnlinked(ptr, false);
+ memFreeLocked(ptr, false);
}
template<typename T>
@@ -276,7 +276,7 @@ void pinnedFree(T* ptr)
#define INSTANTIATE(T) \
template T* memAlloc(const size_t &elements); \
template void memFree(T* ptr); \
- template void memFreeUnlinked(T* ptr, bool free_unlinked); \
+ template void memFreeLocked(T* ptr, bool freeLocked); \
template void memPop(const T* ptr); \
template void memPush(const T* ptr); \
template T* pinnedAlloc(const size_t &elements); \
diff --git a/src/backend/cpu/memory.hpp b/src/backend/cpu/memory.hpp
index 41a156f..19846c4 100644
--- a/src/backend/cpu/memory.hpp
+++ b/src/backend/cpu/memory.hpp
@@ -12,8 +12,13 @@
namespace cpu
{
template<typename T> T* memAlloc(const size_t &elements);
+
+ // Need these as 2 separate function and not a default argument
+ // This is because it is used as the deleter in shared pointer
+ // which cannot support default arguments
template<typename T> void memFree(T* ptr);
- template<typename T> void memFreeUnlinked(T* ptr, bool free_unlinked);
+ template<typename T> void memFreeLocked(T* ptr, bool freeLocked);
+
template<typename T> void memPop(const T *ptr);
template<typename T> void memPush(const T *ptr);
diff --git a/src/backend/cuda/memory.cpp b/src/backend/cuda/memory.cpp
index 5260950..8152c8a 100644
--- a/src/backend/cuda/memory.cpp
+++ b/src/backend/cuda/memory.cpp
@@ -68,7 +68,7 @@ namespace cuda
}
template<typename T>
- void memFreeUnlinked(T *ptr, bool free_unlinked)
+ void memFreeLocked(T *ptr, bool freeLocked)
{
cudaFreeWrapper(ptr); // Free it because we are not sure what the size is
}
@@ -283,7 +283,7 @@ namespace cuda
}
template<typename T>
- void memFreeUnlinked(T *ptr, bool free_unlinked)
+ void memFreeLocked(T *ptr, bool freeLocked)
{
int n = getActiveDeviceId();
mem_iter iter = memory_maps[n].find((void *)ptr);
@@ -291,7 +291,7 @@ namespace cuda
if (iter != memory_maps[n].end()) {
iter->second.mngr_lock = false;
- if ((iter->second.user_lock) && !free_unlinked) return;
+ if ((iter->second.user_lock) && !freeLocked) return;
iter->second.user_lock = false;
@@ -306,7 +306,7 @@ namespace cuda
template<typename T>
void memFree(T *ptr)
{
- memFreeUnlinked(ptr, false);
+ memFreeLocked(ptr, false);
}
template<typename T>
@@ -430,7 +430,7 @@ namespace cuda
#define INSTANTIATE(T) \
template T* memAlloc(const size_t &elements); \
template void memFree(T* ptr); \
- template void memFreeUnlinked(T* ptr, bool free_unlinked); \
+ template void memFreeLocked(T* ptr, bool freeLocked); \
template void memPop(const T* ptr); \
template void memPush(const T* ptr); \
template T* pinnedAlloc(const size_t &elements); \
diff --git a/src/backend/cuda/memory.hpp b/src/backend/cuda/memory.hpp
index 2d419f2..5644a52 100644
--- a/src/backend/cuda/memory.hpp
+++ b/src/backend/cuda/memory.hpp
@@ -12,8 +12,12 @@
namespace cuda
{
template<typename T> T* memAlloc(const size_t &elements);
+
+ // Need these as 2 separate function and not a default argument
+ // This is because it is used as the deleter in shared pointer
+ // which cannot support default arguments
template<typename T> void memFree(T* ptr);
- template<typename T> void memFreeUnlinked(T* ptr, bool free_unlinked);
+ template<typename T> void memFreeLocked(T* ptr, bool freeLocked);
template<typename T> void memPop(const T *ptr);
template<typename T> void memPush(const T *ptr);
diff --git a/src/backend/opencl/memory.cpp b/src/backend/opencl/memory.cpp
index c37ae2a..141610d 100644
--- a/src/backend/opencl/memory.cpp
+++ b/src/backend/opencl/memory.cpp
@@ -191,10 +191,10 @@ namespace opencl
void bufferFree(cl::Buffer *ptr)
{
- bufferFreeUnlinked(ptr, false);
+ bufferFreeLocked(ptr, false);
}
- void bufferFreeUnlinked(cl::Buffer *ptr, bool free_unlinked)
+ void bufferFreeLocked(cl::Buffer *ptr, bool freeLocked)
{
int n = getActiveDeviceId();
mem_iter iter = memory_maps[n].find(ptr);
@@ -202,7 +202,7 @@ namespace opencl
if (iter != memory_maps[n].end()) {
iter->second.mngr_lock = false;
- if ((iter->second).user_lock && !free_unlinked) return;
+ if ((iter->second).user_lock && !freeLocked) return;
iter->second.user_lock = false;
@@ -260,13 +260,13 @@ namespace opencl
template<typename T>
void memFree(T *ptr)
{
- return bufferFreeUnlinked((cl::Buffer *)ptr, false);
+ return bufferFreeLocked((cl::Buffer *)ptr, false);
}
template<typename T>
- void memFreeUnlinked(T *ptr, bool free_unlinked)
+ void memFreeLocked(T *ptr, bool freeLocked)
{
- return bufferFreeUnlinked((cl::Buffer *)ptr, free_unlinked);
+ return bufferFreeLocked((cl::Buffer *)ptr, freeLocked);
}
template<typename T>
@@ -398,7 +398,7 @@ namespace opencl
#define INSTANTIATE(T) \
template T* memAlloc(const size_t &elements); \
template void memFree(T* ptr); \
- template void memFreeUnlinked(T* ptr, bool free_unlinked); \
+ template void memFreeLocked(T* ptr, bool freeLocked); \
template void memPop(const T* ptr); \
template void memPush(const T* ptr); \
template T* pinnedAlloc(const size_t &elements); \
diff --git a/src/backend/opencl/memory.hpp b/src/backend/opencl/memory.hpp
index 625bd10..96292cd 100644
--- a/src/backend/opencl/memory.hpp
+++ b/src/backend/opencl/memory.hpp
@@ -15,12 +15,20 @@ namespace opencl
{
cl::Buffer *bufferAlloc(const size_t &bytes);
+
+ // Need these as 2 separate function and not a default argument
+ // This is because it is used as the deleter in shared pointer
+ // which cannot support default arguments
void bufferFree(cl::Buffer *buf);
- void bufferFreeUnlinked(cl::Buffer *buf, bool free_unlinked);
+ void bufferFreeLocked(cl::Buffer *buf, bool freeLocked);
template<typename T> T *memAlloc(const size_t &elements);
+
+ // Need these as 2 separate function and not a default argument
+ // This is because it is used as the deleter in shared pointer
+ // which cannot support default arguments
template<typename T> void memFree(T* ptr);
- template<typename T> void memFreeUnlinked(T* ptr, bool free_unlinked);
+ template<typename T> void memFreeLocked(T* ptr, bool freeLocked);
template<typename T> void memPop(const T *ptr);
template<typename T> void memPush(const T *ptr);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git
More information about the debian-science-commits
mailing list