[arrayfire] 139/284: Deprecate af_(lock/unlock)_device_ptr. Use af_(lock/unlock)_array

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Sun Feb 7 18:59:27 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 960574050303c363ef26be8c8a7c05c15974904f
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date:   Thu Dec 31 18:19:08 2015 -0500

    Deprecate af_(lock/unlock)_device_ptr. Use af_(lock/unlock)_array
---
 include/af/device.h        | 28 ++++++++++++++++++++-
 src/api/c/device.cpp       | 62 +++++++++++++++++++++++++++-------------------
 src/api/cpp/array.cpp      |  4 +--
 src/api/unified/device.cpp | 12 +++++++++
 4 files changed, 77 insertions(+), 29 deletions(-)

diff --git a/include/af/device.h b/include/af/device.h
index ff33b33..394170c 100644
--- a/include/af/device.h
+++ b/include/af/device.h
@@ -346,9 +346,12 @@ extern "C" {
     /**
        Lock the device buffer in the memory manager.
 
-       Locked buffers are not freed by memory manager until \ref af_unlock_device_ptr is called.
+       Locked buffers are not freed by memory manager until \ref af_unlock_array is called.
        \ingroup device_func_mem
     */
+#if AF_API_VERSION >= 33
+    DEPRECATED("Use af_lock_array instead")
+#endif
     AFAPI af_err af_lock_device_ptr(const af_array arr);
 #endif
 
@@ -359,9 +362,32 @@ extern "C" {
        This function will give back the control over the device pointer to the memory manager.
        \ingroup device_func_mem
     */
+#if AF_API_VERSION >= 33
+    DEPRECATED("Use af_unlock_array instead")
+#endif
     AFAPI af_err af_unlock_device_ptr(const af_array arr);
 #endif
 
+#if AF_API_VERSION >= 33
+    /**
+       Lock the device buffer in the memory manager.
+
+       Locked buffers are not freed by memory manager until \ref af_unlock_array is called.
+       \ingroup device_func_mem
+    */
+    AFAPI af_err af_lock_array(const af_array arr);
+#endif
+
+#if AF_API_VERSION >= 33
+    /**
+       Unlock device buffer in the memory manager.
+
+       This function will give back the control over the device pointer to the memory manager.
+       \ingroup device_func_mem
+    */
+    AFAPI af_err af_unlock_array(const af_array arr);
+#endif
+
     /**
        Get the device pointer and lock the buffer in memory manager.
 
diff --git a/src/api/c/device.cpp b/src/api/c/device.cpp
index 84cd246..51eb613 100644
--- a/src/api/c/device.cpp
+++ b/src/api/c/device.cpp
@@ -214,29 +214,34 @@ af_err af_get_device_ptr(void **data, const af_array arr)
 }
 
 template <typename T>
-inline void lockDevicePtr(const af_array arr)
+inline void lockArray(const af_array arr)
 {
     memPop<T>((const T *)getArray<T>(arr).get());
 }
 
 af_err af_lock_device_ptr(const af_array arr)
 {
+    return af_lock_array(arr);
+}
+
+af_err af_lock_array(const af_array arr)
+{
     try {
         af_dtype type = getInfo(arr).getType();
 
         switch (type) {
-        case f32: lockDevicePtr<float  >(arr); break;
-        case f64: lockDevicePtr<double >(arr); break;
-        case c32: lockDevicePtr<cfloat >(arr); break;
-        case c64: lockDevicePtr<cdouble>(arr); break;
-        case s32: lockDevicePtr<int    >(arr); break;
-        case u32: lockDevicePtr<uint   >(arr); break;
-        case s64: lockDevicePtr<intl   >(arr); break;
-        case u64: lockDevicePtr<uintl  >(arr); break;
-        case s16: lockDevicePtr<short  >(arr); break;
-        case u16: lockDevicePtr<ushort >(arr); break;
-        case u8 : lockDevicePtr<uchar  >(arr); break;
-        case b8 : lockDevicePtr<char   >(arr); break;
+        case f32: lockArray<float  >(arr); break;
+        case f64: lockArray<double >(arr); break;
+        case c32: lockArray<cfloat >(arr); break;
+        case c64: lockArray<cdouble>(arr); break;
+        case s32: lockArray<int    >(arr); break;
+        case u32: lockArray<uint   >(arr); break;
+        case s64: lockArray<intl   >(arr); break;
+        case u64: lockArray<uintl  >(arr); break;
+        case s16: lockArray<short  >(arr); break;
+        case u16: lockArray<ushort >(arr); break;
+        case u8 : lockArray<uchar  >(arr); break;
+        case b8 : lockArray<char   >(arr); break;
         default: TYPE_ERROR(4, type);
         }
 
@@ -246,29 +251,34 @@ af_err af_lock_device_ptr(const af_array arr)
 }
 
 template <typename T>
-inline void unlockDevicePtr(const af_array arr)
+inline void unlockArray(const af_array arr)
 {
     memPush<T>((const T *)getArray<T>(arr).get());
 }
 
 af_err af_unlock_device_ptr(const af_array arr)
 {
+    return af_unlock_array(arr);
+}
+
+af_err af_unlock_array(const af_array arr)
+{
     try {
         af_dtype type = getInfo(arr).getType();
 
         switch (type) {
-        case f32: unlockDevicePtr<float  >(arr); break;
-        case f64: unlockDevicePtr<double >(arr); break;
-        case c32: unlockDevicePtr<cfloat >(arr); break;
-        case c64: unlockDevicePtr<cdouble>(arr); break;
-        case s32: unlockDevicePtr<int    >(arr); break;
-        case u32: unlockDevicePtr<uint   >(arr); break;
-        case s64: unlockDevicePtr<intl   >(arr); break;
-        case u64: unlockDevicePtr<uintl  >(arr); break;
-        case s16: unlockDevicePtr<short  >(arr); break;
-        case u16: unlockDevicePtr<ushort >(arr); break;
-        case u8 : unlockDevicePtr<uchar  >(arr); break;
-        case b8 : unlockDevicePtr<char   >(arr); break;
+        case f32: unlockArray<float  >(arr); break;
+        case f64: unlockArray<double >(arr); break;
+        case c32: unlockArray<cfloat >(arr); break;
+        case c64: unlockArray<cdouble>(arr); break;
+        case s32: unlockArray<int    >(arr); break;
+        case u32: unlockArray<uint   >(arr); break;
+        case s64: unlockArray<intl   >(arr); break;
+        case u64: unlockArray<uintl  >(arr); break;
+        case s16: unlockArray<short  >(arr); break;
+        case u16: unlockArray<ushort >(arr); break;
+        case u8 : unlockArray<uchar  >(arr); break;
+        case b8 : unlockArray<char   >(arr); break;
         default: TYPE_ERROR(4, type);
         }
 
diff --git a/src/api/cpp/array.cpp b/src/api/cpp/array.cpp
index f7931cf..b993e2f 100644
--- a/src/api/cpp/array.cpp
+++ b/src/api/cpp/array.cpp
@@ -1057,11 +1057,11 @@ af::dtype implicit_dtype(af::dtype scalar_type, af::dtype array_type)
 
     void array::lock() const
     {
-        AF_THROW(af_lock_device_ptr(get()));
+        AF_THROW(af_lock_array(get()));
     }
 
     void array::unlock() const
     {
-        AF_THROW(af_unlock_device_ptr(get()));
+        AF_THROW(af_unlock_array(get()));
     }
 }
diff --git a/src/api/unified/device.cpp b/src/api/unified/device.cpp
index 8f04bf6..1d5979a 100644
--- a/src/api/unified/device.cpp
+++ b/src/api/unified/device.cpp
@@ -148,6 +148,18 @@ af_err af_unlock_device_ptr(const af_array arr)
     return CALL(arr);
 }
 
+af_err af_lock_array(const af_array arr)
+{
+    CHECK_ARRAYS(arr);
+    return CALL(arr);
+}
+
+af_err af_unlock_array(const af_array arr)
+{
+    CHECK_ARRAYS(arr);
+    return CALL(arr);
+}
+
 af_err af_get_device_ptr(void **ptr, const af_array arr)
 {
     CHECK_ARRAYS(arr);

-- 
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