Commit 97b1c215 authored by German Leon's avatar German Leon
Browse files

Muchos cambios

parent 8621c3da
......@@ -28,28 +28,74 @@ signal
"""
def set_event(event):
def set_event_normal(event):
# Accessing global vars
global global_logging, was_hit, bit_flip,bp,t,primero
if (isinstance(event, gdb.BreakpointEvent)):
global_logging.info("Before breakpoint"+ str(time.clock()-t))
global_logging.info ("Enviado senal a "+ str(pid))
sendsignal(cp.SIGNAL_STOP)
bp.enabled=False
gdb.execute('c')
# #os.system ("killall -2 python3")
elif (isinstance(event, gdb.SignalEvent)):
if (isinstance(event, gdb.SignalEvent)):
gdb.events.stop.disconnect(set_event_normal)
try:
# Just checking if it was hit
if bit_flip.fault_injected is False:
bit_flip.single_event()
global_logging.info("BIT FLIP SET ON SIGNAL {}".format(event.stop_signal))
#global_logging.info ("Enviado senal a "+ str(pid))
#sendsignal(cp.SIGNAL_STOP)
gdb.events.stop.connect(set_event_normal)
except Exception as err:
global_logging.exception("EVENT DIFFERENT FROM STOP SIGNAL: {}".format(str(err)))
else:
global_logging.exception("EVENT DIFFERENT SignalEvent FROM STOP SIGNAL: {}".format(isinstance(event, gdb.BreakpointEvent)))
def set_event_inst_adr(event):
# Accessing global vars
global global_logging, was_hit, bit_flip,bpia,t,primero,data_kernels
if (isinstance(event, gdb.SignalEvent)):
try:
# Just checking if it was hit
#Generar una direccion aleatoria a un kernel y almacenarlo en checkpointkernel
#checkpointkernel=" *0x555555c71ed0 "
gdb.events.stop.disconnect(set_event_inst_adr)
BitFlip.update_data_kernels(data_kernels)
# global_logging.info(BitFlip.principiokernel("lud_diagonal"))
#global_logging.info(BitFlip.principiokernel("lud_internal"))
# global_logging.info(BitFlip.principiokernel("lud_perimeter"))
# global_logging.info(BitFlip.principio2kernel("lud_diagonal"))
# global_logging.info(BitFlip.principio2kernel("lud_internal"))
# global_logging.info(BitFlip.principio2kernel("lud_perimeter"))
checkpointkernel=BitFlip.address_random(data_kernels)
global_logging.info("BREAK {} \n".format(checkpointkernel))
bpia=gdb.Breakpoint(checkpointkernel)
gdb.events.stop.connect(set_event_break_instr_adr)
except Exception as err:
global_logging.exception("EVENT DIFFERENT FROM STOP SIGNAL: {} IN set_event_inst_adr ".format(str(err)))
def set_event_break_instr_adr(event):
# Accessing global vars
global global_logging, was_hit, bit_flip,bpia,t,primero
if (isinstance(event, gdb.BreakpointEvent)):
try:
gdb.events.stop.disconnect(set_event_break_instr_adr)
global_logging.info("RUN BREAK {} \n")
bpia.delete()
# Just checking if it was hit
if bit_flip.fault_injected is False:
bit_flip.single_event()
global_logging.info("BIT FLIP SET ON SIGNAL {}".format(event.stop_signal))
#global_logging.info ("Enviado senal a "+ str(pid))
sendsignal(cp.SIGNAL_STOP)
#bpia.enabled=False
gdb.events.stop.connect(set_event_inst_adr)
#sendsignal(cp.SIGNAL_STOP)
gdb.execute('c')
except Exception as err:
global_logging.exception("EVENT DIFFERENT FROM STOP SIGNAL: {}".format(str(err)))
global_logging.exception("EVENT DIFFERENT FROM STOP SIGNAL: {} IN set_event_break_instr_adr".format(str(err)))
#De esta forma, si llega un event por nexti (event.stop), no realiza nada.
"""
......@@ -58,10 +104,11 @@ Main function
def main():
global global_logging, register, injection_site, bits_to_flip, fault_model, was_hit, bit_flip, arg0,t,kernel,pid,bp
global global_logging, register, injection_site, bits_to_flip, fault_model, was_hit, bit_flip, arg0,t,kernel,pid,bp,data_kernels,rsi,traza
was_hit = False
indirect= cp.INDIRECT_KERNEL
pruebaDebug=True
# Initialize GDB to run the app
gdb.execute("set confirm off")
gdb.execute("set pagination off")
......@@ -79,10 +126,10 @@ def main():
gdb_init_strings, injection_site] = arg0.split('|')
pruebaDebug=(cp.INJECTION_SITES[injection_site]==cp.INST_OUT_V1)
# Logging
global_logging = Logging(log_file=flip_log_file)
global_logging.info("Starting flip_value script "+" called by " + str(pid) + " for stop kernel " + str(kernel));
global_logging.info("Starting flip_value script "+" called by " + str(pid) + " for stop kernel " + str(kernel)+". This kernel has"+str(max_regs)+".");
try:
for init_str in gdb_init_strings.split(";"):
gdb.execute(init_str)
......@@ -96,13 +143,18 @@ def main():
fault_model = int(fault_model)
bit_flip = BitFlip(bits_to_flip=bits_to_flip, fault_model=fault_model,max_regs=max_regs,
logging=global_logging, injection_site=cp.INJECTION_SITES[injection_site])
data_kernels=bit_flip.read_data_kernels(pruebaDebug)
# Start app execution
t=time.clock();
gdb.Breakpoint('main')
#gdb.execute("break "+kernel)
bp=gdb.Breakpoint(kernel)
global_logging.info("Put Break "+ str(time.clock()-t))
global_logging.info("Put Break "+kernel+" "+ str(time.clock()-t))
gdb.execute("r")
try:
......@@ -116,8 +168,26 @@ def main():
fp.write(pid_bench)
fp.close()
# Connecting to a stop signal event
if indirect:
print ("Indirecto")
gdb.execute("set cuda break_on_launch application")
else:
bp=gdb.Breakpoint(kernel)
gdb.execute('c')
#bp.enabled=False
if indirect:
gdb.execute("set cuda break_on_launch none")
gdb.events.stop.connect(set_event_inst_adr)
else:
bp.delete()
gdb.events.stop.connect(set_event_normal)
global_logging.info("Before breakpoint"+ str(time.clock()-t))
global_logging.info ("Enviado senal a "+ str(pid))
sendsignal(cp.SIGNAL_STOP)
gdb.execute('c')
gdb.events.stop.connect(set_event)
print("4")
i = 0
try:
......
......@@ -2,8 +2,11 @@ import os
import re
import gdb
import time
import signal
import common_functions as cf
from classes.BitFlip import BitFlip
from classes.Logging import Logging
import common_parameters as cp
def exit_handler(event):
global nosalir
nosalir=False
......@@ -20,26 +23,6 @@ def exit_handler(event):
Handler that will put a breakpoint on the kernel after
signal
"""
def handler(signum, frame):
global pid,pillo,t0
print ("handler:+++++++++++========================++++++++++++")
#print ("+++++++++++========================++++++++++++")
#gdb.execute("nexti")
settimeslice()
pillo=time.time()-t0
os.kill(os.getpid(), signal.SIGINT)
#print ("+++++++++++========================++++++++++++")
def setalarm():
signal.signal(signal.SIGALRM,handler)
#print ("No disponible")
def settimeslice():
#signal.alarm(1)
signal.setitimer(signal.ITIMER_REAL,1.0,1.0)
#print ("No disponible")
def pausealarm():
signal.setitimer(signal.ITIMER_REAL,0)
#print ("No disponible")
def selectrd():
linea= cf.execute_command(gdb=gdb, to_execute="x/1i $pc")
......@@ -78,85 +61,66 @@ def selectrd():
print (type(lista))
print(lista)
def set_event(event):
global trun,ocurrencias,t,pillo,t0,bp
#pausealarm()
global trun,ocurrencias,t
print("===,casi,casi,casi,=============")
if (isinstance(event, gdb.BreakpointEvent)):
print ("Bp")
t0=time.clock()
bp.enabled=False
print("===,si,si,si,=============")
t=time.clock()
ocurrencias=ocurrencias+1
#signal.setitimer(signal.ITIMER_REAL,3)
else:
print ("set_event")
#signal.setitimer(signal.ITIMER_REAL,0)
trun=(time.clock()-t0)
#signal.setitimer(signal.ITIMER_REAL,2)
#signal.setitimer(signal.ITIMER_REAL,0.1)
t=time.time()-t0
print ("\n Pongo: "+str(t)+" Pillo;"+str(pillo)+"\n")
#settimeslice()
#gdb.execute("c")
trun=(time.clock()-t)
def kernels():
data_kernels=BitFlip.read_data_kernels()
print("DIct {}".format(data_kernels))
BitFlip.update_data_kernels(data_kernels)
print("DIct {}".format(data_kernels))
BitFlip.principiokernel("lud_diagonal")
BitFlip.principiokernel("lud_internal")
BitFlip.principiokernel("lud_perimeter")
BitFlip.principio2kernel("lud_diagonal")
BitFlip.principio2kernel("lud_internal")
BitFlip.principio2kernel("lud_perimeter")
r=BitFlip.kernelnow()
print(r)
#[p,f]=BitFlip.rangekernel("lud_diagonal")
#print (p,f)
gdb.execute('disas lud_diagonal')
gdb.execute('disas lud_internal')
gdb.execute('disas lud_perimeter')
def main():
global ocurrencias,t,nosalir,trun,pid,t0,pillo,bp
global ocurrencias,t,nosalir,trun,bf
was_hit = False
#pid=os.getpid()
ocurrencias=0
# Initialize GDB to run the appset pagination off
gdb.execute('catch signal SIGALRM')
gdb.execute("set confirm off")
gdb.execute("set pagination off")
gdb.execute("set target-async off")
gdb.execute("set non-stop off")
setalarm()
settimeslice()
# Connecting to a exit handler event
gdb.events.exited.connect(exit_handler)
# Connecting to a stop signal event
gdb.events.stop.connect(set_event)
#gdb.events.cont.connect(set_event_cont)
#gdb.execute("file ~/rodinia_3.1/cuda/lud/cuda/lud_cuda")
#gdb.execute("set arg -s 10000")
#gdb.execute("break lud_cuda")
t0=time.time()
print (t0)
pillo=t0
gdb.execute("file codes/mmElem/matrixMul")
gdb.execute("set arg -wA=16384 -hA=16384 -hB=16384 -wB=16384")
#gdb.execute("set cuda break_on_launch application")
bm=gdb.Breakpoint('main')
bp=gdb.Breakpoint('matrixMulCUDA')
#gdb.execute('handle SIGALRM stop')
#gdb.execute('handle SIGALRM ignore')
#gdb.execute('handle SIGALRM')
#gdb.execute('catch signal SIGALRM')
gdb.execute("file codes/lud/cuda/lud_cuda")
gdb.execute("set arg -s 10000")
gdb.execute("set cuda break_on_launch application")
gdb.execute('r')
#selectrd()
a=gdb.execute ("info proc", to_string=True).splitlines()[0].split(' ')[1]
print("Process:{}".format(a))
print ("1")
gdb.execute("c")
print ("1")
gdb.execute("c")
gdb.execute("c")
gdb.execute("c")
pausealarm()
gdb.execute("c")
gdb.execute("c")
#nosalir=True
# while nosalir:
# gdb.execute("finish")
# gdb.execute("c")"
print (" Ocurrencias "+str(ocurrencias)+" Tiempo acumulado de ejecucciones "+ str(trun))
f=open("tmpxxx_return_profiler.conf","w")
f.write("Ocurrencias ="+str(ocurrencias)+"\n Tiempo "+str(trun)+"\n")
f.close()
nosalir=True
gdb.events.stop.disconnect(set_event)
g=Logging(log_file="ludv2.conf")
# Force a create un object, don't care arguments
bf = BitFlip(bits_to_flip=27, fault_model=0,max_regs=18,
logging=g, injection_site=cp.INJECTION_SITES["INST_OUT"])
bf.analisis(["lud_diagonal", "lud_perimeter","lud_internal"])
main()
......
import gdb
import os
import time
import re
import sys
import copy
import common_functions as cf
from classes.BitFlip import BitFlip
......@@ -60,35 +61,56 @@ def main():
# gdb_init_strings = str(os.environ["CAROL_FI_INFO"])
gdb_init_strings = arg0
cadena=gdb_init_strings.split(";",3)
cadena=gdb_init_strings.split(";",4)
print >>sys.stderr, (cadena[0]) #,"-",cadena[0],"-",cadena[1],"-", cadena[2],"#". cadena[3])
print >>sys.stderr, (gdb_init_strings+"---0:"+cadena[0]+"\n-1:"+cadena[1],"\n-2:",cadena[2],"\n-3:", cadena[3],"\n-4:", cadena[4])
section =cadena[0]=="True"
onlycount=cadena[1]=="True"
#print ("B "+section+"ke "+kernel_end+" ....")
#print (cadena[2].split(";"))
for init_str in cadena[3].split(";"):
print (cadena[3].split(";"))
print("INIT_str {}".format(cadena[4].split(";")))
for init_str in cadena[4].split(";"):
gdb.execute(init_str)
maxi=0.
gdb.execute("r")
if (onlycount):
ks=cadena[2].split(",")
print (ks)
#print >>sys.stderr, ("=====================Kernels ")
#print ("=====================Kernels {}".format(cadena[2]))
listreg=set ()
f=open("tmpxxx/kernels.conf","w")
f.write("[Kernels]\n")
print(cadena[2])
f.write("Nombres={}\n".format(cadena[2]))
f.write("trace={}\n".format(cadena[3]))
for x in ks:
listreg.update(BitFlip.numreg(x) )
f.write("[{}] \n".format(x))
nm=BitFlip.numreg(x)
listreg.update(nm)
f.write("Registro={}\n".format(len(nm)))
f.write("Principio={}\n".format(BitFlip.principiokernel(x)))
f.write("Tamano={}\n".format(BitFlip.lenkernel(x)))
f.close()
print(listreg)
maxi=len(listreg)
print("Maximo..."+str (maxi)+" o "+str(max([int(x) for x in listreg] ) ))
#os.system("chmod 444 tmpxxx/kernels.conf")
else:
if (section):
print("Break & continue");
gdb.execute("c")
else:
print("Finish.........");
if( len (cadena[2])==0):
gdb.execute("quit")
else:
gdb.execute("finish")
f=open("tmpxxx_return_profiler.conf","w")
f=open("tmpxxx/return_profiler.conf","w")
f.write("[DEFAULT] \nOcurrencias = "+str(ocurrencias)+"\nTiempo = "+str(trun)+"\n")
f.close()
sys.exit(maxi)
......
......@@ -6,17 +6,30 @@ hang=$[$fi_field + 1]
crash=$[$hang + 1]
masked=$[$crash +1 ]
sdc=$[$masked +1 ]
for i in $fi_field $hang $crash $masked $sdc
for i in $fi_field $crash $sdc
do
cab=$(cut -d, -f$i $1|head -1)
trues=$(cut -d, -f$i $1|grep "True"|wc -l)
campos[$i]=$trues
echo $cab "=" ${campos[$i]}
done
for i in $masked
do
cab=$(cut -d, -f$i $1|head -1)
trues=$(cut -d, -f$hang,$i $1|grep "False,True"|wc -l)
echo $cab "=" $trues
campos[$i]=$trues
done
campos[$masked]=$[campos[$masked]-campos[$hang]]
cab=$(cut -d, -f$hang $1|head -1)
trues=$(cut -d, -f$hang,$crash $1|grep "True,False"|wc -l)
echo $cab "=" $trues
campos[$hang]=$trues
for i in $hang $crash $masked $sdc
do
tantoporcien=$(printf %.3f "$(( campos[$i] * 10**5/campos[$fi_field] ))e-3")
tantoporcien=$(printf %.3f "$(( campos[$i] * 10**5/${campos[$fi_field]} ))e-3")
cab=$(cut -d, -f$i $1|head -1)
echo $cab"(%)="$tantoporcien
done
......
......@@ -18,9 +18,9 @@ date >> tiempos
echo "Step 2 - Running ${FAULTS} on ${CONFFILE}"
./fault_injector.py -i ${FAULTS} -c ${CONFFILE} -n 1 $*
while test -f "tmpxxx_num_rounds.conf"
while test -f "tmpxxx/num_rounds.conf"
do
cat tmpxxx_num_rounds.conf >> tandas
cat tmpxxx/num_rounds.conf >> tmpxxx/tandas
./fault_injector.py -i ${FAULTS} -c ${CONFFILE} -n 1 $*
echo "==============================="
done
......
......@@ -19,9 +19,9 @@ date >> tiempos
echo "Step 2 - Running ${FAULTS} on ${CONFFILE}"
./fault_injector.py -i ${FAULTS} -c ${CONFFILE} -n 1 $*
while test -f "tmpxxx_num_rounds.conf"
while test -f "tmpxxx/num_rounds.conf"
do
cat tmpxxx_num_rounds.conf >> tandas
cat tmpxxx/num_rounds.conf >> tmpxxx/tandas
./fault_injector.py -i ${FAULTS} -c ${CONFFILE} -n 1 $*
echo "==============================="
done
......
......@@ -20,9 +20,9 @@ echo "Step 2 - Running ${FAULTS} on ${CONFFILE}"
echo $?
while test -f "tmpxxx_num_rounds.conf"
while test -f "tmpxxx/num_rounds.conf"
do
cat tmpxxx_num_rounds.conf >> tandas
cat tmpxxx/num_rounds.conf >> tmpxxx/tandas
./fault_injector.py -i ${FAULTS} -c ${CONFFILE} -n 1 $*
echo "==============================="
done
......
......@@ -18,9 +18,9 @@ echo "Step 2 - Running ${FAULTS} on ${CONFFILE}"
./fault_injector.py -i ${FAULTS} -c ${CONFFILE} -n 1 $*
echo $?
while test -f "tmpxxx_num_rounds.conf"
while test -f "tmpxxx/num_rounds.conf"
do
cat tmpxxx_num_rounds.conf >> tandas
cat tmpxxx/num_rounds.conf >> tmpxxx/tandas
./fault_injector.py -i ${FAULTS} -c ${CONFFILE} -n 1 $*
echo "==============================="
done
......
......@@ -20,9 +20,9 @@ echo "Step 2 - Running ${FAULTS} on ${CONFFILE}"
./fault_injector.py -i ${FAULTS} -c ${CONFFILE} -n 1 $*
while test -f "tmpxxx_num_rounds.conf"
while test -f "tmpxxx/num_rounds.conf"
do
cat tmpxxx_num_rounds.conf >> tandas
cat tmpxxx/num_rounds.conf >> tmpxxx/tandas
./fault_injector.py -i ${FAULTS} -c ${CONFFILE} -n 1 $*
echo "==============================="
done
......
......@@ -5,21 +5,21 @@ set -e
#uncomment to a more verbose script
#set -x
DIR_RODINIA=codes
FAULTS=1000
FAULTS=3000
#CONFFILE=codes/matrixMul/matrixmul_16K.conf
#CONFFILE=codes/mmElem/matrixmul_16K.conf
#CONFFILE=codes/lavaMD/lavaMD.conf
CONFFILE=$DIR_RODINIA/lud/lud.conf
CONFFILE=$DIR_RODINIA/lud/lud2k.conf
echo "Step 1 - Profiling the application for fault injection"
./app_profiler.py -c ${CONFFILE} $*
echo "Step 2 - Running ${FAULTS} on ${CONFFILE}"
./fault_injector.py -i ${FAULTS} -c ${CONFFILE} -n 1 $*
while test -f "tmpxxx_num_rounds.conf"
while test -f "./tmpxxx/num_rounds.conf"
do
cat tmpxxx_num_rounds.conf >> tandas
cat tmpxxx/num_rounds.conf >> tmpxxx/tandas
./fault_injector.py -i ${FAULTS} -c ${CONFFILE} -n 1 $*
echo "==============================="
done
......
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