|
@@ -20,18 +20,20 @@ import os.path
|
|
|
# The temp directory to save temporary files
|
|
|
temp_dir = './temp/'
|
|
|
|
|
|
-def find_annotated_line(line_text,file):
|
|
|
- line_number = 0
|
|
|
+def find_annotated_line(after_line,line_text,file):
|
|
|
+ line_number = -1
|
|
|
with open(file) as myFile:
|
|
|
for num, line in enumerate(myFile, 1):
|
|
|
if line_text in line:
|
|
|
- line_number = num
|
|
|
+ if num > after_line:
|
|
|
+ line_number = num
|
|
|
+ break
|
|
|
return line_number
|
|
|
|
|
|
|
|
|
-def energy_results():
|
|
|
- line_start = "Start"
|
|
|
- line_end = "End"
|
|
|
+def energy_results(iter):
|
|
|
+ line_start = 1
|
|
|
+ after_line = 0
|
|
|
directory = "./"
|
|
|
|
|
|
#initialize return values
|
|
@@ -44,105 +46,113 @@ def energy_results():
|
|
|
output[1] = 'No info available'
|
|
|
return output, line_info
|
|
|
|
|
|
- line_start = find_annotated_line(line_start,"module-power-input.txt")
|
|
|
- line_end = find_annotated_line(line_end,"module-power-input.txt")
|
|
|
-
|
|
|
- # report module power
|
|
|
- f = open("module-power-input.txt")
|
|
|
module_power = 0;
|
|
|
suma = 0;
|
|
|
- flag_in = 0
|
|
|
+ prof_time = 0;
|
|
|
+ gpu_power = 0;
|
|
|
+ cpu_power = 0;
|
|
|
|
|
|
- for num, line in enumerate(f,1):
|
|
|
-
|
|
|
- if num == line_end:
|
|
|
- flag_in = 0
|
|
|
- break
|
|
|
+ while(line_start>0):
|
|
|
|
|
|
- if flag_in == 1:
|
|
|
- fields = line.split() #split the line with whitespace as delimmiter
|
|
|
- module_power = module_power + int(fields[0])
|
|
|
- suma = suma + 1
|
|
|
+ line_start = find_annotated_line(after_line,"Start","module-power-input.txt")
|
|
|
+ line_end = find_annotated_line(after_line,"End","module-power-input.txt")
|
|
|
+ after_line = line_end
|
|
|
+ if line_start == -1:
|
|
|
+ break
|
|
|
|
|
|
- if num == line_start: #find the begining of the specified area aof the code
|
|
|
- flag_in = 1
|
|
|
+ # report module power
|
|
|
+ f = open("module-power-input.txt")
|
|
|
+
|
|
|
+ flag_in = 0
|
|
|
|
|
|
- module_power = float(module_power)/suma
|
|
|
+ for num, line in enumerate(f,1):
|
|
|
+
|
|
|
+ if num == line_end:
|
|
|
+ flag_in = 0
|
|
|
+ break
|
|
|
|
|
|
- line_start = max(1,line_start - 1)
|
|
|
- line_end = line_end - 1
|
|
|
+ if flag_in == 1:
|
|
|
+ fields = line.split() #split the line with whitespace as delimmiter
|
|
|
+ module_power = module_power + int(fields[0])
|
|
|
+ suma = suma + 1
|
|
|
|
|
|
- # report gpu power
|
|
|
- f = open("GPU-power.txt")
|
|
|
- gpu_power = 0;
|
|
|
- suma = 0;
|
|
|
- flag_in = 0
|
|
|
+ if num == line_start: #find the begining of the specified area aof the code
|
|
|
+ flag_in = 1
|
|
|
|
|
|
- for num, line in enumerate(f,1):
|
|
|
|
|
|
- if num == line_end:
|
|
|
- flag_in = 0
|
|
|
- break
|
|
|
|
|
|
- if flag_in == 1:
|
|
|
- fields = line.split() #split the line with whitespace as delimmiter
|
|
|
- gpu_power = gpu_power + int(fields[0])
|
|
|
- suma = suma + 1
|
|
|
+ line_start = max(1,line_start - 1)
|
|
|
+ line_end = line_end - 1
|
|
|
|
|
|
- if num == line_start: #find the begining of the specified area aof the code
|
|
|
- flag_in = 1
|
|
|
+ # report gpu power
|
|
|
+ f = open("GPU-power.txt")
|
|
|
+ flag_in = 0
|
|
|
|
|
|
- #average module power
|
|
|
- gpu_power = float(gpu_power)/suma
|
|
|
+ for num, line in enumerate(f,1):
|
|
|
+
|
|
|
+ if num == line_end:
|
|
|
+ flag_in = 0
|
|
|
+ break
|
|
|
|
|
|
- # report cpu power
|
|
|
- f = open("CPU-power.txt")
|
|
|
- cpu_power = 0;
|
|
|
- suma = 0;
|
|
|
- flag_in = 0
|
|
|
+ if flag_in == 1:
|
|
|
+ fields = line.split() #split the line with whitespace as delimmiter
|
|
|
+ gpu_power = gpu_power + int(fields[0])
|
|
|
+ #suma = suma + 1
|
|
|
+
|
|
|
+ if num == line_start: #find the begining of the specified area aof the code
|
|
|
+ flag_in = 1
|
|
|
|
|
|
- for num, line in enumerate(f,1):
|
|
|
|
|
|
- if num == line_end:
|
|
|
- flag_in = 0
|
|
|
- break
|
|
|
|
|
|
- if flag_in == 1:
|
|
|
- fields = line.split() #split the line with whitespace as delimmiter
|
|
|
- cpu_power = cpu_power + int(fields[0])
|
|
|
- suma = suma + 1
|
|
|
+ # report cpu power
|
|
|
+ f = open("CPU-power.txt")
|
|
|
+ flag_in = 0
|
|
|
|
|
|
- if num == line_start: #find the begining of the specified area aof the code
|
|
|
- flag_in = 1
|
|
|
+ for num, line in enumerate(f,1):
|
|
|
+
|
|
|
+ if num == line_end:
|
|
|
+ flag_in = 0
|
|
|
+ break
|
|
|
|
|
|
- #average module power
|
|
|
- cpu_power = float(cpu_power)/suma
|
|
|
+ if flag_in == 1:
|
|
|
+ fields = line.split() #split the line with whitespace as delimmiter
|
|
|
+ cpu_power = cpu_power + int(fields[0])
|
|
|
+ #suma = suma + 1
|
|
|
|
|
|
- # report time
|
|
|
- f = open("prof_time.txt")
|
|
|
- prof_time = 0;
|
|
|
- flag_in = 0
|
|
|
+ if num == line_start: #find the begining of the specified area aof the code
|
|
|
+ flag_in = 1
|
|
|
|
|
|
- for num, line in enumerate(f,1):
|
|
|
-
|
|
|
- if num == line_end:
|
|
|
- flag_in = 0
|
|
|
- break
|
|
|
+ # report time
|
|
|
+ f = open("prof_time.txt")
|
|
|
+ flag_in = 0
|
|
|
+
|
|
|
+ for num, line in enumerate(f,1):
|
|
|
+
|
|
|
+ if num == line_end:
|
|
|
+ flag_in = 0
|
|
|
+ break
|
|
|
+
|
|
|
+ if flag_in == 1:
|
|
|
+ fields = line.split() #split the line with whitespace as delimmiter
|
|
|
+ prof_time = prof_time + int(fields[0])
|
|
|
|
|
|
- if flag_in == 1:
|
|
|
- fields = line.split() #split the line with whitespace as delimmiter
|
|
|
- prof_time = prof_time + int(fields[0])
|
|
|
+ if num == line_start: #find the begining of the specified area aof the code
|
|
|
+ flag_in = 1
|
|
|
|
|
|
- if num == line_start: #find the begining of the specified area aof the code
|
|
|
- flag_in = 1
|
|
|
+ if (suma > 0):
|
|
|
+ module_power = float(module_power)/suma
|
|
|
+ #average module power
|
|
|
+ gpu_power = float(gpu_power)/suma
|
|
|
+ #average module power
|
|
|
+ cpu_power = float(cpu_power)/suma
|
|
|
|
|
|
module_energy = (module_power/1000)*(float(prof_time)/1000)
|
|
|
cpu_energy = (cpu_power/1000)*(float(prof_time)/1000)
|
|
|
gpu_energy = (gpu_power/1000)*(float(prof_time)/1000)
|
|
|
total = module_energy + cpu_energy + gpu_energy
|
|
|
|
|
|
- print 'module_energy: ', module_energy;
|
|
|
- print 'cpu_energy: ', cpu_energy;
|
|
|
- print 'gpu_energy: ', gpu_energy;
|
|
|
- print module_energy, cpu_energy, gpu_energy, total
|
|
|
+ print 'module_energy: ', module_energy/int(iter);
|
|
|
+ print 'cpu_energy: ', cpu_energy/int(iter);
|
|
|
+ print 'gpu_energy: ', gpu_energy/int(iter);
|
|
|
+ print module_energy/int(iter), cpu_energy/int(iter), gpu_energy/int(iter), total/int(iter)
|
|
|
|