[python-dtcwt] 155/497: update opencl benchmark script to handle no-OpenCL case
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:06:00 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/sid
in repository python-dtcwt.
commit 72a325e63640f8cf57fa77bd5c50df1d4008f938
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date: Thu Nov 7 20:32:00 2013 +0000
update opencl benchmark script to handle no-OpenCL case
The output from the script is now not terribly edifying if there is no
OpenCL present but it shouldn't fail.
---
scripts/benchmark_opencl.py | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/scripts/benchmark_opencl.py b/scripts/benchmark_opencl.py
index 0d70a5e..83e0870 100644
--- a/scripts/benchmark_opencl.py
+++ b/scripts/benchmark_opencl.py
@@ -12,6 +12,7 @@ import timeit
import numpy as np
from dtcwt.coeffs import biort, qshift
+from dtcwt.opencl.lowlevel import NoCLPresentError
lena = np.load(os.path.join(os.path.dirname(__file__), '..', 'tests', 'lena.npz'))['lena']
h0o, g0o, h1o, g1o = biort('near_sym_b')
@@ -31,11 +32,15 @@ def format_time(t):
def benchmark(statement='pass', setup='pass'):
number, repeat = (1, 3)
min_time = 0
-
- while min_time < 0.2:
- number *= 10
- times = timeit.repeat(statement, setup, repeat=repeat, number=number)
- min_time = min(times)
+
+ try:
+ while min_time < 0.2:
+ number *= 10
+ times = timeit.repeat(statement, setup, repeat=repeat, number=number)
+ min_time = min(times)
+ except NoCLPresentError:
+ print('Skipping benchmark since OpenCL is not present')
+ return 0
t = min_time / number
print('{0} loops, best of {1}: {2}'.format(number, repeat, format_time(t)))
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-dtcwt.git
More information about the debian-science-commits
mailing list