/[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 613 - (show annotations)
Wed Mar 22 01:12:32 2006 UTC (13 years, 10 months ago) by elspeth
File MIME type: text/x-python
File size: 1882 byte(s)
More copyright information inserted.

1 # $Id$
2
3 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
4 http://www.access.edu.au
5 Primary Business: Queensland, Australia"""
6 __licence__="""Licensed under the Open Software License version 3.0
7 http://www.opensource.org/licences/osl-3.0.php"""
8 from os import getenv
9 from time import time
10 from esys.escript import *
11 from esys.bruce import Brick
12 from numarray import ones
13
14 cache_size=3 # Mbytes
15 nterm_max=256
16 ne=20000
17 np=int(getenv("OMP_NUM_THREADS"))
18 print "np =",np
19
20 print "nthreads, num. terms, num. comp, volume[Mbytes], cache usage, Gflops/thread"
21
22 for var in [True,False]:
23
24 n=int(ne**(1./3.))
25 dom=Brick(n,n)
26 l=(n+1)**3
27 sx=dom.getX()[0]+dom.getX()[1]+dom.getX()[2]
28
29 for ncomp in [1, 2, 4, 8, 16, 32, 128, 256]:
30
31 fac=ones([ncomp])
32 dataset=[]
33 for i in range(nterm_max+1):
34 dataset.append(sx*fac*(i+1))
35
36 for nterm in [2, 4, 8, 16, 32, 64, 128, 256]:
37
38 total_length=(ncomp*float(l)*(nterm+1)*8.)*1.e-6
39
40 if var:
41
42 opcount=(nterm-1)*float(l)*ncomp*1.e-9
43 a=sx*0.*fac
44 rv=DataVariable(a)
45 dv=[]
46 for d in dataset[:nterm]:
47 dv.append(DataVariable(d))
48 t=time()
49 for i in range(1,nterm):
50 dv[i].sum(dv[i-1])
51 r=dv[nterm-1].evaluate()
52 t=time()-t
53
54 else:
55
56 opcount=nterm*float(l)*ncomp*1.e-9
57 r=sx*0.*fac
58 t=time()
59 for d in dataset[:nterm]:
60 r+=d
61 t=time()-t
62
63 err=Lsup(sx*fac*(nterm+1.)*nterm/2.-r)
64 if err>1.e-8:
65 raise SystemError,"result wrong (error %e)!"%err
66 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