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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 122 - (show annotations)
Thu Jun 9 05:38:05 2005 UTC (14 years, 6 months ago) by jgs
File MIME type: text/x-python
File size: 1598 byte(s)
Merge of development branch back to main trunk on 2005-06-09

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