File: dsolve.py

package info (click to toggle)
openblas 0.2.19-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 44,272 kB
  • ctags: 76,509
  • sloc: asm: 1,086,998; ansic: 186,055; fortran: 74,181; makefile: 11,187; perl: 3,428; python: 661; sh: 81
file content (56 lines) | stat: -rwxr-xr-x 980 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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)