8 print("Usage : %s datafile links latency bandwidth [size...]" % sys.argv[0])
9 print("where : links is the number of links between nodes")
10 print(" latency is the nominal latency given in the platform file")
11 print(" bandwidth is the nominal bandwidth given in the platform file")
12 print(" size are segments limites")
15 ##-----------------------------------------
16 ## avg : return average of a list of values
17 ## param l list of values
18 ##-----------------------------------------
25 ##-------------------------------------------------
27 ## param X first data vector (..x_i..)
28 ## param Y second data vector (..x_i..)
29 ## = 1/n \Sum_{i=1}^n (x_i - avg(x)) * (y_i - avg(y))
30 ##--------------------------------------------------
32 assert len(X) == len(Y)
33 n = len(X) # n=len(X)=len(Y)
38 S_XY += (X[i] - avg_X) * (Y[i] - avg_Y)
41 ##----------------------------------
42 ## variance : variance
43 ## param X data vector ( ..x_i.. )
44 ## (S_X)^2 = (Sum ( x_i - avg(x) )^2 ) / n
45 ##----------------------------------
51 S_X2 += (X[i] - avg_X) ** 2
54 def calibrate (links, latency, bandwidth, sizes, timings):
55 assert len(sizes) == len(timings)
58 S_XY = cov(sizes, timings)
59 S_X2 = variance(sizes)
61 b = avg(timings) - a * avg(sizes)
62 return (b * 1e-6) / (latency * links), 1e6 / (a * bandwidth)
64 ##-----------------------------------------------------------------------------------------------
66 ##-----------------------------------------------------------------------------------------------
67 links = int(sys.argv[2])
68 latency = float(sys.argv[3])
69 bandwidth = float(sys.argv[4])
70 skampidat = open(sys.argv[1], "r")
74 for line in skampidat:
76 if line[0] != '#' and len(l) >= 3: # is it a comment ?
79 #count= 8388608 8388608 144916.1 7.6 32 144916.1 143262.0
80 #("%s %d %d %f %f %d %f %f\n" % (countlbl, count, countn, time, stddev, iter, mini, maxi)
81 timings.append(float(l[3]) / links)
82 sizes.append(int(l[1]))
86 for i in xrange(5, len(sys.argv)):
87 limits += [idx for idx in xrange(len(sizes)) if sizes[idx] == int(sys.argv[i])]
88 limits.append(len(sizes) - 1)
92 correc = calibrate(links, latency, bandwidth, sizes[low:lim + 1], timings[low:lim + 1])
94 print("Segment [%d:%d] -- Latency factor=%g -- Bandwidth factor=%g" % (sizes[low], sizes[lim], correc[0], correc[1]))