From 8614057ea9d10a14d7986935150fc4fa78846cc6 Mon Sep 17 00:00:00 2001 From: Werner Saar Date: Mon, 8 Jun 2015 14:06:38 +0200 Subject: [PATCH] added benchmark scripts for numpy, octave and R --- benchmark/scripts/NUMPY/cgemm.py | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/NUMPY/cgemv.py | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/NUMPY/daxpy.py | 58 +++++++++++++++++++++++++++++++++++ benchmark/scripts/NUMPY/ddot.py | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/NUMPY/deig.py | 55 ++++++++++++++++++++++++++++++++++ benchmark/scripts/NUMPY/dgemm.py | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/NUMPY/dgemv.py | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/NUMPY/dgesv.py | 58 +++++++++++++++++++++++++++++++++++ benchmark/scripts/NUMPY/dsolve.py | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/NUMPY/sdot.py | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/NUMPY/sgemm.py | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/NUMPY/sgemv.py | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/NUMPY/zgemm.py | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/NUMPY/zgemv.py | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/OCTAVE/cgemm.m | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/OCTAVE/cgemv.m | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/OCTAVE/deig.m | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/OCTAVE/dgemm.m | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/OCTAVE/dgemv.m | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/OCTAVE/dsolve.m | 59 ++++++++++++++++++++++++++++++++++++ benchmark/scripts/OCTAVE/sgemm.m | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/OCTAVE/sgemv.m | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/OCTAVE/zgemm.m | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/OCTAVE/zgemv.m | 56 ++++++++++++++++++++++++++++++++++ benchmark/scripts/R/deig.R | 62 ++++++++++++++++++++++++++++++++++++++ benchmark/scripts/R/dgemm.R | 63 +++++++++++++++++++++++++++++++++++++++ benchmark/scripts/R/dsolve.R | 63 +++++++++++++++++++++++++++++++++++++++ 27 files changed, 1538 insertions(+) create mode 100755 benchmark/scripts/NUMPY/cgemm.py create mode 100755 benchmark/scripts/NUMPY/cgemv.py create mode 100755 benchmark/scripts/NUMPY/daxpy.py create mode 100755 benchmark/scripts/NUMPY/ddot.py create mode 100755 benchmark/scripts/NUMPY/deig.py create mode 100755 benchmark/scripts/NUMPY/dgemm.py create mode 100755 benchmark/scripts/NUMPY/dgemv.py create mode 100755 benchmark/scripts/NUMPY/dgesv.py create mode 100755 benchmark/scripts/NUMPY/dsolve.py create mode 100755 benchmark/scripts/NUMPY/sdot.py create mode 100755 benchmark/scripts/NUMPY/sgemm.py create mode 100755 benchmark/scripts/NUMPY/sgemv.py create mode 100755 benchmark/scripts/NUMPY/zgemm.py create mode 100755 benchmark/scripts/NUMPY/zgemv.py create mode 100755 benchmark/scripts/OCTAVE/cgemm.m create mode 100755 benchmark/scripts/OCTAVE/cgemv.m create mode 100755 benchmark/scripts/OCTAVE/deig.m create mode 100755 benchmark/scripts/OCTAVE/dgemm.m create mode 100755 benchmark/scripts/OCTAVE/dgemv.m create mode 100755 benchmark/scripts/OCTAVE/dsolve.m create mode 100755 benchmark/scripts/OCTAVE/sgemm.m create mode 100755 benchmark/scripts/OCTAVE/sgemv.m create mode 100755 benchmark/scripts/OCTAVE/zgemm.m create mode 100755 benchmark/scripts/OCTAVE/zgemv.m create mode 100755 benchmark/scripts/R/deig.R create mode 100755 benchmark/scripts/R/dgemm.R create mode 100755 benchmark/scripts/R/dsolve.R diff --git a/benchmark/scripts/NUMPY/cgemm.py b/benchmark/scripts/NUMPY/cgemm.py new file mode 100755 index 0000000..b35d3b8 --- /dev/null +++ b/benchmark/scripts/NUMPY/cgemm.py @@ -0,0 +1,56 @@ +#!/usr/bin/python + +import os +import sys +import time +import numpy +from numpy.random import randn + +def run_cgemm(N,l): + + A = randn(N,N).astype('float32') + randn(N,N).astype('float32') * 1j; + B = randn(N,N).astype('float32') + randn(N,N).astype('float32') * 1j; + + start = time.time(); + for i in range(0,l): + ref = numpy.dot(A,B) + end = time.time() + + timediff = (end -start) + mflops = ( 8*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_cgemm(i,LOOPS) + diff --git a/benchmark/scripts/NUMPY/cgemv.py b/benchmark/scripts/NUMPY/cgemv.py new file mode 100755 index 0000000..aa0ac9d --- /dev/null +++ b/benchmark/scripts/NUMPY/cgemv.py @@ -0,0 +1,56 @@ +#!/usr/bin/python + +import os +import sys +import time +import numpy +from numpy.random import randn + +def run_cgemv(N,l): + + A = randn(N,N).astype('float32') + randn(N,N).astype('float32') * 1j; + B = randn(N).astype('float32') + randn(N).astype('float32') * 1j; + + start = time.time(); + for i in range(0,l): + ref = numpy.dot(A,B) + end = time.time() + + timediff = (end -start) + mflops = ( 8*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_cgemv(i,LOOPS) + diff --git a/benchmark/scripts/NUMPY/daxpy.py b/benchmark/scripts/NUMPY/daxpy.py new file mode 100755 index 0000000..db2e0e6 --- /dev/null +++ b/benchmark/scripts/NUMPY/daxpy.py @@ -0,0 +1,58 @@ +#!/usr/bin/python + +import os +import sys +import time +import numpy +from numpy.random import randn +from scipy.linalg.blas import daxpy + + +def run_daxpy(N,l): + + x = randn(N).astype('float64') + y = randn(N).astype('float64') + + start = time.time(); + for i in range(0,l): + y = daxpy(x,y, a=2.0 ) + end = time.time() + + timediff = (end -start) + mflops = ( 2*N ) *l / timediff + mflops *= 1e-6 + + size = "%d" % (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_daxpy(i,LOOPS) + diff --git a/benchmark/scripts/NUMPY/ddot.py b/benchmark/scripts/NUMPY/ddot.py new file mode 100755 index 0000000..0f4ced3 --- /dev/null +++ b/benchmark/scripts/NUMPY/ddot.py @@ -0,0 +1,56 @@ +#!/usr/bin/python + +import os +import sys +import time +import numpy +from numpy.random import randn + +def run_ddot(N,l): + + A = randn(N).astype('float64') + B = randn(N).astype('float64') + + start = time.time(); + for i in range(0,l): + ref = numpy.dot(A,B) + end = time.time() + + timediff = (end -start) + mflops = ( 2*N ) *l / timediff + mflops *= 1e-6 + + size = "%d" % (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_ddot(i,LOOPS) + diff --git a/benchmark/scripts/NUMPY/deig.py b/benchmark/scripts/NUMPY/deig.py new file mode 100755 index 0000000..aac7abe --- /dev/null +++ b/benchmark/scripts/NUMPY/deig.py @@ -0,0 +1,55 @@ +#!/usr/bin/python + +import os +import sys +import time +import numpy +from numpy.random import randn + +def run_deig(N,l): + + A = randn(N,N).astype('float64') + + start = time.time(); + for i in range(0,l): + la,v = numpy.linalg.eig(A) + end = time.time() + + timediff = (end -start) + mflops = ( 26.33 *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_deig(i,LOOPS) + diff --git a/benchmark/scripts/NUMPY/dgemm.py b/benchmark/scripts/NUMPY/dgemm.py new file mode 100755 index 0000000..a312487 --- /dev/null +++ b/benchmark/scripts/NUMPY/dgemm.py @@ -0,0 +1,56 @@ +#!/usr/bin/python + +import os +import sys +import time +import numpy +from numpy.random import randn + +def run_dgemm(N,l): + + A = randn(N,N).astype('float64') + B = randn(N,N).astype('float64') + + start = time.time(); + for i in range(0,l): + ref = numpy.dot(A,B) + end = time.time() + + timediff = (end -start) + mflops = ( 2*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_dgemm(i,LOOPS) + diff --git a/benchmark/scripts/NUMPY/dgemv.py b/benchmark/scripts/NUMPY/dgemv.py new file mode 100755 index 0000000..bbc295e --- /dev/null +++ b/benchmark/scripts/NUMPY/dgemv.py @@ -0,0 +1,56 @@ +#!/usr/bin/python + +import os +import sys +import time +import numpy +from numpy.random import randn + +def run_dgemv(N,l): + + A = randn(N,N).astype('float64') + B = randn(N).astype('float64') + + start = time.time(); + for i in range(0,l): + ref = numpy.dot(A,B) + end = time.time() + + timediff = (end -start) + mflops = ( 2*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_dgemv(i,LOOPS) + diff --git a/benchmark/scripts/NUMPY/dgesv.py b/benchmark/scripts/NUMPY/dgesv.py new file mode 100755 index 0000000..8adabd1 --- /dev/null +++ b/benchmark/scripts/NUMPY/dgesv.py @@ -0,0 +1,58 @@ +#!/usr/bin/python + +import os +import sys +import time +import numpy +from numpy.random import randn +from scipy.linalg.lapack import dgesv + +def run_dgesv(N,l): + + a = randn(N,N).astype('float64') + b = randn(N,N).astype('float64') + + start = time.time(); + for i in range(0,l): + dgesv(a,b,1,1) + end = time.time() + + timediff = (end -start) + + mflops = ( 2.0/3.0 *N*N*N + 2.0*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_dgesv(i,LOOPS) + diff --git a/benchmark/scripts/NUMPY/dsolve.py b/benchmark/scripts/NUMPY/dsolve.py new file mode 100755 index 0000000..1b067a8 --- /dev/null +++ b/benchmark/scripts/NUMPY/dsolve.py @@ -0,0 +1,56 @@ +#!/usr/bin/python + +import os +import sys +import time +import numpy +from numpy.random import randn + +def run_dsolve(N,l): + + A = randn(N,N).astype('float64') + B = randn(N,N).astype('float64') + + start = time.time(); + for i in range(0,l): + ref = numpy.linalg.solve(A,B) + end = time.time() + + timediff = (end -start) + mflops = ( 2.0/3.0 *N*N*N + 2.0*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_dsolve(i,LOOPS) + diff --git a/benchmark/scripts/NUMPY/sdot.py b/benchmark/scripts/NUMPY/sdot.py new file mode 100755 index 0000000..4fe6b8c --- /dev/null +++ b/benchmark/scripts/NUMPY/sdot.py @@ -0,0 +1,56 @@ +#!/usr/bin/python + +import os +import sys +import time +import numpy +from numpy.random import randn + +def run_sdot(N,l): + + A = randn(N).astype('float32') + B = randn(N).astype('float32') + + start = time.time(); + for i in range(0,l): + ref = numpy.dot(A,B) + end = time.time() + + timediff = (end -start) + mflops = ( 2*N ) *l / timediff + mflops *= 1e-6 + + size = "%d" % (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_sdot(i,LOOPS) + diff --git a/benchmark/scripts/NUMPY/sgemm.py b/benchmark/scripts/NUMPY/sgemm.py new file mode 100755 index 0000000..1680ec2 --- /dev/null +++ b/benchmark/scripts/NUMPY/sgemm.py @@ -0,0 +1,56 @@ +#!/usr/bin/python + +import os +import sys +import time +import numpy +from numpy.random import randn + +def run_sgemm(N,l): + + A = randn(N,N).astype('float32') + B = randn(N,N).astype('float32') + + start = time.time(); + for i in range(0,l): + ref = numpy.dot(A,B) + end = time.time() + + timediff = (end -start) + mflops = ( 2*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_sgemm(i,LOOPS) + diff --git a/benchmark/scripts/NUMPY/sgemv.py b/benchmark/scripts/NUMPY/sgemv.py new file mode 100755 index 0000000..3fe6add --- /dev/null +++ b/benchmark/scripts/NUMPY/sgemv.py @@ -0,0 +1,56 @@ +#!/usr/bin/python + +import os +import sys +import time +import numpy +from numpy.random import randn + +def run_sgemv(N,l): + + A = randn(N,N).astype('float32') + B = randn(N).astype('float32') + + start = time.time(); + for i in range(0,l): + ref = numpy.dot(A,B) + end = time.time() + + timediff = (end -start) + mflops = ( 2*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_sgemv(i,LOOPS) + diff --git a/benchmark/scripts/NUMPY/zgemm.py b/benchmark/scripts/NUMPY/zgemm.py new file mode 100755 index 0000000..4556d4f --- /dev/null +++ b/benchmark/scripts/NUMPY/zgemm.py @@ -0,0 +1,56 @@ +#!/usr/bin/python + +import os +import sys +import time +import numpy +from numpy.random import randn + +def run_zgemm(N,l): + + A = randn(N,N).astype('float64') + randn(N,N).astype('float64') * 1j; + B = randn(N,N).astype('float64') + randn(N,N).astype('float64') * 1j; + + start = time.time(); + for i in range(0,l): + ref = numpy.dot(A,B) + end = time.time() + + timediff = (end -start) + mflops = ( 8*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_zgemm(i,LOOPS) + diff --git a/benchmark/scripts/NUMPY/zgemv.py b/benchmark/scripts/NUMPY/zgemv.py new file mode 100755 index 0000000..ea69a19 --- /dev/null +++ b/benchmark/scripts/NUMPY/zgemv.py @@ -0,0 +1,56 @@ +#!/usr/bin/python + +import os +import sys +import time +import numpy +from numpy.random import randn + +def run_zgemv(N,l): + + A = randn(N,N).astype('float64') + randn(N,N).astype('float64') * 1j; + B = randn(N).astype('float64') + randn(N).astype('float64') * 1j; + + start = time.time(); + for i in range(0,l): + ref = numpy.dot(A,B) + end = time.time() + + timediff = (end -start) + mflops = ( 8*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_zgemv(i,LOOPS) + diff --git a/benchmark/scripts/OCTAVE/cgemm.m b/benchmark/scripts/OCTAVE/cgemm.m new file mode 100755 index 0000000..0e79e71 --- /dev/null +++ b/benchmark/scripts/OCTAVE/cgemm.m @@ -0,0 +1,56 @@ +#!/usr/bin/octave --silent + +nfrom = 128 ; +nto = 2048; +nstep = 128; +loops = 1; + + +arg_list = argv(); +for i = 1:nargin + + switch(i) + case 1 + nfrom = str2num(arg_list{i}); + case 2 + nto = str2num(arg_list{i}); + case 3 + nstep = str2num(arg_list{i}); + case 4 + loops = str2num(arg_list{i}); + + endswitch + +endfor + +p = getenv("OPENBLAS_LOOPS"); +if p + loops = str2num(p); +endif + +printf("From %d To %d Step=%d Loops=%d\n",nfrom, nto, nstep, loops); +printf(" SIZE FLOPS TIME\n"); + +n = nfrom; +while n <= nto + + A = single(rand(n,n)) + single(rand(n,n)) * 1i; + B = single(rand(n,n)) + single(rand(n,n)) * 1i; + start = clock(); + + l=0; + while l < loops + + C = A * B; + l = l + 1; + + endwhile + + timeg = etime(clock(), start); + mflops = ( 4.0 * 2.0*n*n*n *loops ) / ( timeg * 1.0e6 ); + + st1 = sprintf("%dx%d : ", n,n); + printf("%20s %10.2f MFlops %10.6f sec\n", st1, mflops, timeg); + n = n + nstep; + +endwhile diff --git a/benchmark/scripts/OCTAVE/cgemv.m b/benchmark/scripts/OCTAVE/cgemv.m new file mode 100755 index 0000000..7237983 --- /dev/null +++ b/benchmark/scripts/OCTAVE/cgemv.m @@ -0,0 +1,56 @@ +#!/usr/bin/octave --silent + +nfrom = 128 ; +nto = 2048; +nstep = 128; +loops = 1; + + +arg_list = argv(); +for i = 1:nargin + + switch(i) + case 1 + nfrom = str2num(arg_list{i}); + case 2 + nto = str2num(arg_list{i}); + case 3 + nstep = str2num(arg_list{i}); + case 4 + loops = str2num(arg_list{i}); + + endswitch + +endfor + +p = getenv("OPENBLAS_LOOPS"); +if p + loops = str2num(p); +endif + +printf("From %d To %d Step=%d Loops=%d\n",nfrom, nto, nstep, loops); +printf(" SIZE FLOPS TIME\n"); + +n = nfrom; +while n <= nto + + A = single(rand(n,n)) + single(rand(n,n)) * 1i; + B = single(rand(n,1)) + single(rand(n,1)) * 1i; + start = clock(); + + l=0; + while l < loops + + C = A * B; + l = l + 1; + + endwhile + + timeg = etime(clock(), start); + mflops = ( 4.0 * 2.0*n*n *loops ) / ( timeg * 1.0e6 ); + + st1 = sprintf("%dx%d : ", n,n); + printf("%20s %10.2f MFlops %10.6f sec\n", st1, mflops, timeg); + n = n + nstep; + +endwhile diff --git a/benchmark/scripts/OCTAVE/deig.m b/benchmark/scripts/OCTAVE/deig.m new file mode 100755 index 0000000..15c85af --- /dev/null +++ b/benchmark/scripts/OCTAVE/deig.m @@ -0,0 +1,56 @@ +#!/usr/bin/octave --silent + +nfrom = 128 ; +nto = 2048; +nstep = 128; +loops = 1; + + +arg_list = argv(); +for i = 1:nargin + + switch(i) + case 1 + nfrom = str2num(arg_list{i}); + case 2 + nto = str2num(arg_list{i}); + case 3 + nstep = str2num(arg_list{i}); + case 4 + loops = str2num(arg_list{i}); + + endswitch + +endfor + +p = getenv("OPENBLAS_LOOPS"); +if p + loops = str2num(p); +endif + +printf("From %d To %d Step=%d Loops=%d\n",nfrom, nto, nstep, loops); +printf(" SIZE FLOPS TIME\n"); + +n = nfrom; +while n <= nto + + A = double(rand(n,n)); + start = clock(); + + l=0; + while l < loops + + [V,lambda] = eig(A); + l = l + 1; + + endwhile + + + timeg = etime(clock(), start); + mflops = ( 26.33 *n*n*n ) *loops / ( timeg * 1.0e6 ); + + st1 = sprintf("%dx%d : ", n,n); + printf("%20s %10.2f MFlops %10.6f sec\n", st1, mflops, timeg ); + n = n + nstep; + +endwhile diff --git a/benchmark/scripts/OCTAVE/dgemm.m b/benchmark/scripts/OCTAVE/dgemm.m new file mode 100755 index 0000000..da4f127 --- /dev/null +++ b/benchmark/scripts/OCTAVE/dgemm.m @@ -0,0 +1,56 @@ +#!/usr/bin/octave --silent + +nfrom = 128 ; +nto = 2048; +nstep = 128; +loops = 1; + + +arg_list = argv(); +for i = 1:nargin + + switch(i) + case 1 + nfrom = str2num(arg_list{i}); + case 2 + nto = str2num(arg_list{i}); + case 3 + nstep = str2num(arg_list{i}); + case 4 + loops = str2num(arg_list{i}); + + endswitch + +endfor + +p = getenv("OPENBLAS_LOOPS"); +if p + loops = str2num(p); +endif + +printf("From %d To %d Step=%d Loops=%d\n",nfrom, nto, nstep, loops); +printf(" SIZE FLOPS TIME\n"); + +n = nfrom; +while n <= nto + + A = double(rand(n,n)); + B = double(rand(n,n)); + start = clock(); + + l=0; + while l < loops + + C = A * B; + l = l + 1; + + endwhile + + timeg = etime(clock(), start); + mflops = ( 2.0*n*n*n *loops ) / ( timeg * 1.0e6 ); + + st1 = sprintf("%dx%d : ", n,n); + printf("%20s %10.2f MFlops %10.6f sec\n", st1, mflops, timeg); + n = n + nstep; + +endwhile diff --git a/benchmark/scripts/OCTAVE/dgemv.m b/benchmark/scripts/OCTAVE/dgemv.m new file mode 100755 index 0000000..139b141 --- /dev/null +++ b/benchmark/scripts/OCTAVE/dgemv.m @@ -0,0 +1,56 @@ +#!/usr/bin/octave --silent + +nfrom = 128 ; +nto = 2048; +nstep = 128; +loops = 1; + + +arg_list = argv(); +for i = 1:nargin + + switch(i) + case 1 + nfrom = str2num(arg_list{i}); + case 2 + nto = str2num(arg_list{i}); + case 3 + nstep = str2num(arg_list{i}); + case 4 + loops = str2num(arg_list{i}); + + endswitch + +endfor + +p = getenv("OPENBLAS_LOOPS"); +if p + loops = str2num(p); +endif + +printf("From %d To %d Step=%d Loops=%d\n",nfrom, nto, nstep, loops); +printf(" SIZE FLOPS TIME\n"); + +n = nfrom; +while n <= nto + + A = double(rand(n,n)); + B = double(rand(n,1)); + start = clock(); + + l=0; + while l < loops + + C = A * B; + l = l + 1; + + endwhile + + timeg = etime(clock(), start); + mflops = ( 2.0*n*n *loops ) / ( timeg * 1.0e6 ); + + st1 = sprintf("%dx%d : ", n,n); + printf("%20s %10.2f MFlops %10.6f sec\n", st1, mflops, timeg); + n = n + nstep; + +endwhile diff --git a/benchmark/scripts/OCTAVE/dsolve.m b/benchmark/scripts/OCTAVE/dsolve.m new file mode 100755 index 0000000..fff4b08 --- /dev/null +++ b/benchmark/scripts/OCTAVE/dsolve.m @@ -0,0 +1,59 @@ +#!/usr/bin/octave --silent + +nfrom = 128 ; +nto = 2048; +nstep = 128; +loops = 1; + + +arg_list = argv(); +for i = 1:nargin + + switch(i) + case 1 + nfrom = str2num(arg_list{i}); + case 2 + nto = str2num(arg_list{i}); + case 3 + nstep = str2num(arg_list{i}); + case 4 + loops = str2num(arg_list{i}); + + endswitch + +endfor + +p = getenv("OPENBLAS_LOOPS"); +if p + loops = str2num(p); +endif + +printf("From %d To %d Step=%d Loops=%d\n",nfrom, nto, nstep, loops); +printf(" SIZE FLOPS TIME\n"); + +n = nfrom; +while n <= nto + + A = double(rand(n,n)); + B = double(rand(n,n)); + start = clock(); + + l=0; + while l < loops + + x = linsolve(A,B); + #x = A / B; + l = l + 1; + + endwhile + + + timeg = etime(clock(), start); + #r = norm(A*x - B)/norm(B) + mflops = ( 2.0/3.0 *n*n*n + 2.0*n*n*n ) *loops / ( timeg * 1.0e6 ); + + st1 = sprintf("%dx%d : ", n,n); + printf("%20s %10.2f MFlops %10.6f sec\n", st1, mflops, timeg ); + n = n + nstep; + +endwhile diff --git a/benchmark/scripts/OCTAVE/sgemm.m b/benchmark/scripts/OCTAVE/sgemm.m new file mode 100755 index 0000000..b79548b --- /dev/null +++ b/benchmark/scripts/OCTAVE/sgemm.m @@ -0,0 +1,56 @@ +#!/usr/bin/octave --silent + +nfrom = 128 ; +nto = 2048; +nstep = 128; +loops = 1; + + +arg_list = argv(); +for i = 1:nargin + + switch(i) + case 1 + nfrom = str2num(arg_list{i}); + case 2 + nto = str2num(arg_list{i}); + case 3 + nstep = str2num(arg_list{i}); + case 4 + loops = str2num(arg_list{i}); + + endswitch + +endfor + +p = getenv("OPENBLAS_LOOPS"); +if p + loops = str2num(p); +endif + +printf("From %d To %d Step=%d Loops=%d\n",nfrom, nto, nstep, loops); +printf(" SIZE FLOPS TIME\n"); + +n = nfrom; +while n <= nto + + A = single(rand(n,n)); + B = single(rand(n,n)); + start = clock(); + + l=0; + while l < loops + + C = A * B; + l = l + 1; + + endwhile + + timeg = etime(clock(), start); + mflops = ( 2.0*n*n*n *loops ) / ( timeg * 1.0e6 ); + + st1 = sprintf("%dx%d : ", n,n); + printf("%20s %10.2f MFlops %10.6f sec\n", st1, mflops, timeg); + n = n + nstep; + +endwhile diff --git a/benchmark/scripts/OCTAVE/sgemv.m b/benchmark/scripts/OCTAVE/sgemv.m new file mode 100755 index 0000000..1315288 --- /dev/null +++ b/benchmark/scripts/OCTAVE/sgemv.m @@ -0,0 +1,56 @@ +#!/usr/bin/octave --silent + +nfrom = 128 ; +nto = 2048; +nstep = 128; +loops = 1; + + +arg_list = argv(); +for i = 1:nargin + + switch(i) + case 1 + nfrom = str2num(arg_list{i}); + case 2 + nto = str2num(arg_list{i}); + case 3 + nstep = str2num(arg_list{i}); + case 4 + loops = str2num(arg_list{i}); + + endswitch + +endfor + +p = getenv("OPENBLAS_LOOPS"); +if p + loops = str2num(p); +endif + +printf("From %d To %d Step=%d Loops=%d\n",nfrom, nto, nstep, loops); +printf(" SIZE FLOPS TIME\n"); + +n = nfrom; +while n <= nto + + A = single(rand(n,n)); + B = single(rand(n,1)); + start = clock(); + + l=0; + while l < loops + + C = A * B; + l = l + 1; + + endwhile + + timeg = etime(clock(), start); + mflops = ( 2.0*n*n *loops ) / ( timeg * 1.0e6 ); + + st1 = sprintf("%dx%d : ", n,n); + printf("%20s %10.2f MFlops %10.6f sec\n", st1, mflops, timeg); + n = n + nstep; + +endwhile diff --git a/benchmark/scripts/OCTAVE/zgemm.m b/benchmark/scripts/OCTAVE/zgemm.m new file mode 100755 index 0000000..a748437 --- /dev/null +++ b/benchmark/scripts/OCTAVE/zgemm.m @@ -0,0 +1,56 @@ +#!/usr/bin/octave --silent + +nfrom = 128 ; +nto = 2048; +nstep = 128; +loops = 1; + + +arg_list = argv(); +for i = 1:nargin + + switch(i) + case 1 + nfrom = str2num(arg_list{i}); + case 2 + nto = str2num(arg_list{i}); + case 3 + nstep = str2num(arg_list{i}); + case 4 + loops = str2num(arg_list{i}); + + endswitch + +endfor + +p = getenv("OPENBLAS_LOOPS"); +if p + loops = str2num(p); +endif + +printf("From %d To %d Step=%d Loops=%d\n",nfrom, nto, nstep, loops); +printf(" SIZE FLOPS TIME\n"); + +n = nfrom; +while n <= nto + + A = double(rand(n,n)) + double(rand(n,n)) * 1i; + B = double(rand(n,n)) + double(rand(n,n)) * 1i; + start = clock(); + + l=0; + while l < loops + + C = A * B; + l = l + 1; + + endwhile + + timeg = etime(clock(), start); + mflops = ( 4.0 * 2.0*n*n*n *loops ) / ( timeg * 1.0e6 ); + + st1 = sprintf("%dx%d : ", n,n); + printf("%20s %10.2f MFlops %10.6f sec\n", st1, mflops, timeg); + n = n + nstep; + +endwhile diff --git a/benchmark/scripts/OCTAVE/zgemv.m b/benchmark/scripts/OCTAVE/zgemv.m new file mode 100755 index 0000000..10a0089 --- /dev/null +++ b/benchmark/scripts/OCTAVE/zgemv.m @@ -0,0 +1,56 @@ +#!/usr/bin/octave --silent + +nfrom = 128 ; +nto = 2048; +nstep = 128; +loops = 1; + + +arg_list = argv(); +for i = 1:nargin + + switch(i) + case 1 + nfrom = str2num(arg_list{i}); + case 2 + nto = str2num(arg_list{i}); + case 3 + nstep = str2num(arg_list{i}); + case 4 + loops = str2num(arg_list{i}); + + endswitch + +endfor + +p = getenv("OPENBLAS_LOOPS"); +if p + loops = str2num(p); +endif + +printf("From %d To %d Step=%d Loops=%d\n",nfrom, nto, nstep, loops); +printf(" SIZE FLOPS TIME\n"); + +n = nfrom; +while n <= nto + + A = double(rand(n,n)) + double(rand(n,n)) * 1i; + B = double(rand(n,1)) + double(rand(n,1)) * 1i; + start = clock(); + + l=0; + while l < loops + + C = A * B; + l = l + 1; + + endwhile + + timeg = etime(clock(), start); + mflops = ( 4.0 * 2.0*n*n *loops ) / ( timeg * 1.0e6 ); + + st1 = sprintf("%dx%d : ", n,n); + printf("%20s %10.2f MFlops %10.6f sec\n", st1, mflops, timeg); + n = n + nstep; + +endwhile diff --git a/benchmark/scripts/R/deig.R b/benchmark/scripts/R/deig.R new file mode 100755 index 0000000..3521c7c --- /dev/null +++ b/benchmark/scripts/R/deig.R @@ -0,0 +1,62 @@ +#!/usr/bin/Rscript + +argv <- commandArgs(trailingOnly = TRUE) + +nfrom = 128 +nto = 2048 +nstep = 128 +loops = 1 + +if ( length(argv) > 0 ) { + + for ( z in 1:length(argv) ) { + + if ( z == 1 ) { + nfrom <- as.numeric(argv[z]) + } else if ( z==2 ) { + nto <- as.numeric(argv[z]) + } else if ( z==3 ) { + nstep <- as.numeric(argv[z]) + } else if ( z==4 ) { + loops <- as.numeric(argv[z]) + } + } + +} + +p=Sys.getenv("OPENBLAS_LOOPS") +if ( p != "" ) { + loops <- as.numeric(p) +} + + +cat(sprintf("From %.0f To %.0f Step=%.0f Loops=%.0f\n",nfrom, nto, nstep, loops)) +cat(sprintf(" SIZE Flops Time\n")) + +n = nfrom +while ( n <= nto ) { + + A <- matrix(runif(n*n), ncol = n, nrow = n, byrow = TRUE) + + l = 1 + + start <- proc.time()[3] + + while ( l <= loops ) { + + ev <- eigen(A) + l = l + 1 + } + + end <- proc.time()[3] + timeg = end - start + mflops = (26.66 *n*n*n ) * loops / ( timeg * 1.0e6 ) + + st = sprintf("%.0fx%.0f :",n , n) + cat(sprintf("%20s %10.2f MFlops %10.6f sec\n", st, mflops, timeg)) + + n = n + nstep + +} + + diff --git a/benchmark/scripts/R/dgemm.R b/benchmark/scripts/R/dgemm.R new file mode 100755 index 0000000..f1c09c3 --- /dev/null +++ b/benchmark/scripts/R/dgemm.R @@ -0,0 +1,63 @@ +#!/usr/bin/Rscript + +argv <- commandArgs(trailingOnly = TRUE) + +nfrom = 128 +nto = 2048 +nstep = 128 +loops = 1 + +if ( length(argv) > 0 ) { + + for ( z in 1:length(argv) ) { + + if ( z == 1 ) { + nfrom <- as.numeric(argv[z]) + } else if ( z==2 ) { + nto <- as.numeric(argv[z]) + } else if ( z==3 ) { + nstep <- as.numeric(argv[z]) + } else if ( z==4 ) { + loops <- as.numeric(argv[z]) + } + } + +} + +p=Sys.getenv("OPENBLAS_LOOPS") +if ( p != "" ) { + loops <- as.numeric(p) +} + + +cat(sprintf("From %.0f To %.0f Step=%.0f Loops=%.0f\n",nfrom, nto, nstep, loops)) +cat(sprintf(" SIZE Flops Time\n")) + +n = nfrom +while ( n <= nto ) { + + A <- matrix(runif(n*n), ncol = n, nrow = n, byrow = TRUE) + B <- matrix(runif(n*n), ncol = n, nrow = n, byrow = TRUE) + + l = 1 + + start <- proc.time()[3] + + while ( l <= loops ) { + + C <- A %*% B + l = l + 1 + } + + end <- proc.time()[3] + timeg = end - start + mflops = ( 2.0 *n*n*n ) * loops / ( timeg * 1.0e6 ) + + st = sprintf("%.0fx%.0f :",n , n) + cat(sprintf("%20s %10.2f MFlops %10.6f sec\n", st, mflops, timeg)) + + n = n + nstep + +} + + diff --git a/benchmark/scripts/R/dsolve.R b/benchmark/scripts/R/dsolve.R new file mode 100755 index 0000000..6c6b77f --- /dev/null +++ b/benchmark/scripts/R/dsolve.R @@ -0,0 +1,63 @@ +#!/usr/bin/Rscript + +argv <- commandArgs(trailingOnly = TRUE) + +nfrom = 128 +nto = 2048 +nstep = 128 +loops = 1 + +if ( length(argv) > 0 ) { + + for ( z in 1:length(argv) ) { + + if ( z == 1 ) { + nfrom <- as.numeric(argv[z]) + } else if ( z==2 ) { + nto <- as.numeric(argv[z]) + } else if ( z==3 ) { + nstep <- as.numeric(argv[z]) + } else if ( z==4 ) { + loops <- as.numeric(argv[z]) + } + } + +} + +p=Sys.getenv("OPENBLAS_LOOPS") +if ( p != "" ) { + loops <- as.numeric(p) +} + + +cat(sprintf("From %.0f To %.0f Step=%.0f Loops=%.0f\n",nfrom, nto, nstep, loops)) +cat(sprintf(" SIZE Flops Time\n")) + +n = nfrom +while ( n <= nto ) { + + A <- matrix(runif(n*n), ncol = n, nrow = n, byrow = TRUE) + B <- matrix(runif(n*n), ncol = n, nrow = n, byrow = TRUE) + + l = 1 + + start <- proc.time()[3] + + while ( l <= loops ) { + + solve(A,B) + l = l + 1 + } + + end <- proc.time()[3] + timeg = end - start + mflops = (2.0/3.0 *n*n*n + 2.0 *n*n*n ) * loops / ( timeg * 1.0e6 ) + + st = sprintf("%.0fx%.0f :",n , n) + cat(sprintf("%20s %10.2f MFlops %10.6f sec\n", st, mflops, timeg)) + + n = n + nstep + +} + + -- 2.7.4