9 print("Usage : %s datafile links latency bandwidth [size...]" % sys.argv[0])
10 print("where : links is the number of links between nodes")
11 print(" latency is the nominal latency given in the platform file")
12 print(" bandwidth is the nominal bandwidth given in the platform file")
13 print(" size are segments limites")
16 ##-----------------------------------------
17 ## avg : return average of a list of values
18 ## param l list of values
19 ##-----------------------------------------
26 ##-------------------------------------------------
28 ## param X first data vector (..x_i..)
29 ## param Y second data vector (..x_i..)
30 ## = 1/n \Sum_{i=1}^n (x_i - avg(x)) * (y_i - avg(y))
31 ##--------------------------------------------------
33 assert len(X) == len(Y)
34 n = len(X) # n=len(X)=len(Y)
39 S_XY += (X[i] - avg_X) * (Y[i] - avg_Y)
42 ##----------------------------------
43 ## variance : variance
44 ## param X data vector ( ..x_i.. )
45 ## (S_X)^2 = (Sum ( x_i - avg(x) )^2 ) / n
46 ##----------------------------------
52 S_X2 += (X[i] - avg_X) ** 2
55 def calibrate (links, latency, bandwidth, sizes, timings):
56 assert len(sizes) == len(timings)
59 S_XY = cov(sizes, timings)
60 S_X2 = variance(sizes)
62 b = avg(timings) - a * avg(sizes)
63 return (b * 1e-6) / (latency * links), 1e6 / (a * bandwidth)
65 ##-----------------------------------------------------------------------------------------------
67 ##-----------------------------------------------------------------------------------------------
68 links = int(sys.argv[2])
69 latency = float(sys.argv[3])
70 bandwidth = float(sys.argv[4])
71 skampidat = open(sys.argv[1], "r")
75 for line in skampidat:
77 if line[0] != '#' and len(l) >= 3: # is it a comment ?
80 #count= 8388608 8388608 144916.1 7.6 32 144916.1 143262.0
81 #("%s %d %d %f %f %d %f %f\n" % (countlbl, count, countn, time, stddev, iter, mini, maxi)
82 timings.append(float(l[3]) / links)
83 sizes.append(int(l[1]))
85 ## adds message sizes of interest: if values are specified starting from the 6th command line arg
86 ## and these values are found as message sizes in te log file, add it to the limits list.
87 ## Each of these value si considered a potential inflexion point between two segments.
89 ## If no value specified, a single segment is considered from 1st to last message size logged.
92 for i in xrange(5, len(sys.argv)):
93 limits += [idx for idx in xrange(len(sizes)) if sizes[idx] == int(sys.argv[i])]
94 limits.append(len(sizes) - 1)
98 correc = calibrate(links, latency, bandwidth, sizes[low:lim + 1], timings[low:lim + 1])
100 print("Segment [%d:%d] -- Latency factor=%g -- Bandwidth factor=%g" % (sizes[low], sizes[lim], correc[0], correc[1]))