[python-arrayfire] 116/250: FEAT/TEST: Adding function to call garbage collector

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:38 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/master
in repository python-arrayfire.

commit 8e895a5900951bb6fb2068f50ec58dd61ee38f77
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Wed Sep 9 20:44:51 2015 -0400

    FEAT/TEST: Adding function to call garbage collector
---
 arrayfire/device.py    | 6 ++++++
 tests/simple/device.py | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/arrayfire/device.py b/arrayfire/device.py
index 65a7de4..f115673 100644
--- a/arrayfire/device.py
+++ b/arrayfire/device.py
@@ -132,3 +132,9 @@ def device_mem_info():
     mem_info['alloc'] = {'buffers' : alloc_buffers.value, 'bytes' : alloc_bytes.value}
     mem_info['lock'] = {'buffers' : lock_buffers.value, 'bytes' : lock_bytes.value}
     return mem_info
+
+def device_gc():
+    """
+    Ask the garbage collector to free all unlocked memory
+    """
+    safe_call(backend.get().af_device_gc())
diff --git a/tests/simple/device.py b/tests/simple/device.py
index 250e093..3132ae1 100644
--- a/tests/simple/device.py
+++ b/tests/simple/device.py
@@ -19,6 +19,8 @@ def simple_device(verbose=False):
     print_func(af.is_dbl_supported())
     af.sync()
 
+    dev = af.get_device()
+    print_func(dev)
     for k in range(af.get_device_count()):
         af.set_device(k)
         dev = af.get_device()
@@ -26,6 +28,8 @@ def simple_device(verbose=False):
 
         print_func(af.is_dbl_supported(k))
 
+        af.device_gc()
+
         mem_info_old = af.device_mem_info()
 
         a = af.randu(100, 100)
@@ -34,4 +38,6 @@ def simple_device(verbose=False):
         assert(mem_info['alloc']['buffers'] == 1 + mem_info_old['alloc']['buffers'])
         assert(mem_info[ 'lock']['buffers'] == 1 + mem_info_old[ 'lock']['buffers'])
 
+    af.set_device(dev)
+
 _util.tests['device'] = simple_device

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-arrayfire.git



More information about the debian-science-commits mailing list