Merge pull request #663 from ifilippov/perf
Adding multiple targets in perf.py
This commit is contained in:
88
perf.py
88
perf.py
@@ -177,7 +177,10 @@ def geomean(par):
|
|||||||
l = len(par)
|
l = len(par)
|
||||||
for i in range(l):
|
for i in range(l):
|
||||||
temp = temp * par[i]
|
temp = temp * par[i]
|
||||||
|
if l != 0:
|
||||||
temp = temp ** (1.0/l)
|
temp = temp ** (1.0/l)
|
||||||
|
else:
|
||||||
|
temp = 0
|
||||||
return round(temp, 2)
|
return round(temp, 2)
|
||||||
|
|
||||||
#takes an answer struct and print it.
|
#takes an answer struct and print it.
|
||||||
@@ -189,18 +192,30 @@ def geomean(par):
|
|||||||
#test[4] - list of absolute results with tasks
|
#test[4] - list of absolute results with tasks
|
||||||
#test[5] - list of absolute time without ISPC (serial)
|
#test[5] - list of absolute time without ISPC (serial)
|
||||||
#test[1..4] may be empty
|
#test[1..4] may be empty
|
||||||
def print_answer(answer):
|
def print_answer(answer, target_number):
|
||||||
filelist = []
|
filelist = []
|
||||||
print_debug("--------------------------------------------------------------------------\n", s, perf_log)
|
print_debug("--------------------------------------------------------------------------\n", s, perf_log)
|
||||||
print_debug("test name:\t ISPC speedup: ISPC + tasks speedup: | " +
|
print_debug("test name:\t ISPC speedup: ISPC + tasks speedup: | " +
|
||||||
" ISPC time: ISPC + tasks time: serial:\n", s, perf_log)
|
" ISPC time: ISPC + tasks time: serial:\n", s, perf_log)
|
||||||
|
if target_number > 1:
|
||||||
|
if options.output == "":
|
||||||
|
options.output = "targets.csv"
|
||||||
|
filelist.append("test name,ISPC speedup" + "," * target_number + "ISPC + tasks speedup\n")
|
||||||
|
filelist.append("," + options.perf_target + "," + options.perf_target + "\n")
|
||||||
|
else:
|
||||||
filelist.append("test name,ISPC speedup,diff," +
|
filelist.append("test name,ISPC speedup,diff," +
|
||||||
"ISPC + tasks speedup,diff,ISPC time,diff,ISPC + tasks time,diff,serial,diff\n")
|
"ISPC + tasks speedup,diff,ISPC time,diff,ISPC + tasks time,diff,serial,diff\n")
|
||||||
max_t = [0,0,0,0,0]
|
max_t = [0,0,0,0,0]
|
||||||
diff_t = [0,0,0,0,0]
|
diff_t = [0,0,0,0,0]
|
||||||
geomean_t = [0,0,0,0,0]
|
geomean_t = []
|
||||||
list_of_max = [[],[],[],[],[]]
|
list_of_max = []
|
||||||
|
for i1 in range(target_number):
|
||||||
|
geomean_t.append([0,0,0,0,0])
|
||||||
|
list_of_max.append([[],[],[],[],[]])
|
||||||
list_of_compare = [[],[],[],[],[],[]]
|
list_of_compare = [[],[],[],[],[],[]]
|
||||||
|
target_k = 0
|
||||||
|
temp_str_1 = ""
|
||||||
|
temp_str_2 = ""
|
||||||
for i in range(len(answer)):
|
for i in range(len(answer)):
|
||||||
list_of_compare[0].append(answer[i][0])
|
list_of_compare[0].append(answer[i][0])
|
||||||
for t in range(1,6):
|
for t in range(1,6):
|
||||||
@@ -215,7 +230,7 @@ def print_answer(answer):
|
|||||||
mm = min(answer[i][t])
|
mm = min(answer[i][t])
|
||||||
list_of_compare[t].append(mm)
|
list_of_compare[t].append(mm)
|
||||||
max_t[t-1] = '%.2f' % mm
|
max_t[t-1] = '%.2f' % mm
|
||||||
list_of_max[t-1].append(mm)
|
list_of_max[i % target_number][t-1].append(mm)
|
||||||
diff_t[t-1] = '%.2f' % (max(answer[i][t]) - min(answer[i][t]))
|
diff_t[t-1] = '%.2f' % (max(answer[i][t]) - min(answer[i][t]))
|
||||||
print_debug("%s:\n" % answer[i][0], s, perf_log)
|
print_debug("%s:\n" % answer[i][0], s, perf_log)
|
||||||
print_debug("\t\tmax:\t%5s\t\t%10s\t|min:%10s\t%10s\t%10s\n" %
|
print_debug("\t\tmax:\t%5s\t\t%10s\t|min:%10s\t%10s\t%10s\n" %
|
||||||
@@ -227,17 +242,37 @@ def print_answer(answer):
|
|||||||
max_t[t] = ""
|
max_t[t] = ""
|
||||||
if diff_t[t] == "n/a":
|
if diff_t[t] == "n/a":
|
||||||
diff_t[t] = ""
|
diff_t[t] = ""
|
||||||
|
if target_number > 1:
|
||||||
|
if target_k == 0:
|
||||||
|
temp_str_1 = answer[i][0] + ","
|
||||||
|
temp_str_2 = ""
|
||||||
|
temp_str_1 += max_t[0] + ","
|
||||||
|
temp_str_2 += max_t[1] + ","
|
||||||
|
target_k = target_k + 1
|
||||||
|
if target_k == target_number:
|
||||||
|
filelist.append(temp_str_1 + temp_str_2[:-1] + "\n")
|
||||||
|
target_k = 0
|
||||||
|
else:
|
||||||
filelist.append(answer[i][0] + "," +
|
filelist.append(answer[i][0] + "," +
|
||||||
max_t[0] + "," + diff_t[0] + "," + max_t[1] + "," + diff_t[1] + "," +
|
max_t[0] + "," + diff_t[0] + "," + max_t[1] + "," + diff_t[1] + "," +
|
||||||
max_t[2] + "," + diff_t[2] + "," + max_t[3] + "," + diff_t[3] + "," +
|
max_t[2] + "," + diff_t[2] + "," + max_t[3] + "," + diff_t[3] + "," +
|
||||||
max_t[4] + "," + diff_t[4] + "\n")
|
max_t[4] + "," + diff_t[4] + "\n")
|
||||||
for i in range(0,5):
|
for i in range(0,5):
|
||||||
geomean_t[i] = geomean(list_of_max[i])
|
for i1 in range(target_number):
|
||||||
|
geomean_t[i1][i] = geomean(list_of_max[i1][i])
|
||||||
print_debug("---------------------------------------------------------------------------------\n", s, perf_log)
|
print_debug("---------------------------------------------------------------------------------\n", s, perf_log)
|
||||||
print_debug("Geomean:\t\t%5s\t\t%10s\t|%14s\t%10s\t%10s\n" %
|
print_debug("Geomean:\t\t%5s\t\t%10s\t|%14s\t%10s\t%10s\n" %
|
||||||
(geomean_t[0], geomean_t[1], geomean_t[2], geomean_t[3], geomean_t[4]), s, perf_log)
|
(geomean_t[0][0], geomean_t[0][1], geomean_t[0][2], geomean_t[0][3], geomean_t[0][4]), s, perf_log)
|
||||||
filelist.append("Geomean," + str(geomean_t[0]) + ",," + str(geomean_t[1])
|
if target_number > 1:
|
||||||
+ ",," + str(geomean_t[2]) + ",," + str(geomean_t[3]) + ",," + str(geomean_t[4]) + "\n")
|
temp_str_1 = "Geomean,"
|
||||||
|
temp_str_2 = ""
|
||||||
|
for i in range(target_number):
|
||||||
|
temp_str_1 += str(geomean_t[i][0]) + ","
|
||||||
|
temp_str_2 += str(geomean_t[i][1]) + ","
|
||||||
|
filelist.append(temp_str_1 + temp_str_2[:-1] + "\n")
|
||||||
|
else:
|
||||||
|
filelist.append("Geomean," + str(geomean_t[0][0]) + ",," + str(geomean_t[0][1])
|
||||||
|
+ ",," + str(geomean_t[0][2]) + ",," + str(geomean_t[0][3]) + ",," + str(geomean_t[0][4]) + "\n")
|
||||||
print_file(filelist)
|
print_file(filelist)
|
||||||
return list_of_compare
|
return list_of_compare
|
||||||
|
|
||||||
@@ -297,6 +332,15 @@ def perf(options1, args):
|
|||||||
if is_windows:
|
if is_windows:
|
||||||
pwd1 = "..\\..\\"
|
pwd1 = "..\\..\\"
|
||||||
|
|
||||||
|
if options.perf_target != "":
|
||||||
|
test_only_r = " sse2-i32x4 sse2-i32x8 sse4-i32x4 sse4-i32x8 sse4-i16x8 \
|
||||||
|
sse4-i8x16 avx1-i32x8 avx1-i32x16 avx1-i64x4 avx1.1-i32x8 \
|
||||||
|
avx1.1-i32x16 avx1.1-i64x4 avx2-i32x8 avx2-i32x16 avx2-i64x4 "
|
||||||
|
test_only = options.perf_target.split(" ")
|
||||||
|
for iterator in test_only:
|
||||||
|
if not (" " + iterator + " " in test_only_r):
|
||||||
|
error("unknow option for target: " + iterator, 1)
|
||||||
|
|
||||||
# check if cpu usage is low now
|
# check if cpu usage is low now
|
||||||
cpu_percent = cpu_check()
|
cpu_percent = cpu_check()
|
||||||
if cpu_percent > 20:
|
if cpu_percent > 20:
|
||||||
@@ -409,8 +453,6 @@ def perf(options1, args):
|
|||||||
while i < length-2:
|
while i < length-2:
|
||||||
# we read name of test
|
# we read name of test
|
||||||
print_debug("%s" % lines[i], s, perf_log)
|
print_debug("%s" % lines[i], s, perf_log)
|
||||||
test = [lines[i][:-1],[],[],[],[],[]]
|
|
||||||
test_ref = [lines[i][:-1],[],[],[],[],[]]
|
|
||||||
# read location of test
|
# read location of test
|
||||||
folder = lines[i+1]
|
folder = lines[i+1]
|
||||||
folder = folder[:-1]
|
folder = folder[:-1]
|
||||||
@@ -424,9 +466,18 @@ def perf(options1, args):
|
|||||||
command = lines[i+2]
|
command = lines[i+2]
|
||||||
command = command[:-1]
|
command = command[:-1]
|
||||||
# handle conditional target argument
|
# handle conditional target argument
|
||||||
target_str = ""
|
target_str_temp = ""
|
||||||
|
perf_targets = [""]
|
||||||
|
target_number = 1
|
||||||
if options.perf_target != "":
|
if options.perf_target != "":
|
||||||
target_str = " ISPC_IA_TARGETS="+options.perf_target
|
perf_targets = options.perf_target.split(',')
|
||||||
|
target_str_temp = " ISPC_IA_TARGETS="
|
||||||
|
target_number = len(perf_targets)
|
||||||
|
temp = 0
|
||||||
|
for target_i in range(target_number):
|
||||||
|
test = [lines[i][:-1],[],[],[],[],[]]
|
||||||
|
test_ref = [lines[i][:-1],[],[],[],[],[]]
|
||||||
|
target_str = target_str_temp + perf_targets[target_i]
|
||||||
if is_windows == False:
|
if is_windows == False:
|
||||||
ex_command_ref = "./ref " + command + " >> " + perf_temp + "_ref"
|
ex_command_ref = "./ref " + command + " >> " + perf_temp + "_ref"
|
||||||
ex_command = "./test " + command + " >> " + perf_temp + "_test"
|
ex_command = "./test " + command + " >> " + perf_temp + "_test"
|
||||||
@@ -446,19 +497,20 @@ def perf(options1, args):
|
|||||||
R = next_line.split(' ')
|
R = next_line.split(' ')
|
||||||
c1 = int(R[1]) #c1 is a number of string which we want to use in test output
|
c1 = int(R[1]) #c1 is a number of string which we want to use in test output
|
||||||
c2 = int(R[2]) #c2 is total number of strings in test output
|
c2 = int(R[2]) #c2 is total number of strings in test output
|
||||||
i = i+1
|
temp = 1
|
||||||
else:
|
else:
|
||||||
c1 = 1
|
c1 = 1
|
||||||
c2 = 1
|
c2 = 1
|
||||||
next_line = lines[i+3]
|
next_line = lines[i+3]
|
||||||
if next_line[0] == "^": #we should concatenate result of this test with previous one
|
if next_line[0] == "^":
|
||||||
|
temp = 1
|
||||||
|
if next_line[0] == "^" and target_number == 1: #we should concatenate result of this test with previous one
|
||||||
run_test(commands, c1, c2, answer[len(answer)-1], answer_ref[len(answer)-1], False)
|
run_test(commands, c1, c2, answer[len(answer)-1], answer_ref[len(answer)-1], False)
|
||||||
i = i+1
|
|
||||||
else: #we run this test and append it's result to answer structure
|
else: #we run this test and append it's result to answer structure
|
||||||
run_test(commands, c1, c2, test, test_ref, True)
|
run_test(commands, c1, c2, test, test_ref, True)
|
||||||
answer.append(test)
|
answer.append(test)
|
||||||
answer_ref.append(test_ref)
|
answer_ref.append(test_ref)
|
||||||
|
i = i + temp
|
||||||
# preparing next loop iteration
|
# preparing next loop iteration
|
||||||
os.chdir(pwd1)
|
os.chdir(pwd1)
|
||||||
i+=4
|
i+=4
|
||||||
@@ -468,8 +520,10 @@ def perf(options1, args):
|
|||||||
common.remove_if_exists(perf_temp+"_ref")
|
common.remove_if_exists(perf_temp+"_ref")
|
||||||
|
|
||||||
#print collected answer
|
#print collected answer
|
||||||
|
if target_number > 1:
|
||||||
|
s = True
|
||||||
print_debug("\n\nTEST COMPILER:\n", s, perf_log)
|
print_debug("\n\nTEST COMPILER:\n", s, perf_log)
|
||||||
A = print_answer(answer)
|
A = print_answer(answer, target_number)
|
||||||
if options.ref != "":
|
if options.ref != "":
|
||||||
print_debug("\n\nREFERENCE COMPILER:\n", s, perf_log)
|
print_debug("\n\nREFERENCE COMPILER:\n", s, perf_log)
|
||||||
B = print_answer(answer_ref)
|
B = print_answer(answer_ref)
|
||||||
|
|||||||
Reference in New Issue
Block a user