/[escript]/trunk/escript/test/python/benchmark.py
ViewVC logotype

Contents of /trunk/escript/test/python/benchmark.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 155 - (show annotations)
Wed Nov 9 02:02:19 2005 UTC (14 years, 1 month ago) by jgs
File MIME type: text/x-python
File size: 1594 byte(s)
move all directories from trunk/esys2 into trunk and remove esys2

1 # $Id$
2
3 from os import getenv
4 from time import time
5 from esys.escript import *
6 from esys.bruce import Brick
7 from numarray import ones
8
9 cache_size=3 # Mbytes
10 nterm_max=256
11 ne=20000
12 np=int(getenv("OMP_NUM_THREADS"))
13 print "np =",np
14
15 print "nthreads, num. terms, num. comp, volume[Mbytes], cache usage, Gflops/thread"
16
17 for var in [True,False]:
18
19 n=int(ne**(1./3.))
20 dom=Brick(n,n)
21 l=(n+1)**3
22 sx=dom.getX()[0]+dom.getX()[1]+dom.getX()[2]
23
24 for ncomp in [1, 2, 4, 8, 16, 32, 128, 256]:
25
26 fac=ones([ncomp])
27 dataset=[]
28 for i in range(nterm_max+1):
29 dataset.append(sx*fac*(i+1))
30
31 for nterm in [2, 4, 8, 16, 32, 64, 128, 256]:
32
33 total_length=(ncomp*float(l)*(nterm+1)*8.)*1.e-6
34
35 if var:
36
37 opcount=(nterm-1)*float(l)*ncomp*1.e-9
38 a=sx*0.*fac
39 rv=DataVariable(a)
40 dv=[]
41 for d in dataset[:nterm]:
42 dv.append(DataVariable(d))
43 t=time()
44 for i in range(1,nterm):
45 dv[i].sum(dv[i-1])
46 r=dv[nterm-1].evaluate()
47 t=time()-t
48
49 else:
50
51 opcount=nterm*float(l)*ncomp*1.e-9
52 r=sx*0.*fac
53 t=time()
54 for d in dataset[:nterm]:
55 r+=d
56 t=time()-t
57
58 err=Lsup(sx*fac*(nterm+1.)*nterm/2.-r)
59 if err>1.e-8:
60 raise SystemError,"result wrong (error %e)!"%err
61 print "%d,%d,%d,%f,%f,%f"%(np,nterm,ncomp,total_length,total_length/(np*cache_size),opcount/t/np)

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26