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.

deig.py 925 B

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