9 print("Usage : %s datafile links latency bandwidth [size...]" % sys.argv[0])
10 print("where : datafile is a SkaMPI pingpong measurement log file");
11 print(" links is the number of links between nodes")
12 print(" latency is the nominal latency given in the platform file")
13 print(" bandwidth is the nominal bandwidth given in the platform file")
14 print(" size are segments limits")
17 ##-----------------------------------------
18 ## avg : return average of a list of values
19 ## param l list of values
20 ##-----------------------------------------
27 ##-------------------------------------------------
29 ## param X first data vector (..x_i..)
30 ## param Y second data vector (..x_i..)
31 ## = 1/n \Sum_{i=1}^n (x_i - avg(x)) * (y_i - avg(y))
32 ##--------------------------------------------------
34 assert len(X) == len(Y)
35 n = len(X) # n=len(X)=len(Y)
40 S_XY += (X[i] - avg_X) * (Y[i] - avg_Y)
43 ##----------------------------------
44 ## variance : variance
45 ## param X data vector ( ..x_i.. )
46 ## (S_X)^2 = (Sum ( x_i - avg(x) )^2 ) / n
47 ##----------------------------------
53 S_X2 += (X[i] - avg_X) ** 2
56 def calibrate (links, latency, bandwidth, sizes, timings):
57 assert len(sizes) == len(timings)
60 S_XY = cov(sizes, timings)
61 S_X2 = variance(sizes)
63 b = avg(timings) - a * avg(sizes)
64 return (b * 1e-6) / (latency * links), 1e6 / (a * bandwidth)
66 ##-----------------------------------------------------------------------------------------------
68 ##-----------------------------------------------------------------------------------------------
69 links = int(sys.argv[2])
70 latency = float(sys.argv[3])
71 bandwidth = float(sys.argv[4])
72 skampidat = open(sys.argv[1], "r")
74 ## read data from skampi logs.
78 for line in skampidat:
80 if line[0] != '#' and len(l) >= 3: # is it a comment ?
83 #count= 8388608 8388608 144916.1 7.6 32 144916.1 143262.0
84 #("%s %d %d %f %f %d %f %f\n" % (countlbl, count, countn, time, stddev, iter, mini, maxi)
85 readdata.append( (int(l[1]),float(l[3]) / 2 ) ); # divide by 2 because of ping-pong measured
87 ## These may not be sorted so sort it by message size before processing.
88 sorteddata = sorted( readdata, key=lambda pair: pair[0])
89 sizes,timings = zip(*sorteddata);
92 ## adds message sizes of interest: if values are specified starting from the 6th command line arg
93 ## and these values are found as message sizes in te log file, add it to the limits list.
94 ## Each of these value si considered a potential inflexion point between two segments.
96 ## If no value specified, a single segment is considered from 1st to last message size logged.
99 for i in range(5, len(sys.argv)):
100 limits += [idx for idx in range(len(sizes)) if sizes[idx] == int(sys.argv[i])]
101 limits.append(len(sizes) - 1)
105 correc = calibrate(links, latency, bandwidth, sizes[low:lim + 1], timings[low:lim + 1])
107 print("Segment [%d:%d] -- Latency factor=%g -- Bandwidth factor=%g" % (sizes[low], sizes[lim], correc[0], correc[1]))