iterTimes.py 5.18 KB
Newer Older
1
2
import sys
import glob
3
import numpy as numpy
4
5
6
import pandas as pd

#-----------------------------------------------
7
def read_file(f, dataA, dataB, itA, itB):
8
9
10
11
12
  compute_tam = 0
  comm_tam = 0
  sdr = 0
  adr = 0
  dist = 0
13
14
  css = 0
  cst = 0
15
16
17
  time = 0
  recording = False
  it_line = 0
18
19
  aux_itA = 0
  aux_itB = 0
20
21
22
23
  iters = 0
  np = 0
  np_par = 0
  ns = 0
24
  array = []
25
26
27
28
29
30
31
32
  columnas = ['Titer','Ttype','Top']

  #print(f)
  for line in f: 
    lineS = line.split()
    if len(lineS) > 1:

        if recording and lineS[0].split(':')[0] in columnas: #Record data
33
          aux_itA = 0
34
35
36
37
          lineS.pop(0)

          if it_line==0:
            for observation in lineS:
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
              dataA.append([None]*15)
              dataA[itA+aux_itA][0] = sdr
              dataA[itA+aux_itA][1] = adr
              dataA[itA+aux_itA][2] = np
              dataA[itA+aux_itA][3] = np_par
              dataA[itA+aux_itA][4] = ns
              dataA[itA+aux_itA][5] = dist
              dataA[itA+aux_itA][6] = compute_tam
              dataA[itA+aux_itA][7] = comm_tam
              dataA[itA+aux_itA][8] = cst
              dataA[itA+aux_itA][9] = css
              dataA[itA+aux_itA][10] = time
              dataA[itA+aux_itA][11] = iters
              dataA[itA+aux_itA][12] = float(observation)
              array.append(float(observation))
              aux_itA+=1
54
          elif it_line==1:
55
            deleted = 0
56
            for observation in lineS:
57
58
59
60
61
              dataA[itA+aux_itA][13] = float(observation)
              if float(observation) == 0:
                  array.pop(aux_itA - deleted)
                  deleted+=1
              aux_itA+=1
62
63
          else:
            for observation in lineS:
64
65
              dataA[itA+aux_itA][14] = float(observation)
              aux_itA+=1
66
67
68
69
70

          it_line += 1
          if(it_line % 3 == 0): # Comprobar si se ha terminado de mirar esta ejecucion
            recording = False
            it_line = 0
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
            itA = itA + aux_itA
            if ns != 0: # Solo obtener datos de grupos con hijos
                dataB.append([None]*14)
                dataB[itB][0] = sdr
                dataB[itB][1] = adr
                dataB[itB][2] = np
                dataB[itB][3] = np_par
                dataB[itB][4] = ns
                dataB[itB][5] = dist
                dataB[itB][6] = compute_tam
                dataB[itB][7] = comm_tam
                dataB[itB][8] = cst
                dataB[itB][9] = css
                dataB[itB][10] = time
                dataB[itB][11] = iters
                dataB[itB][12] = tuple(array)
                dataB[itB][13] = numpy.sum(array)
                itB+=1
                array = []
90
91
92
93
94
95

        if lineS[0] == "Config:":
          compute_tam = int(lineS[1].split('=')[1].split(',')[0])
          comm_tam = int(lineS[2].split('=')[1].split(',')[0])
          sdr = int(lineS[3].split('=')[1].split(',')[0])
          adr = int(lineS[4].split('=')[1].split(',')[0]) 
96
97
98
          css = int(lineS[6].split('=')[1].split(',')[0])
          cst = int(lineS[7].split('=')[1].split(',')[0])
          time = float(lineS[8].split('=')[1])
99
100
101
102
103
104
105
106
        elif lineS[0] == "Config":
          recording = True
          iters = int(lineS[2].split('=')[1].split(',')[0])
          dist = int(lineS[4].split('=')[1].split(',')[0])
          np = int(lineS[5].split('=')[1].split(',')[0])
          np_par = int(lineS[6].split('=')[1].split(',')[0])
          ns = int(float(lineS[7].split('=')[1]))

107
  return itA,itB
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#-----------------------------------------------
#Config: matrix=1000, sdr=1000000000, adr=0, aib=0 time=2.000000
#Config Group: iters=100, factor=1.000000, phy=2, procs=2, parents=0, sons=4
#Ttype: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

if len(sys.argv) < 2:
    print("The files name is missing\nUsage: python3 iterTimes.py resultsName directory csvOutName")
    exit(1)

if len(sys.argv) >= 3:
    BaseDir = sys.argv[2]
    print("Searching in directory: "+ BaseDir)
else:
    BaseDir = sys.argv[2]

if len(sys.argv) >= 4:
124
  print("Csv name will be: " + sys.argv[3] + ".csv and "+ sys.argv[3] + "_Total.csv")
125
126
127
128
129
130
131
132
  name = sys.argv[3]
else:
  name = "data"

insideDir = "Run"
lista = glob.glob("./" + BaseDir + insideDir + "*/" + sys.argv[1]+ "*ID*.o*")
print("Number of files found: "+ str(len(lista)));

133
134
135
136
137
itA = itB = 0
dataA = []
dataB = []  #0   #1        #2    #3       #4     #5      #6             #7          #8     #9   #10    #11       #12   #13   #14
columnsA = ["N", "%Async", "NP", "N_par", "NS", "Dist", "Compute_tam", "Comm_tam", "Cst", "Css","Time", "Iters", "Ti", "Tt", "To"] #15
columnsB = ["N", "%Async", "NP", "N_par", "NS", "Dist", "Compute_tam", "Comm_tam", "Cst", "Css","Time", "Iters", "Ti", "Sum"] #14
138
139
140

for elem in lista:
  f = open(elem, "r")
141
  itA,itB = read_file(f, dataA, dataB, itA, itB)
142
143
144
  f.close()

#print(data)
145
146
dfA = pd.DataFrame(dataA, columns=columnsA)
dfB = pd.DataFrame(dataB, columns=columnsB)
147

148
149
150
151
152
153
154
dfA['N'] += dfA['%Async']
dfA['%Async'] = (dfA['%Async'] / dfA['N']) * 100
dfA.to_csv(name + '.csv')

dfB['N'] += dfB['%Async']
dfB['%Async'] = (dfB['%Async'] / dfB['N']) * 100
dfB.to_csv(name + '_Total.csv')