You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ssyrk.py 1.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env python
  2. import os
  3. import sys
  4. import time
  5. import numpy
  6. from numpy import zeros
  7. from numpy.random import randn
  8. from scipy.linalg import blas
  9. def run_ssyrk(N,l):
  10. A = randn(N,N).astype('float32')
  11. C = zeros((N,N), dtype='float32')
  12. start = time.time()
  13. for i in range(0,l):
  14. C[...] = blas.ssyrk(1.0,A)
  15. end = time.time()
  16. timediff = (end -start)
  17. mflops = ( N*N*N) *l / timediff
  18. mflops *= 1e-6
  19. size = "%dx%d" % (N,N)
  20. print("%14s :\t%20f MFlops\t%20f sec" % (size,mflops,timediff))
  21. if __name__ == "__main__":
  22. N=128
  23. NMAX=2048
  24. NINC=128
  25. LOOPS=1
  26. z=0
  27. for arg in sys.argv:
  28. if z == 1:
  29. N = int(arg)
  30. elif z == 2:
  31. NMAX = int(arg)
  32. elif z == 3:
  33. NINC = int(arg)
  34. elif z == 4:
  35. LOOPS = int(arg)
  36. z = z + 1
  37. if 'OPENBLAS_LOOPS' in os.environ:
  38. p = os.environ['OPENBLAS_LOOPS']
  39. if p:
  40. LOOPS = int(p)
  41. print("From: %d To: %d Step=%d Loops=%d" % (N, NMAX, NINC, LOOPS))
  42. print("\tSIZE\t\t\tFlops\t\t\t\t\tTime")
  43. for i in range (N,NMAX+NINC,NINC):
  44. run_ssyrk(i,LOOPS)