MallTimes.py 5.32 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import sys
import glob
import numpy as np
import pandas as pd

def getData(lineS, outData, tp, hasIter = False):
  for data in lineS:
    k_v = data.split('=')
    if k_v[0] == "time":
      time = float(k_v[1])
    elif k_v[0] == "iters" and hasIter:
      iters = int(k_v[1])

  outData[tp] = time
  if hasIter:
    outData[tp+1] = iters

#-----------------------------------------------
def record(f, observation, line):
  # Record first line - General info
  lineS = line.split()
  for j in range(1,7):
    observation[j] = int(lineS[j].split('=')[1])

  # Record procces number
  line = next(f)
  lineS = line.split()
  j = 7
  for key_values in lineS:
    k_v = key_values.split('=')
    observation[j] = int(k_v[1])
    j+=1

  # Record data
  j = 9
  for j in range(9, 13):
    line = next(f)
    lineS = line.split()  
    getData(lineS, observation, j)

  line = next(f)
  lineS = line.split()  
  #if observation[0] == "A":
  getData(lineS, observation, 13, True)
  #else:
   # getData(lineS, observation, 13)


#-----------------------------------------------
def read_file(f, dataA, dataB, it):
  recording = False
  resizes = 0
  timer = 0
  previousNP = 0

  for line in f: 
    lineS = line.split()

    if len(lineS) > 0:
      if lineS[0] == "Config": # CONFIG LINE
        recording = True
        it += 1
63
64
65
66
        dataA.append([None]*13)
        dataB.append([None]*15)
        #resizes = int(lineS[2].split('=')[1].split(',')[0])
        resizes = 2
67
68
69
70
        compute_tam = int(lineS[3].split('=')[1].split(',')[0])
        comm_tam = int(lineS[4].split('=')[1].split(',')[0])
        sdr = int(lineS[5].split('=')[1].split(',')[0])
        adr = int(lineS[6].split('=')[1].split(',')[0]) #TODO Que lo tome como porcentaje
71
72
        css = int(lineS[8].split('=')[1].split(',')[0])
        cst = int(lineS[9].split('=')[1].split(',')[0])
73
        # TODO Que obtenga Aib
74
        time = float(lineS[10].split('=')[1])
75
76
77
78
79
80

        dataB[it][0] = sdr
        dataB[it][1] = adr 
        dataB[it][4] = "" 
        dataB[it][5] = compute_tam
        dataB[it][6] = comm_tam
81
82
83
84
        dataB[it][7] = cst
        dataB[it][8] = css
        dataB[it][9] = time
        dataB[it][10] = "" 
85
86
87

        dataA[it][0] = sdr
        dataA[it][1] = adr 
88
89
90
91
92
93
94
        dataA[it][5] = ""
        dataA[it][6] = compute_tam
        dataA[it][7] = comm_tam
        dataA[it][8] = cst
        dataA[it][9] = css
        dataA[it][10] = time
        dataA[it][11] = ""
95
96
97
98
99
100
101
102
103
104

      elif recording and resizes != 0: # RESIZE LINE
        iters = int(lineS[2].split('=')[1].split(',')[0])
        npr = int(lineS[3].split('=')[1].split(',')[0])
        dist = lineS[5].split('=')[1]

        resizes = resizes - 1
        if resizes == 0:
          dataB[it][3] = npr
          dataB[it][4] += dist
105
          dataB[it][10] += str(iters)
106

107
          dataA[it][4] = npr #FIXME No sera correcta si hay mas de una reconfig
108
          dataA[it][2] = str(previousNP) + "," + str(npr)
109
110
          dataA[it][5] += dist
          dataA[it][11] += str(iters)
111
          timer = 4
112
113
114
        else:
          dataB[it][2] = npr
          dataB[it][4] += dist + ","
115
          dataB[it][10] += str(iters) + ","
116

117
118
119
          dataA[it][3] = npr
          dataA[it][5] += dist + ","
          dataA[it][11] += str(iters) + ","
120
121
122
          previousNP = npr

      else: # SAVE TIMES
123
        if timer == 4:
124
          dataB[it][11] = float(lineS[1])
125
        elif timer == 3:
126
          dataB[it][12] = float(lineS[1])
127
        elif timer == 2:
128
          dataB[it][13] = float(lineS[1])
129
        elif timer == 1:
130
          dataB[it][14] = float(lineS[1])
131
        else:
132
          dataA[it][12] = float(lineS[1])
133
134
135
        timer = timer - 1
          
  return it
136
137
#columnsA1 = ["N", "%Async", "Groups", "Dist", "Matrix", "CommTam", "Cst", "Css", "Time", "Iters", "TE"] #8
#columnsB1 = ["N", "%Async", "NP", "NS", "Dist", "Matrix", "CommTam", "Cst", "Css", "Time", "Iters", "TC", "TS", "TA"] #12
138
139
140
141
#Config loaded: resizes=2, matrix=1000, sdr=1000000000, adr=0, aib=0, time=2.000000 || grp=1
#Resize 0: Iters=100, Procs=2, Factors=1.000000, Phy=2
#Resize 1: Iters=100, Procs=4, Factors=0.500000, Phy=2
#Tspawn: 0.249393 
142
#Tthread: 0 
143
144
145
#Tsync: 0.330391 
#Tasync: 0
#Tex: 301.428615
146
147

#Config loaded: resizes=1, matrix=0, comm_tam=0, sdr=0, adr=0, aib=0, cst=3, css=1, time=1 || grp=1
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#-----------------------------------------------

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:
  print("Csv name will be: " + sys.argv[3] + "G.csv & " + sys.argv[3] + "M.csv")
  name = sys.argv[3]
else:
  name = "data"

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

it = -1
dataA = []
dataB = []
173
174
columnsA = ["N", "%Async", "Groups", "NP", "NS", "Dist", "Matrix", "CommTam", "Cst", "Css", "Time", "Iters", "TE"] #13
columnsB = ["N", "%Async", "NP", "NS", "Dist", "Matrix", "CommTam", "Cst", "Css", "Time", "Iters", "TC", "TH", "TS", "TA"] #15
175
176
177
178
179
180
181
182
183
184
185
186

for elem in lista:
  f = open(elem, "r")
  it = read_file(f, dataA, dataB, it)
  f.close()

#print(data)
dfA = pd.DataFrame(dataA, columns=columnsA)
dfA.to_csv(name + 'G.csv')

dfB = pd.DataFrame(dataB, columns=columnsB)
dfB.to_csv(name + 'M.csv')