Commit 707781af authored by German Leon's avatar German Leon
Browse files

Por si falta algun detallito

parent b5431069
......@@ -101,13 +101,16 @@ def generate_gold(gdb_exec, benchmark_binary, benchmark_args,device):
def main():
os.system("rm -f {}".format(cp.KERNEL_INFO_DIR))
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--conf', dest="config_file", help='Configuration file', required=True)
parser.add_argument('-d', '--device', dest="device", help="The GPU to perform FI."
" Default is 0.", required=False, default=0, type=int)
args = parser.parse_args()
if (args.device>0):
cp.LOGS_PATH=cp.LOGS_PATH+"-"+str(args.device)
cp.rewrite_path()
os.system("rm -f {}".format(cp.KERNEL_INFO_DIR))
# Read the configuration file with data for all the apps that will be executed
conf = cf.load_config_file(args.config_file)
......
......@@ -38,30 +38,22 @@ class BitFlip:
def numreg (kernel):
try:
disassemble_array = cf.execute_command(gdb=gdb, to_execute="disassemble {}".format(kernel))
print ("kenel={}".format(kernel))
#print ("kenel={}".format(kernel))
except:
print("SIN NOmbre")
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)
#m=re.match(r".*:\t(\S+) .*",line)#Para que es m
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)
......@@ -75,13 +67,16 @@ class BitFlip:
"""
def asmline(self):
#Leo la linea de ejecucion
return cf.execute_command(gdb=gdb, to_execute="x/1i $pc")
linea=cf.execute_command(gdb=gdb, to_execute="x/1i $pc")
self.__logging.info("ASSM_LINE:{}".format(linea[0]))
return linea
def reg_asmline( self):
#Obtengo los registros de la instruccion
linea= self.asmline()
self.__assmline="ASSM_LINE:{}".format(linea[0])
#print (linea)#+"-"+str(len(linea))+"-"+linea[0])
#print ("============")
lista=re.findall(r"R(\d+)", linea[0])
#Ahora son todos los registros.
......@@ -89,8 +84,11 @@ class BitFlip:
setlista=set()
setlista.update(lista)
#self.__logging.info(str(len(setlista)))
return setlista
def regmod (self):
lista=self.reg_asmline()
while len(lista) == 0: #Habria que poner un limite.
......@@ -102,9 +100,9 @@ class BitFlip:
strlistareg="info registers "
for x in listareg:
strlistareg+=x;
#print (strlistareg)
self.__stringregs=strlistareg
#self.__logging.info("REFERED REGISTERS :"+strlistareg)
#Obtengo el valor de los registro referenciados
valores= cf.execute_command(gdb=gdb, to_execute=strlistareg)
return valores
......@@ -112,11 +110,12 @@ class BitFlip:
#Obtengo el valor de los registro referenciados por la primera instruccipn
#self.__logging.info("===============================")
gdb.execute("nexti")
#self.__logging.info("==============================="+self.__stringregs)
linea= self.asmline()
#self.__logging.info("ASSM_LINE:{}".format(linea))
valores= cf.execute_command(gdb=gdb, to_execute=self.__stringregs)
return valores
def dictreg(self,valores):
#self.__logging.info("Execute dictreg")
#Almaceno en un dictionario los valores de los registros
......@@ -126,18 +125,11 @@ class BitFlip:
m = re.match(r".*R(\d+).*0x([0-9a-fA-F]+).*", x)
if m:
regs[m.group(1)]=m.group(2)
#print (str(m.group(1))+":= "+str(m.group(2)))
#print(regs)
#print ("========DR")
return regs
def cmpregdst (self,valores,regs):
#Comparo los regsitros, para saber cuales he modificado.
#self.__logging.info("Execute cmpregdst------------")#+str(type(valores)))
regdst=set()
#print("==cmpregdst")
#print("Arg;..valores...")
#print(type(valores))
#print (valores)
for x in valores:
......@@ -150,14 +142,13 @@ class BitFlip:
#self.__logging.info(str(len(regdst)))
return regdst
def __inst_generic_injector(self):
#def miinst_out():
#self.__logging.info("Comienzo")
regs=self.dictreg(self.regmod())
#self.__logging.info("Reg1")
valores=self.nextinstr()
#self.__logging.info("Ejecutado sfte instuccion")
r=self.cmpregdst(valores,regs)
#self.__logging.info("Se han modificado {}".format(len(r)))
while (len(r) ==0):
self.__logging.info("INSTRUCTION WITHOUT OPERANDS")
gdb.execute("nexti")
......@@ -167,7 +158,7 @@ class BitFlip:
self.__register="R{}".format(r.pop())
self.__logging.info("SELECTED_REGISTER:{}".format(self.__register))
self.__logging.info("ASSM_LINE:{}".format(self.__assmline))
# __rf_generic_injector will set fault_injected attribute
self.__rf_generic_injector()
......@@ -265,6 +256,7 @@ class BitFlip:
def __rf_generic_injector(self):
try:
# get register content
self.asmline()
reg_cmd = cf.execute_command(gdb, "p/t ${}".format(self.__register))
m = re.match(r'\$(\d+)[ ]*=[ ]*(\S+).*', reg_cmd[0])
......
......@@ -26,20 +26,20 @@ maxWaitTimes = 5
# binary file of the application
# Must be full path
benchmarkBinary = /home/badia/rodinia_3.1/cuda/hotspot/hotspot
benchmarkBinary = /home/badia/mycarol-fi/codes/hotspot/hotspot
#benchmarkBinary_noverificar = /home/badia/rodinia_3.1/cuda/lavaMD/lavaMD
# Commands to set the session inside GDB environment
benchmarkArgs = 1024 2 10000 /home/badia/rodinia_3.1/data/hotspot/temp_1024 /home/badia/rodinia_3.1//data/hotspot/power_1024 output.out
benchmarkArgs = 2 10000 /home/badia/mycarol-fi/data/hotspot/temp_1024 /home/badia/mycarol-fi/data/hotspot/power_1024 output.out
#benchmarkArgs = 16384 2 2 /home/badia/rodinia_3.1/data/hotspot/temp_16384 /home/badia/rodinia_3.1/data/hotspot/power_16384 output.out
benchmarkArgs_noverificar = 1024 2 10000 /home/badia/rodinia_3.1/data/hotspot/temp_1024 /home/badia/rodinia_3.1/data/hotspot/power_1024 output.out
benchmarkArgs_noverificar = 1024 2 10000 /home/badia/mycarol-fi/data/hotspot/temp_1024 /home/badia/mycarol-fi/data/hotspot/power_1024 output.out
#benchmarkArgs_noverificar = 16384 2 2 /home/badia/rodinia_3.1/data/hotspot/temp_16384 /home/badia/rodinia_3.1/data/hotspot/power_16384 .
# CSV output file. It will be overwrite at each injection
csvFile = results/hotspot_RF.csv
# You should create a script on the benchmark source folder to verify GOLD_OUTPUT x INJ_OUTPUT
goldenCheckScript = ../rodinia_3.1/cuda/hotspot/sdc_check.sh
goldenCheckScript = codes/hotspot/sdc_check.sh
# Number of signals that will be sent to the application
seqSignals = 2
......
......@@ -18,8 +18,8 @@ faultModel = 0
# INST_OUT -> Instruction Output (NOT IMPLEMENTED YET)
# INST_composed -> Instruction Adress (NOT IMPLEMENTED YET)
injectionSite = RF
#injectionSite = INST_OUT
#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
......
......@@ -17,7 +17,7 @@ faultModel = 0
# RF -> Register File
# INST_OUT -> Instruction Output (NOT IMPLEMENTED YET)
# INST_composed -> Instruction Adress (NOT IMPLEMENTED YET)
injectionSite = INST_OUT
injectionSite = RF
# 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
......@@ -26,9 +26,9 @@ maxWaitTimes = 5
# binary file of the application
# Must be full path
benchmarkBinary = /home/badia/rodinia_3.1/cuda/nw/needle
benchmarkBinary = /home/badia/mycarol-fi/codes/nw/needle
benchmarkBinary_noverificar = /home/badia/rodinia_3.1/cuda/nw/needle_MUDO
benchmarkBinary_noverificar = /home/badia/mycarol-fi/codes/nw/needle_MUDO
#benchmarkBinary_noverificar = /home/badia/rodinia_3.1/cuda/lavaMD/lavaMD
# Commands to set the session inside GDB environment
......@@ -37,10 +37,10 @@ benchmarkArgs = 32000 1
#benchmarkArgs_noverificar = -s 2048
# CSV output file. It will be overwrite at each injection
csvFile = /home/badia/rodinia_3.1/cuda/nw/fi_nw_single_bit.csv
csvFile = results/nw_RF.csv
# You should create a script on the benchmark source folder to verify GOLD_OUTPUT x INJ_OUTPUT
goldenCheckScript = ../rodinia_3.1/cuda/nw/sdc_check.sh
goldenCheckScript = codes/nw/sdc_check.sh
# Number of signals that will be sent to the application
seqSignals = 2
......
......@@ -9,7 +9,6 @@
# are environment variables defined by the fault_injector.py
# diff stdout
diff -B ${INJ_OUTPUT_PATH} ${GOLD_OUTPUT_PATH} > ${DIFF_LOG}
# Special comparison like the following one can be done in this script
grep -q "Result = FAIL" ${INJ_OUTPUT_PATH} >> ${DIFF_LOG}
......@@ -18,9 +17,9 @@ grep -q "Result = FAIL" ${INJ_OUTPUT_PATH} >> ${DIFF_LOG}
diff -B ${INJ_ERR_PATH} ${GOLD_ERR_PATH} > ${DIFF_ERR_LOG}
echo $pwd
ls -l result*
diff ./result.txt ~/rodinia_3.1/cuda/nw/gold/result.1.txt >> ${INJ_OUTPUT_PATH}
diff ./result.txt codes/nw/gold/result.1.txt >> ${INJ_OUTPUT_PATH}
diff ./result.txt ~/rodinia_3.1/cuda/nw/gold/result.1.txt #>> ${INJ_OUTPUT_PATH}
#diff ./result.txt ~/rodinia_3.1/cuda/nw/gold/result.1.txt #>> ${INJ_OUTPUT_PATH}
if [ $? -ne 0 ]
then
echo "Result = FAIL" >> ${INJ_OUTPUT_PATH}
......@@ -29,4 +28,6 @@ else
fi
rm result.txt
# Must exit 0
p
diff -B ${INJ_OUTPUT_PATH} ${GOLD_OUTPUT_PATH} > ${DIFF_LOG}
exit 0
......@@ -9,24 +9,11 @@ MAX_TIMES_TO_PROFILE = 2
# Log path to store all injections info
LOGS_PATH = 'logs'
# Temporary file to store kernel information
KERNEL_INFO_DIR = LOGS_PATH + '/tmp/carol-fi-kernel-info.txt'
# For golden generation
GOLD_ERR_PATH = LOGS_PATH + '/tmp/carol_fi_golden_bench_err.txt'
GOLD_OUTPUT_PATH = LOGS_PATH + '/tmp/carol_fi_golden_bench_output.txt'
# Files that will be compared to golden ones
INJ_OUTPUT_PATH = LOGS_PATH + '/tmp/carol_fi_inj_bench_output_{}.txt'
INJ_ERR_PATH = LOGS_PATH + '/tmp/carol_fi_inj_bench_err_{}.txt'
# Internal python scripts
FLIP_SCRIPT = 'flip_value.py'
PROFILER_SCRIPT = 'profiler.py'
# Temporary difference logs
DIFF_LOG = LOGS_PATH + '/tmp/diff_{}.log'
DIFF_ERR_LOG = LOGS_PATH + '/tmp/diff_err_{}.log'
# Debug env vars
# Debug FI process
......@@ -34,14 +21,12 @@ DEBUG = True
# Debug profiler process
DEBUG_PROFILER = True
# Log file for SignalApp thread
SIGNAL_APP_LOG = LOGS_PATH + '/tmp/signal_app_thread_{}.txt'
# Num of sleep time divisor
NUM_DIVISION_TIMES = 100.0
# Common body of log filename
LOG_DEFAULT_NAME = LOGS_PATH + '/tmp/carolfi-flipvalue-{}.log'
# MAX INT 32 bits
......@@ -110,3 +95,30 @@ LEAST_8_BITS = 5
# Focus error string
FOCUS_ERROR_STRING = "Focus not set on any active CUDA kernel."
def rewrite_path():
# Temporary file to store kernel information
global KERNEL_INFO_DIR,GOLD_ERR_PATH,GOLD_OUTPUT_PATH,INJ_OUTPUT_PATH,INJ_ERR_PATH,DIFF_LOG,DIFF_ERR_LOG, SIGNAL_APP_LOG, LOG_DEFAULT_NAME
KERNEL_INFO_DIR = LOGS_PATH + '/tmp/carol-fi-kernel-info.txt'
# For golden generation
GOLD_ERR_PATH = LOGS_PATH + '/tmp/carol_fi_golden_bench_err.txt'
GOLD_OUTPUT_PATH = LOGS_PATH + '/tmp/carol_fi_golden_bench_output.txt'
# Files that will be compared to golden ones
INJ_OUTPUT_PATH = LOGS_PATH + '/tmp/carol_fi_inj_bench_output_{}.txt'
INJ_ERR_PATH = LOGS_PATH + '/tmp/carol_fi_inj_bench_err_{}.txt'
# Temporary difference logs
DIFF_LOG = LOGS_PATH + '/tmp/diff_{}.log'
DIFF_ERR_LOG = LOGS_PATH + '/tmp/diff_err_{}.log'
SIGNAL_APP_LOG = LOGS_PATH + '/tmp/signal_app_thread_{}.txt'
# Common body of log filename
LOG_DEFAULT_NAME = LOGS_PATH + '/tmp/carolfi-flipvalue-{}.log'
......@@ -69,6 +69,7 @@ def signal_handler(sig, frame):
os.system(cmd + " > /dev/null 2>&1")
os.system("rm -f {}/bin/*".format(current_path))
print("Current_path "+current_path)
for th in gpus_threads:
th.join()
#sys.exit(0)
......@@ -309,19 +310,26 @@ def check_injection_outcome(host_thread, logging, injection_site):
# Check specific outcomes
# No need to process for RF
instruction = 'register'
assm_line = logging.search("ASSM_LINE")
dpc={}
dpc['absoluto']="0x"+re.match(r".*0x([0-9a-fA-F]+) <.*",assm_line).group(1)
dpc['relativo']=assm_line.split('<')[1].split('>')[0]
print("---PC: "+dpc['absoluto']+ "PC rel"+dpc['relativo'])
pc=dpc['absoluto']+"<"+dpc['relativo']+">"
if cp.INJECTION_SITES[injection_site] in [cp.INST_OUT, cp.INST_ADD]:
# 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
pc = instruction
fi_successful = False
if cp.DEBUG:
cf.printf("THREAD {} FAULT WAS NOT INJECTED. ERROR {}".format(host_thread, te))
return block, fi_successful, new_value, old_value, register, thread, instruction
return block, fi_successful, new_value, old_value, register, thread, instruction, pc
"""
Function to run one execution of the fault injector
return old register value, new register value
......@@ -444,7 +452,7 @@ def gdb_inject_fault(**kwargs):
# Check if the carolfi logfile contains the information
# to confirm the fault injection outcome
block, fi_successful, new_value, old_value, register, thread, instruction = check_injection_outcome(
block, fi_successful, new_value, old_value, register, thread, instruction,pc = check_injection_outcome(
host_thread=host_thread,
logging=logging,
injection_site=injection_site
......@@ -460,7 +468,7 @@ def gdb_inject_fault(**kwargs):
cf.printf("THREAD {} SAVE OUTPUT AND RETURN".format(host_thread))
return_list = [register, old_value, new_value, fi_successful,
is_hang, is_crash, is_sdc, is_masked, signal_init_wait_time, block, thread, instruction, user_defined_string]
is_hang, is_crash, is_sdc, is_masked, signal_init_wait_time, block, thread, instruction, pc, user_defined_string]
return return_list
......@@ -580,7 +588,7 @@ def fault_injection_by_signal(**kwargs):
fi_tic = int(time.time())
[register, old_val, new_val, fault_injected,
hang, crash, masked,sdc, signal_init_time, block,
thread, instruction, user_defined_val] = gdb_inject_fault(**kwargs)
thread, instruction, pc, user_defined_val] = gdb_inject_fault(**kwargs)
# Time toc
......@@ -596,7 +604,7 @@ def fault_injection_by_signal(**kwargs):
row = [unique_id, register, num_rounds, fault_model, thread,
block, old_val, new_val, injection_site,
fault_injected, hang, crash[0], sdc, masked ,tmp,injection_time,
signal_init_time, bits_to_flip, instruction, user_defined_val]
signal_init_time, bits_to_flip, instruction, pc, user_defined_val]
if fault_injected:
# output_str = "THREAD:{}, FAULT NUM:{}".format(host_thread, num_rounds)
......@@ -662,6 +670,9 @@ def main():
args = parser.parse_args()
if args.iterations < 1:
parser.error('Iterations must be greater than zero')
if (args.device>0):
cp.LOGS_PATH=cp.LOGS_PATH+"-"+str(args.device)
cp.rewrite_path()
# Start with a different seed every time to vary the random numbers generated
# the seed will be the current number of second since 01/01/70
......@@ -689,7 +700,7 @@ def main():
# Csv log
fieldnames = ['unique_id', 'register', 'iteration', 'fault_model', 'thread', 'block', 'old_value',
'new_value', 'inj_site', 'fault_successful', 'hang', 'crash', 'masked', 'sdc', 'Exception','time',
'inj_time_location', 'bits_flipped', 'instruction', 'user_defined']
'inj_time_location', 'bits_flipped', 'instruction', 'pc', 'user_defined']
if os.path.exists("tmpxxx_num_rounds.conf"):
mode='a'
......
......@@ -5,7 +5,7 @@ set -e
#uncomment to a more verbose script
#set -x
FAULTS=1000
FAULTS=10
#CONFFILE=codes/matrixMul/matrixmul_16K.conf
#CONFFILE=codes/mmElem/matrixmul_16K.conf
......@@ -28,4 +28,4 @@ done
echo "Fault injection finished"
date >> tiempos
echo "Fin..." >> tiempos
exit 0
exit
......@@ -4,8 +4,8 @@ set -e
#uncomment to a more verbose script
#set -x
DIR_RODINIA=$HOME/rodinia_3.1/cuda
FAULTS=1000
DIR_RODINIA=codes
FAULTS=100
#CONFFILE=codes/matrixMul/matrixmul_16K.conf
#CONFFILE=codes/mmElem/matrixmul_16K.conf
......
......@@ -4,8 +4,9 @@ set -e
#uncomment to a more verbose script
#set -x
DIR_RODINIA=$HOME/rodinia_3.1/cuda
FAULTS=1000
#DIR_RODINIA=$HOME/rodinia_3.1/cuda
DIR_RODINIA=codes
FAULTS=100
#CONFFILE=codes/matrixMul/matrixmul_16K.conf
#CONFFILE=codes/mmElem/matrixmul_16K.conf
......
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