From c10b1f555d4b15fd215dca416a55ec22f099b11e Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Tue, 19 Jan 2016 12:32:14 -0500 Subject: [PATCH 01/14] benchmark/scripts/SCIPY/dsyrk.py: Allocate `C` using zeros instead of randomly generating it. --- benchmark/scripts/SCIPY/dsyrk.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/benchmark/scripts/SCIPY/dsyrk.py b/benchmark/scripts/SCIPY/dsyrk.py index 1ff481e4a..714b253de 100755 --- a/benchmark/scripts/SCIPY/dsyrk.py +++ b/benchmark/scripts/SCIPY/dsyrk.py @@ -4,13 +4,14 @@ import os import sys import time import numpy +from numpy import zeros from numpy.random import randn from scipy.linalg import blas def run_dsyrk(N,l): A = randn(N,N).astype('float64') - C = randn(N,N).astype('float64') + C = zeros((N,N), dtype='float64') start = time.time(); From 8b981e41a165a2ec061227a01b8e6323488111ba Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Tue, 19 Jan 2016 12:32:26 -0500 Subject: [PATCH 02/14] benchmark/scripts/SCIPY/ssyrk.py: Allocate `C` using zeros instead of randomly generating it. --- benchmark/scripts/SCIPY/ssyrk.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/benchmark/scripts/SCIPY/ssyrk.py b/benchmark/scripts/SCIPY/ssyrk.py index 1dee9e21d..c7e1bdbe1 100755 --- a/benchmark/scripts/SCIPY/ssyrk.py +++ b/benchmark/scripts/SCIPY/ssyrk.py @@ -4,13 +4,14 @@ import os import sys import time import numpy +from numpy import zeros from numpy.random import randn from scipy.linalg import blas def run_ssyrk(N,l): A = randn(N,N).astype('float32') - C = randn(N,N).astype('float32') + C = zeros((N,N), dtype='float32') start = time.time(); From 1a73390ffe5eb394d373386eee22618199182ae3 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Tue, 19 Jan 2016 12:33:44 -0500 Subject: [PATCH 03/14] benchmark/scripts/SCIPY/dsyrk.py: Drop unneeded semicolons. --- benchmark/scripts/SCIPY/dsyrk.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/scripts/SCIPY/dsyrk.py b/benchmark/scripts/SCIPY/dsyrk.py index 714b253de..10b96d3f2 100755 --- a/benchmark/scripts/SCIPY/dsyrk.py +++ b/benchmark/scripts/SCIPY/dsyrk.py @@ -14,7 +14,7 @@ def run_dsyrk(N,l): C = zeros((N,N), dtype='float64') - start = time.time(); + start = time.time() for i in range(0,l): C = blas.dsyrk(1.0,A) end = time.time() @@ -49,7 +49,7 @@ if __name__ == "__main__": if 'OPENBLAS_LOOPS' in os.environ: p = os.environ['OPENBLAS_LOOPS'] if p: - LOOPS = int(p); + LOOPS = int(p) print("From: %d To: %d Step=%d Loops=%d" % (N, NMAX, NINC, LOOPS)) print("\tSIZE\t\t\tFlops\t\t\t\t\tTime") From 1153459d1b894f86c272fdbf38d3cc3f123cea0c Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Tue, 19 Jan 2016 12:34:01 -0500 Subject: [PATCH 04/14] benchmark/scripts/SCIPY/ssyrk.py: Drop unneeded semicolons. --- benchmark/scripts/SCIPY/ssyrk.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/scripts/SCIPY/ssyrk.py b/benchmark/scripts/SCIPY/ssyrk.py index c7e1bdbe1..60cfa966a 100755 --- a/benchmark/scripts/SCIPY/ssyrk.py +++ b/benchmark/scripts/SCIPY/ssyrk.py @@ -14,7 +14,7 @@ def run_ssyrk(N,l): C = zeros((N,N), dtype='float32') - start = time.time(); + start = time.time() for i in range(0,l): C = blas.ssyrk(1.0,A) end = time.time() @@ -49,7 +49,7 @@ if __name__ == "__main__": if 'OPENBLAS_LOOPS' in os.environ: p = os.environ['OPENBLAS_LOOPS'] if p: - LOOPS = int(p); + LOOPS = int(p) print("From: %d To: %d Step=%d Loops=%d" % (N, NMAX, NINC, LOOPS)) print("\tSIZE\t\t\tFlops\t\t\t\t\tTime") From cb554b3a9c9f9413a2c1a660c558d21ac84ea191 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Tue, 19 Jan 2016 14:04:55 -0500 Subject: [PATCH 05/14] benchmark/scripts/SCIPY/dsyrk.py: Use the environment python. --- benchmark/scripts/SCIPY/dsyrk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/scripts/SCIPY/dsyrk.py b/benchmark/scripts/SCIPY/dsyrk.py index 10b96d3f2..eb47ebdb1 100755 --- a/benchmark/scripts/SCIPY/dsyrk.py +++ b/benchmark/scripts/SCIPY/dsyrk.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python import os import sys From dd04a8ac2253358f52d7e8dab6c237f87275923b Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Tue, 19 Jan 2016 14:05:14 -0500 Subject: [PATCH 06/14] benchmark/scripts/SCIPY/ssyrk.py: Use the environment python. --- benchmark/scripts/SCIPY/ssyrk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/scripts/SCIPY/ssyrk.py b/benchmark/scripts/SCIPY/ssyrk.py index 60cfa966a..88a8250e8 100755 --- a/benchmark/scripts/SCIPY/ssyrk.py +++ b/benchmark/scripts/SCIPY/ssyrk.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python import os import sys From 81e8690763f2db95c29d0c18d791ce0ced1ebfdb Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Tue, 19 Jan 2016 15:00:23 -0500 Subject: [PATCH 07/14] benchmark/scripts/SCIPY/dsyrk.py: Write values into `C`. --- benchmark/scripts/SCIPY/dsyrk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/scripts/SCIPY/dsyrk.py b/benchmark/scripts/SCIPY/dsyrk.py index eb47ebdb1..8e89d5852 100755 --- a/benchmark/scripts/SCIPY/dsyrk.py +++ b/benchmark/scripts/SCIPY/dsyrk.py @@ -16,7 +16,7 @@ def run_dsyrk(N,l): start = time.time() for i in range(0,l): - C = blas.dsyrk(1.0,A) + C[...] = blas.dsyrk(1.0,A) end = time.time() timediff = (end -start) From 77abc9b28005a5ab469282ed19a0e9bcc9603a7d Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Tue, 19 Jan 2016 15:00:54 -0500 Subject: [PATCH 08/14] benchmark/scripts/SCIPY/ssyrk.py: Write values into `C`. --- benchmark/scripts/SCIPY/ssyrk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/scripts/SCIPY/ssyrk.py b/benchmark/scripts/SCIPY/ssyrk.py index 88a8250e8..034c0fd3a 100755 --- a/benchmark/scripts/SCIPY/ssyrk.py +++ b/benchmark/scripts/SCIPY/ssyrk.py @@ -16,7 +16,7 @@ def run_ssyrk(N,l): start = time.time() for i in range(0,l): - C = blas.ssyrk(1.0,A) + C[...] = blas.ssyrk(1.0,A) end = time.time() timediff = (end -start) From cbb6649e979780705dcddb4bfb1b402a8197c02b Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Tue, 19 Jan 2016 15:05:18 -0500 Subject: [PATCH 09/14] benchmark/scripts/SCIPY/dsyrk.py: Fix PEP8 issues. --- benchmark/scripts/SCIPY/dsyrk.py | 83 ++++++++++++++++---------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/benchmark/scripts/SCIPY/dsyrk.py b/benchmark/scripts/SCIPY/dsyrk.py index 8e89d5852..0ee83bcb7 100755 --- a/benchmark/scripts/SCIPY/dsyrk.py +++ b/benchmark/scripts/SCIPY/dsyrk.py @@ -8,52 +8,51 @@ from numpy import zeros from numpy.random import randn from scipy.linalg import blas -def run_dsyrk(N,l): - A = randn(N,N).astype('float64') - C = zeros((N,N), dtype='float64') +def run_dsyrk(N, l): + A = randn(N, N).astype('float64') + C = zeros((N, N), dtype='float64') - start = time.time() - for i in range(0,l): - C[...] = blas.dsyrk(1.0,A) - end = time.time() - - timediff = (end -start) - mflops = ( N*N*N) *l / timediff - mflops *= 1e-6 + start = time.time() + for i in range(0, l): + C[...] = blas.dsyrk(1.0, A) + end = time.time() - size = "%dx%d" % (N,N) - print("%14s :\t%20f MFlops\t%20f sec" % (size,mflops,timediff)) + timediff = (end - start) + mflops = (N * N * N) * l / timediff + mflops *= 1e-6 + size = "%dx%d" % (N, N) + print("%14s :\t%20f MFlops\t%20f sec" % (size, mflops, timediff)) -if __name__ == "__main__": - N=128 - NMAX=2048 - NINC=128 - LOOPS=1 - - z=0 - for arg in sys.argv: - if z == 1: - N = int(arg) - elif z == 2: - NMAX = int(arg) - elif z == 3: - NINC = int(arg) - elif z == 4: - LOOPS = int(arg) - - z = z + 1 - - if 'OPENBLAS_LOOPS' in os.environ: - p = os.environ['OPENBLAS_LOOPS'] - if p: - LOOPS = int(p) - - print("From: %d To: %d Step=%d Loops=%d" % (N, NMAX, NINC, LOOPS)) - print("\tSIZE\t\t\tFlops\t\t\t\t\tTime") - - for i in range (N,NMAX+NINC,NINC): - run_dsyrk(i,LOOPS) +if __name__ == "__main__": + N = 128 + NMAX = 2048 + NINC = 128 + LOOPS = 1 + + z = 0 + for arg in sys.argv: + if z == 1: + N = int(arg) + elif z == 2: + NMAX = int(arg) + elif z == 3: + NINC = int(arg) + elif z == 4: + LOOPS = int(arg) + + z = z + 1 + + if 'OPENBLAS_LOOPS' in os.environ: + p = os.environ['OPENBLAS_LOOPS'] + if p: + LOOPS = int(p) + + print("From: %d To: %d Step=%d Loops=%d" % (N, NMAX, NINC, LOOPS)) + print("\tSIZE\t\t\tFlops\t\t\t\t\tTime") + + for i in range(N, NMAX + NINC, NINC): + run_dsyrk(i, LOOPS) From adfa0ab8789e1b4d7e0f7b1d1e0ba588969af4cc Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Tue, 19 Jan 2016 15:06:17 -0500 Subject: [PATCH 10/14] benchmark/scripts/SCIPY/ssyrk.py: Fix PEP8 issues. --- benchmark/scripts/SCIPY/ssyrk.py | 83 ++++++++++++++++---------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/benchmark/scripts/SCIPY/ssyrk.py b/benchmark/scripts/SCIPY/ssyrk.py index 034c0fd3a..7d156d41c 100755 --- a/benchmark/scripts/SCIPY/ssyrk.py +++ b/benchmark/scripts/SCIPY/ssyrk.py @@ -8,52 +8,51 @@ from numpy import zeros from numpy.random import randn from scipy.linalg import blas -def run_ssyrk(N,l): - A = randn(N,N).astype('float32') - C = zeros((N,N), dtype='float32') +def run_ssyrk(N, l): + A = randn(N, N).astype('float32') + C = zeros((N, N), dtype='float32') - start = time.time() - for i in range(0,l): - C[...] = blas.ssyrk(1.0,A) - end = time.time() - - timediff = (end -start) - mflops = ( N*N*N) *l / timediff - mflops *= 1e-6 + start = time.time() + for i in range(0, l): + C[...] = blas.ssyrk(1.0, A) + end = time.time() - size = "%dx%d" % (N,N) - print("%14s :\t%20f MFlops\t%20f sec" % (size,mflops,timediff)) + timediff = (end - start) + mflops = (N * N * N) * l / timediff + mflops *= 1e-6 + size = "%dx%d" % (N, N) + print("%14s :\t%20f MFlops\t%20f sec" % (size, mflops, timediff)) -if __name__ == "__main__": - N=128 - NMAX=2048 - NINC=128 - LOOPS=1 - - z=0 - for arg in sys.argv: - if z == 1: - N = int(arg) - elif z == 2: - NMAX = int(arg) - elif z == 3: - NINC = int(arg) - elif z == 4: - LOOPS = int(arg) - - z = z + 1 - - if 'OPENBLAS_LOOPS' in os.environ: - p = os.environ['OPENBLAS_LOOPS'] - if p: - LOOPS = int(p) - - print("From: %d To: %d Step=%d Loops=%d" % (N, NMAX, NINC, LOOPS)) - print("\tSIZE\t\t\tFlops\t\t\t\t\tTime") - - for i in range (N,NMAX+NINC,NINC): - run_ssyrk(i,LOOPS) +if __name__ == "__main__": + N = 128 + NMAX = 2048 + NINC = 128 + LOOPS = 1 + + z = 0 + for arg in sys.argv: + if z == 1: + N = int(arg) + elif z == 2: + NMAX = int(arg) + elif z == 3: + NINC = int(arg) + elif z == 4: + LOOPS = int(arg) + + z = z + 1 + + if 'OPENBLAS_LOOPS' in os.environ: + p = os.environ['OPENBLAS_LOOPS'] + if p: + LOOPS = int(p) + + print("From: %d To: %d Step=%d Loops=%d" % (N, NMAX, NINC, LOOPS)) + print("\tSIZE\t\t\tFlops\t\t\t\t\tTime") + + for i in range(N, NMAX + NINC, NINC): + run_ssyrk(i, LOOPS) From e85f8af519ca7d6c432807331a88a41d7b618f9b Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Tue, 19 Jan 2016 15:28:22 -0500 Subject: [PATCH 11/14] benchmark/scripts/SCIPY/ssyrk.py: Arrays should be Fortran order. --- benchmark/scripts/SCIPY/ssyrk.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/scripts/SCIPY/ssyrk.py b/benchmark/scripts/SCIPY/ssyrk.py index 7d156d41c..c13c62cdf 100755 --- a/benchmark/scripts/SCIPY/ssyrk.py +++ b/benchmark/scripts/SCIPY/ssyrk.py @@ -11,8 +11,8 @@ from scipy.linalg import blas def run_ssyrk(N, l): - A = randn(N, N).astype('float32') - C = zeros((N, N), dtype='float32') + A = randn(N, N).astype('float32', order='F') + C = zeros((N, N), dtype='float32', order='F') start = time.time() for i in range(0, l): From 07bba933ff1464cb3ce7c638ba453b1a1b2409ab Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Tue, 19 Jan 2016 15:29:43 -0500 Subject: [PATCH 12/14] benchmark/scripts/SCIPY/dsyrk.py: Arrays should be Fortran order. --- benchmark/scripts/SCIPY/dsyrk.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/scripts/SCIPY/dsyrk.py b/benchmark/scripts/SCIPY/dsyrk.py index 0ee83bcb7..4495fad16 100755 --- a/benchmark/scripts/SCIPY/dsyrk.py +++ b/benchmark/scripts/SCIPY/dsyrk.py @@ -11,8 +11,8 @@ from scipy.linalg import blas def run_dsyrk(N, l): - A = randn(N, N).astype('float64') - C = zeros((N, N), dtype='float64') + A = randn(N, N).astype('float64', order='F') + C = zeros((N, N), dtype='float64', order='F') start = time.time() for i in range(0, l): From b1b115ecd6d680f653da9d81d573a238f224128f Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Tue, 19 Jan 2016 15:31:37 -0500 Subject: [PATCH 13/14] benchmark/scripts/SCIPY/ssyrk.py: Overwrite will work on a Fortran array of the correct type. --- benchmark/scripts/SCIPY/ssyrk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/scripts/SCIPY/ssyrk.py b/benchmark/scripts/SCIPY/ssyrk.py index c13c62cdf..30aa6c92f 100755 --- a/benchmark/scripts/SCIPY/ssyrk.py +++ b/benchmark/scripts/SCIPY/ssyrk.py @@ -16,7 +16,7 @@ def run_ssyrk(N, l): start = time.time() for i in range(0, l): - C[...] = blas.ssyrk(1.0, A) + blas.ssyrk(1.0, A, c=C, overwrite_c=True) end = time.time() timediff = (end - start) From a48b247e9e17120f3efe83baa43823c9a3f25fe1 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Tue, 19 Jan 2016 15:32:28 -0500 Subject: [PATCH 14/14] benchmark/scripts/SCIPY/dsyrk.py: Overwrite will work on a Fortran array of the correct type. --- benchmark/scripts/SCIPY/dsyrk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/scripts/SCIPY/dsyrk.py b/benchmark/scripts/SCIPY/dsyrk.py index 4495fad16..c6db2fa56 100755 --- a/benchmark/scripts/SCIPY/dsyrk.py +++ b/benchmark/scripts/SCIPY/dsyrk.py @@ -16,7 +16,7 @@ def run_dsyrk(N, l): start = time.time() for i in range(0, l): - C[...] = blas.dsyrk(1.0, A) + blas.dsyrk(1.0, A, c=C, overwrite_c=True) end = time.time() timediff = (end - start)