[python-arrayfire] 154/250: Adding benchmark examples

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:43 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 5879685ec7f2446d7924d3409b545d87bf2745ac
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Tue Dec 8 21:08:52 2015 -0500

    Adding benchmark examples
---
 examples/benchmarks/bench_blas.py | 39 ++++++++++++++++++++++++++++++++++++++
 examples/benchmarks/bench_fft.py  | 40 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+)

diff --git a/examples/benchmarks/bench_blas.py b/examples/benchmarks/bench_blas.py
new file mode 100644
index 0000000..1b31590
--- /dev/null
+++ b/examples/benchmarks/bench_blas.py
@@ -0,0 +1,39 @@
+#!/usr/bin/python
+
+#######################################################
+# Copyright (c) 2015, ArrayFire
+# All rights reserved.
+#
+# This file is distributed under 3-clause BSD license.
+# The complete license agreement can be obtained at:
+# http://arrayfire.com/licenses/BSD-3-Clause
+########################################################
+
+
+import sys
+from time import time
+from arrayfire import (array, randu, matmul)
+import arrayfire as af
+
+def bench(A, iters = 100):
+    start = time()
+    for t in range(iters):
+        B = af.matmul(A, A)
+    af.sync()
+    return (time() - start) / iters
+
+if __name__ == "__main__":
+
+    if (len(sys.argv) > 1):
+        af.set_device(int(sys.argv[1]))
+
+    af.info()
+    print("Benchmark N x N matrix multiply")
+
+    for n in range(128, 2048 + 128, 128):
+        A = af.randu(n, n)
+        af.sync()
+
+        t = bench(A)
+        gflops = 2.0 * (n**3) / (t * 1E9)
+        print("Time taken for %4d x %4d: %0.4f Gflops" % (n, n, gflops))
diff --git a/examples/benchmarks/bench_fft.py b/examples/benchmarks/bench_fft.py
new file mode 100644
index 0000000..735e8d6
--- /dev/null
+++ b/examples/benchmarks/bench_fft.py
@@ -0,0 +1,40 @@
+#!/usr/bin/python
+
+#######################################################
+# Copyright (c) 2015, ArrayFire
+# All rights reserved.
+#
+# This file is distributed under 3-clause BSD license.
+# The complete license agreement can be obtained at:
+# http://arrayfire.com/licenses/BSD-3-Clause
+########################################################
+
+
+import sys
+from time import time
+from arrayfire import (array, randu, matmul)
+import arrayfire as af
+
+def bench(A, iters = 100):
+    start = time()
+    for t in range(iters):
+        B = af.fft2(A)
+    af.sync()
+    return (time() - start) / iters
+
+if __name__ == "__main__":
+
+    if (len(sys.argv) > 1):
+        af.set_device(int(sys.argv[1]))
+
+    af.info()
+    print("Benchmark N x N 2D fft")
+
+    for M in range(7, 13):
+        N = 1 << M
+        A = af.randu(N, N)
+        af.sync()
+
+        t = bench(A)
+        gflops = (10.0 * N * N * M) / (t * 1E9)
+        print("Time taken for %4d x %4d: %0.4f Gflops" % (N, N, gflops))

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