1*6101Speter\"	@(#)equations.me	1.1 03/11/82
2*6101Speter.EQ
3*6101Speterdelim ##
4*6101Speter.EN
5*6101Speter.sh 1 "Notation"
6*6101Speter.pp
7*6101SpeterGiven a program, #P#, and an ordered list of instructions, #I#,
8*6101Spetercomposing #P#,
9*6101Speter.EQ
10*6101SpeterP ~ = ~ {I sub 1} ^ {I sub 2} ^ ... ^ {I sub m}
11*6101Speter.EN
12*6101Speterdefine the address of an instruction to be its index in the program.
13*6101SpeterGiven a namelist, #N#,  that associates names with distinguished
14*6101Speteraddresses, called entry points, sorted by increasing entry point values,
15*6101Speter.EQ
16*6101SpeterN ~ = ~ "{" ( n sub 1 , ~ e sub 1 ) ,..., ( n sub r , ~ e sub r ) "}"
17*6101Speter.EN
18*6101Speter#N# partitions the addresses of #P# into ranges, called routines,
19*6101Spetersuch that
20*6101Speter.EQ
21*6101SpeterR sub 0 ~ mark = ~ "{" 1 ,..., {e sub 1} - 1 "}"
22*6101Speter.EN C
23*6101Speter.EQ
24*6101SpeterR sub i ~ lineup = ~ "{" e sub i ,..., {e sub i} - 1 "}" ~
25*6101Speterfor ~ 1 <= i < r
26*6101Speter.EN C
27*6101Speter.EQ
28*6101SpeterR sub r ~ lineup = ~ "{" e sub r ,..., m "}"
29*6101Speter.EN
30*6101Speter.(q
31*6101Speter<<<watch out.  we have only one entry point per routine.  not
32*6101Spetereverybody does.>>>
33*6101Speter.)q
34*6101SpeterA profilable program consists of the instructions and a namelist.
35*6101Speter.pp
36*6101SpeterGiven a histogram of address samples, #H#, ordered such that the
37*6101Speter#i sup th# sample is the count for the #i sup th#
38*6101Speterinstruction, define the #selftime#, #S#, of each of the #r# routines
39*6101Speteras
40*6101Speter.EQ
41*6101SpeterS sub i ~ = ~ sum from {j ~ \(mo ~ {R sub i}} {H sub j}
42*6101Speter.EN
43*6101Speter.pp
44*6101SpeterGiven a set of arcs, #A#, gathered during the profiled execution of
45*6101Speterthe program, where #A# consists of ordered triples,
46*6101Speter#(tail, ~ head, ~ count)#, giving the address of the
47*6101Spetertail and head of the arc, and a count of the number of times the
48*6101Speterexecution of the program traversed this arc from instruction
49*6101Speter#I sub tail# to instruction #I sub head#,
50*6101Speterthe number of calls to the #i sup th# routine can be calculated
51*6101Speteras
52*6101Speter.EQ
53*6101SpeterC sub i ~ = ~ sum from { ( tail , ~ head , ~ count ) ~ \(mo ~ A }
54*6101Speter                       "{" count | head ~ \(mo ~ R sub i "}"
55*6101Speter.EN
56*6101Speterand the number of calls to the #i sup th# routine from the
57*6101Speter#j sup th# routine as
58*6101Speter.EQ
59*6101SpeterC sub i sup j ~ = ~ sum from { ( tail , ~ head , ~ count ) ~ \(mo ~ A }
60*6101Speter                                  "{" count | tail ~ \(mo ~ R sub i ,
61*6101Speter                                  head ~ \(mo ~ R sub j "}"
62*6101Speter.EN
63*6101Speter.pp
64*6101SpeterIf there is an arc with #tail ~ \(mo ~ R sub i# and
65*6101Speter#head ~ \(mo ~ R sub j#, then #R sub j# is a child of
66*6101Speter#R sub i#, denoted #R sub i ~ Child ~ R sub j#.
67*6101Speter#R sub i# has as a child #R sub j#.
68*6101SpeterThe transitive closure of the #Child# relation is called the
69*6101Speter#Descendants# relation.
70*6101SpeterThe inverse of the #Child# relation is the #Parent# relation.
71*6101SpeterFor example, if #R sub i ~ Child ~ R sub j# then
72*6101Speter#R sub j ~ Parent ~ R sub i#.
73*6101SpeterThe transitive closure of the #Parent# relation is called the
74*6101Speter#Ancestor# relation.
75*6101Speter.pp
76*6101SpeterWe are interested in computing the following recurrence, which
77*6101Spetergives the time for a routine based on its selftime and an
78*6101Speterappropriate fraction of the time of its descendants.
79*6101Speter.EQ
80*6101SpeterT sub i ~ = ~ S sub i + sum from {i ~ Child ~ j}
81*6101Speter                        {T sub j \(mu {C sub i sup j} over {C sub i}}
82*6101Speter.EN
83*6101SpeterThis recurrence can be trivially solved for leaves of the call
84*6101Spetergraph, e.g. those with no children.
85*6101SpeterIn the general case, however, it is necessary to order the nodes
86*6101Speterof the graph so that the times for all children of a routine
87*6101Speterare known before computing the time for the routine itself.
88*6101SpeterSuch an order could be imposed by a depth-first numbering of the
89*6101Speterroutines with a single traversal of each of the arcs in #A#.
90*6101Speter<<<this falls off here because i don't know if we want to continue
91*6101Speterwith this, and it's hard to type.>>>
92