Page MenuHomec4science

gcpu
No OneTemporary

File Metadata

Created
Wed, May 22, 05:24
#!/usr/bin/env python
'''
Extract and plot info contained in cpu.txt files
Yves Revaz
jeu avr 6 15:58:19 CEST 2006
'''
import sys
from numarray import *
import SM
from Nbody import *
from Gtools import io
try:
from optparse import OptionParser
except ImportError:
from optik import OptionParser
def parse_options():
usage = "usage: %prog [options] file"
parser = OptionParser(usage=usage)
parser.add_option("--minx",
action="store",
dest="mnx",
default=None,
help="min value in x")
parser.add_option("--maxx",
action="store",
dest="mxx",
default=None,
help="max value in x")
parser.add_option("--miny",
action="store",
dest="mny",
default=None,
help="min value in y")
parser.add_option("--maxy",
action="store",
dest="mxy",
default=None,
help="max value in y")
parser.add_option("-p",
action="store",
dest="ps",
type="string",
default = None,
help="postscript filename",
metavar=" FILE")
parser.add_option("--mode",
action="store",
dest="mode",
type="string",
default = 'total',
help="mode",
metavar=" MODE")
(options, args) = parser.parse_args()
if len(args) == 0:
print "you must specify a filename"
sys.exit(0)
files = args
return files,options
#############################
# graph
#############################
# get options
files,options = parse_options()
ps = options.ps
mnx = options.mnx
mxx = options.mxx
mny = options.mny
mxy = options.mxy
mode = options.mode
# open sm
if ps==None:
g = SM.plot("x11 -bg white -fg black ")
else:
g = SM.plot("postencap %s"%ps)
# some init
g.palette('bgyrw')
g.expand(0.999)
# set colors
#colors = {}
#i = 0
#for file in files:
# if col!=None:
# colors[file]=col[i]
# else:
# colors[file] = i*255/len(files)
#
# i = i + 1
# read files
for file in files:
Step,Time,CPUs,CPU_Total,CPU_Gravity,CPU_Hydro,CPU_Domain,CPU_Potential,CPU_Predict,CPU_TimeLine,CPU_Snapshot,CPU_TreeWalk,CPU_TreeConstruction,CPU_CommSum,CPU_Imbalance,CPU_HydCompWalk,CPU_HydCommSumm,CPU_HydImbalance,CPU_EnsureNgb,CPU_PM,CPU_Peano=io.read_cpu(file)
if file == files[0]:
# set limits
if mnx==None:
mnx = min(Time)
if mxx==None:
mxx = max(Time)
if mny==None:
mny = min(CPU_Total)
if mxy==None:
mxy = max(CPU_Total)
g.limits(mnx,mxx,0,1)
g.box()
# draw line
#g.ctype(colors[file])
##############
# global bilan
##############
if mode == 'total':
CPU_Gravity = CPU_Gravity / CPU_Total
CPU_Hydro = CPU_Hydro / CPU_Total
CPU_Domain = CPU_Domain / CPU_Total
CPU_Potential = CPU_Potential / CPU_Total
CPU_Predict = CPU_Predict / CPU_Total
CPU_TimeLine = CPU_TimeLine / CPU_Total
CPU_Snapshot = CPU_Snapshot / CPU_Total
Gravity = CPU_Gravity
Hydro = Gravity + CPU_Hydro
Domain = Hydro + CPU_Domain
Potential = Domain + CPU_Potential
Predict = Potential + CPU_Predict
TimeLine = Predict + CPU_TimeLine
Snapshot = TimeLine + CPU_Snapshot
g.connect(Time,Gravity)
g.connect(Time,Hydro)
g.connect(Time,Domain)
g.connect(Time,Potential)
g.connect(Time,Predict)
g.connect(Time,TimeLine)
g.connect(Time,Snapshot)
##############
# gravity bilan
##############
elif mode == 'gravity':
CPU_TreeWalk = CPU_TreeWalk / CPU_Gravity
CPU_TreeConstruction = CPU_TreeConstruction / CPU_Gravity
CPU_CommSum = CPU_CommSum / CPU_Gravity
CPU_Imbalance = CPU_Imbalance / CPU_Gravity
TreeWalk = CPU_TreeWalk
TreeConstruction = TreeWalk + CPU_TreeConstruction
CommSum = TreeConstruction + CPU_CommSum
Imbalance = CommSum + CPU_Imbalance
g.connect(Time,TreeWalk)
g.connect(Time,TreeConstruction)
g.connect(Time,CommSum)
g.connect(Time,Imbalance)
##############
# gas bilan
##############
elif mode == 'hydro':
print "warning, CPU_HydCompWalk,CPU_HydCommSumm,CPU_HydImbalance, CPU_EnsureNgb "
print "are means of total time"
CPU_HydCompWalk = CPU_HydCompWalk / CPU_Hydro
CPU_HydCommSumm = CPU_HydCommSumm / CPU_Hydro
CPU_HydImbalance = CPU_HydImbalance / CPU_Hydro
CPU_EnsureNgb = CPU_EnsureNgb / CPU_Hydro
HydCompWalk = CPU_HydCompWalk
HydCommSumm = HydCompWalk + CPU_HydCommSumm
HydImbalance = HydCommSumm + CPU_HydImbalance
EnsureNgb = HydImbalance + CPU_EnsureNgb
g.connect(Time,HydCompWalk)
g.connect(Time,HydCommSumm)
g.connect(Time,HydImbalance)
g.connect(Time,EnsureNgb)
# labels
g.ctype(0)
g.xlabel('T')
g.ylabel('fraction of time spend')
# -- end ---
if ps==None:
g.show()
else:
g.write()
g.clean()

Event Timeline