Commit a8fc9678 authored by German Leon's avatar German Leon
Browse files

Cambios cruzados

parent b7e5ba94
......@@ -42,14 +42,23 @@ Function that calls the profiler based on the injection mode
"""
def profiler_caller(gdb_exec, kernel, benchmark_binary, benchmark_args,device,section,kernel_end):
def profiler_caller(gdb_exec, kernels, benchmark_binary, benchmark_args,device,section):
acc_time = 0
acc_time_profiler=0
script = 'env CUDA_VISIBLE_DEVICES={} {} -ex \'py arg0 = {}\' -n -batch -x {}'
benchmark_args_striped = benchmark_args.replace('\\n', '').replace('\\', '')
print ("KERNEL"+kernel)
# print ("KERNEL"+kernels)
#init_string = '"file {}; set args {}"'.format(benchmark_binary, benchmark_args_striped)
init_string = '"{};{};file {}; set args {}; break {}"'.format(section,kernel_end,benchmark_binary, benchmark_args_striped,kernel)
print ("SECTION {}".format(section))
init_string = '"{};{};{};file {}; set args {}; set cuda break_on_launch application"'.format(False,True,kernels,benchmark_binary, benchmark_args_striped)
profiler_cmd = script.format(device, gdb_exec, init_string, cp.PROFILER_SCRIPT)
max_registers=os.system(profiler_cmd) >>8
print(max_registers,max_registers>>8)
if bool(section):
init_string = '"{};{};{};file {}; set args {}; break {}; break {}"'.format( bool(section),False,kernels,benchmark_binary,benchmark_args_striped,section['begin'],section['end'])
else:
init_string = '"{};{};{};file {}; set args {}; break {}"'.format(False,False,kernels,benchmark_binary, benchmark_args_striped,kernels.split(",")[0])
profiler_cmd = script.format(device, gdb_exec, init_string, cp.PROFILER_SCRIPT)
print ("Profiler caller")
if cp.DEBUG:
......@@ -64,7 +73,7 @@ def profiler_caller(gdb_exec, kernel, benchmark_binary, benchmark_args,device,se
acc_time += end - start
cf.kill_all("killall -9 {}; killall -9 {}".format(
os.path.basename(gdb_exec), os.path.basename(benchmark_binary)))
return acc_time_profiler / cp.MAX_TIMES_TO_PROFILE, acc_time / cp.MAX_TIMES_TO_PROFILE
return acc_time_profiler / cp.MAX_TIMES_TO_PROFILE, acc_time / cp.MAX_TIMES_TO_PROFILE, max_registers
......@@ -81,7 +90,7 @@ def generate_gold(gdb_exec, benchmark_binary, benchmark_args,device):
os.system("rm -rf " + tmp_path + "/*")
script = 'env CUDA_VISIBLE_DEVICES={} {} -ex \'py arg0 = {}\' -n -batch -x {} > {} 2> {}'
init_string = '"file {}; set args {}"'.format(benchmark_binary, benchmark_args)
init_string = '"{};{};{};file {}; set args {}"'.format(False,True,"",benchmark_binary, benchmark_args)
profiler_cmd = script.format(device, gdb_exec, init_string, cp.PROFILER_SCRIPT, cp.GOLD_OUTPUT_PATH, cp.GOLD_ERR_PATH)
if cp.DEBUG:
print("PROFILER CMD: {}".format(profiler_cmd))
......@@ -118,28 +127,29 @@ def main():
benchmark_args = conf.get('DEFAULT', 'benchmarkArgs_noverificar')
else:
benchmark_args = conf.get('DEFAULT', 'benchmarkArgs')
section= 'kernel_end' in conf['DEFAULT']
kernel_end=''
if (section):
kernel_end=conf.get('DEFAULT','kernel_end')
section={}
if ('section_end' in conf['DEFAULT']):
section['begin']=conf.get('DEFAULT','section_begin')
section['end']=conf.get('DEFAULT','section_end')
gdb_exec = conf.get("DEFAULT", "gdbExecName")
kernel=conf.get('DEFAULT', 'kernel')
[max_time_kernel,max_time_app] = profiler_caller(gdb_exec=gdb_exec,kernel=kernel, benchmark_binary=benchmark_binary, benchmark_args=benchmark_args,device=args.device,section=section,kernel_end=kernel_end)
kernels=conf.get('DEFAULT', 'kernels')
[max_time_kernel,max_time_app,max_regs] = profiler_caller(gdb_exec=gdb_exec,kernels=kernels, benchmark_binary=benchmark_binary, benchmark_args=benchmark_args,device=args.device,section=section)
print ("Time kernel= "+str(max_time_kernel)+ "Time app "+str(max_time_app))
# saving gold
print ("Saving gold");
#generate_gold_result = generate_gold(gdb_exec=gdb_exec,
# benchmark_binary=benchmark_binary, benchmark_args=benchmark_args,device=args.device)
generate_gold_result = generate_gold(gdb_exec=gdb_exec,
benchmark_binary=benchmark_binary, benchmark_args=benchmark_args,device=args.device)
#if generate_gold_result != 0:
# raise EnvironmentError("Gold generation did not finish well, the fault injection will not work")
if generate_gold_result != 0:
raise EnvironmentError("Gold generation did not finish well, the fault injection will not work")
# Remove trash GDB info from the std output and the err output
cf.remove_useless_information_from_output(cp.GOLD_OUTPUT_PATH)
cf.remove_useless_information_from_output(cp.GOLD_ERR_PATH)
# Save the kernel configuration txt file
cf.save_file(file_path=cp.KERNEL_INFO_DIR, data={'max_time': max_time_app,'max_time_kernel': max_time_kernel})
cf.save_file(file_path=cp.KERNEL_INFO_DIR, data={'max_time': max_time_app,'max_time_kernel': max_time_kernel,'max_regs':max_regs})
print("1 - Profile finished\n###################################################")
......
......@@ -17,7 +17,7 @@ faultModel = 0
# RF -> Register File
# INST_OUT -> Instruction Output (NOT IMPLEMENTED YET)
# INST_composed -> Instruction Adress (NOT IMPLEMENTED YET)
injectionSite = RF
injectionSite = INST_OUT
# Max time factor to finish the app, this will be multiplied by the application running time
# For example if your app spend 2s, and the maxWaitTimes is 5, the max running time before it is
# Considered as a crash is 10s
......@@ -42,6 +42,6 @@ seqSignals = 20
# Initial sleep time in seconds before start sending signals
# Generally the memory setup time
initSleep = 2.1
#kernel = matrixMulCUDA
kernel = matrixMul.cu:205
kernel_end = matrixMul.cu:217
kernels = matrixMulCUDA
section_begin = matrixMul.cu:205
section_end = matrixMul.cu:217
......@@ -300,6 +300,7 @@ def check_injection_outcome(host_thread, logging, injection_site):
# if fault was injected ASSM_LINE MUST be in the logfile
assm_line = logging.search("ASSM_LINE")
instruction = re.match(r".*:\t(\S+) .*", assm_line).group(1)
instruction = assm_line
except TypeError as te:
instruction = new_value = old_value = None
......@@ -701,7 +702,7 @@ def main():
'current_path': current_path,
'seq_signals': int(conf.get('DEFAULT', 'seqSignals')),
'init_sleep': float(conf.get('DEFAULT', 'initSleep')),
'kernel':conf.get('DEFAULT', 'kernel'),
'kernel':conf.get('DEFAULT', 'section_begin'),
'gold_check_script': "{}/{}".format(current_path, conf.get('DEFAULT', 'goldenCheckScript')),
'summary_file': summary_file,
'header': fieldnames
......@@ -718,7 +719,7 @@ def main():
for thread in gpus_threads:
thread.join()
ret += thread.exit_code
#ret += thread.exit_code
os.system("rm -f {}/bin/*".format(current_path))
if exit_injector:
......
import gdb
import time
import time
import re
import sys
import common_functions as cf
def exit_handler(event):
global nosalir
......@@ -16,9 +19,40 @@ def exit_handler(event):
Handler that will put a breakpoint on the kernel after
signal
"""
def numreg (kernel):
try:
disassemble_array = cf.execute_command(gdb=gdb, to_execute="disassemble {}".format(kernel))
except:
disassemble_array = cf.execute_command(gdb=gdb, to_execute="disassemble")
listareg=set()
listaregdst=set()
listaregcond=set()
for i in range(0, len(disassemble_array) - 1):
line = disassemble_array[i]
m=re.match(r".*:\t(\S+) .*",line)
# print("ASSM_LINE:{}".format(l))
todacadena="ASSM_LINE:{}".format(line)
print(todacadena)
lista=re.findall(r"R(\d+)", line)
if (len(lista) > 0):
listareg.update(lista)
print (listareg)
listaregdst.add (lista[0])
print (listaregdst)
lista=re.findall(r" P(\d+)", line)
if (len(lista) > 0):
print (listaregcond)
listaregcond.update(lista)
# if m and m.group(1) != '0':
# Print ("Encontrado"
print ("Registros Visibles ({})".format(len(listareg)))
print (listareg)
print ("Registros destino ({})".format(len(listaregdst)))
print (listaregdst)
print ("Registros condicionales ({})".format(len(listaregcond)))
print (listaregcond)
return (len(listareg))
def set_event(event):
global trun,ocurrencias,t,primera
......@@ -58,37 +92,29 @@ def main():
# gdb_init_strings = str(os.environ["CAROL_FI_INFO"])
gdb_init_strings = arg0
cadena=gdb_init_strings.split(";",2)
#print (cadena,"-",cadena[0],'-',cadena[1],'-', cadena[2])
section =cadena[0]=="True"
kernel_end=cadena[1]
cadena=gdb_init_strings.split(";",3)
print >>sys.stderr, (cadena[0]) #,"-",cadena[0],"-",cadena[1],"-", cadena[2],"#". cadena[3])
section =cadena[0]=="True"
onlycount=cadena[1]=="True"
#print ("B "+section+"ke "+kernel_end+" ....")
#print (cadena[2].split(";"))
for init_str in cadena[2].split(";"):
for init_str in cadena[3].split(";"):
gdb.execute(init_str)
if (section):
gdb.execute ("break "+kernel_end)
max=0.
gdb.execute("r")
#nosalir=True
#while nosalir:
if (section):
#print ("Point 1")
gdb.execute("c")
if (onlycount):
ks=cadena[2].split(",",1)
max=numreg(ks[0])
else:
gdb.execute("finish")
#print ("Punto 2")
#print (" Ocurrencias "+str(ocurrencias)+" Tiempo acumulado de ejecucciones "+ str(trun)+ "\n")
gdb.execute("c")
if (section):
gdb.execute("c")
else:
gdb.execute("finish")
#print (" Ocurrencias "+str(ocurrencias)+" Tiempo acumulado de ejecucciones "+ str(trun))
f=open("tmpxxx_return_profiler.conf","w")
f.write("[DEFAULT] \nOcurrencias = "+str(ocurrencias)+"\nTiempo = "+str(trun)+"\n")
f.close()
#print ("End write file \n")
#sys.stdout.flush()
f=open("tmpxxx_return_profiler.conf","w")
f.write("[DEFAULT] \nOcurrencias = "+str(ocurrencias)+"\nTiempo = "+str(trun)+"\n")
f.close()
sys.exit(max)
main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment