Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
German Leon
Carol-fi
Commits
a8fc9678
Commit
a8fc9678
authored
Dec 18, 2020
by
German Leon
Browse files
Cambios cruzados
parent
b7e5ba94
Changes
4
Hide whitespace changes
Inline
Side-by-side
app_profiler.py
View file @
a8fc9678
...
@@ -42,14 +42,23 @@ Function that calls the profiler based on the injection mode
...
@@ -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
,
kernel
s
,
benchmark_binary
,
benchmark_args
,
device
,
section
):
acc_time
=
0
acc_time
=
0
acc_time_profiler
=
0
acc_time_profiler
=
0
script
=
'env CUDA_VISIBLE_DEVICES={} {} -ex
\'
py arg0 = {}
\'
-n -batch -x {}'
script
=
'env CUDA_VISIBLE_DEVICES={} {} -ex
\'
py arg0 = {}
\'
-n -batch -x {}'
benchmark_args_striped
=
benchmark_args
.
replace
(
'
\\
n'
,
''
).
replace
(
'
\\
'
,
''
)
benchmark_args_striped
=
benchmark_args
.
replace
(
'
\\
n'
,
''
).
replace
(
'
\\
'
,
''
)
print
(
"KERNEL"
+
kernel
)
#
print ("KERNEL"+kernel
s
)
#init_string = '"file {}; set args {}"'.format(benchmark_binary, benchmark_args_striped)
#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
)
profiler_cmd
=
script
.
format
(
device
,
gdb_exec
,
init_string
,
cp
.
PROFILER_SCRIPT
)
print
(
"Profiler caller"
)
print
(
"Profiler caller"
)
if
cp
.
DEBUG
:
if
cp
.
DEBUG
:
...
@@ -64,7 +73,7 @@ def profiler_caller(gdb_exec, kernel, benchmark_binary, benchmark_args,device,se
...
@@ -64,7 +73,7 @@ def profiler_caller(gdb_exec, kernel, benchmark_binary, benchmark_args,device,se
acc_time
+=
end
-
start
acc_time
+=
end
-
start
cf
.
kill_all
(
"killall -9 {}; killall -9 {}"
.
format
(
cf
.
kill_all
(
"killall -9 {}; killall -9 {}"
.
format
(
os
.
path
.
basename
(
gdb_exec
),
os
.
path
.
basename
(
benchmark_binary
)))
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):
...
@@ -81,7 +90,7 @@ def generate_gold(gdb_exec, benchmark_binary, benchmark_args,device):
os
.
system
(
"rm -rf "
+
tmp_path
+
"/*"
)
os
.
system
(
"rm -rf "
+
tmp_path
+
"/*"
)
script
=
'env CUDA_VISIBLE_DEVICES={} {} -ex
\'
py arg0 = {}
\'
-n -batch -x {} > {} 2> {}'
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
)
profiler_cmd
=
script
.
format
(
device
,
gdb_exec
,
init_string
,
cp
.
PROFILER_SCRIPT
,
cp
.
GOLD_OUTPUT_PATH
,
cp
.
GOLD_ERR_PATH
)
if
cp
.
DEBUG
:
if
cp
.
DEBUG
:
print
(
"PROFILER CMD: {}"
.
format
(
profiler_cmd
))
print
(
"PROFILER CMD: {}"
.
format
(
profiler_cmd
))
...
@@ -118,28 +127,29 @@ def main():
...
@@ -118,28 +127,29 @@ def main():
benchmark_args
=
conf
.
get
(
'DEFAULT'
,
'benchmarkArgs_noverificar'
)
benchmark_args
=
conf
.
get
(
'DEFAULT'
,
'benchmarkArgs_noverificar'
)
else
:
else
:
benchmark_args
=
conf
.
get
(
'DEFAULT'
,
'benchmarkArgs'
)
benchmark_args
=
conf
.
get
(
'DEFAULT'
,
'benchmarkArgs'
)
section
=
'kernel_end'
in
conf
[
'DEFAULT'
]
kernel_end
=
''
section
=
{}
if
(
section
):
if
(
'section_end'
in
conf
[
'DEFAULT'
]):
kernel_end
=
conf
.
get
(
'DEFAULT'
,
'kernel_end'
)
section
[
'begin'
]
=
conf
.
get
(
'DEFAULT'
,
'section_begin'
)
section
[
'end'
]
=
conf
.
get
(
'DEFAULT'
,
'section_end'
)
gdb_exec
=
conf
.
get
(
"DEFAULT"
,
"gdbExecName"
)
gdb_exec
=
conf
.
get
(
"DEFAULT"
,
"gdbExecName"
)
kernel
=
conf
.
get
(
'DEFAULT'
,
'kernel'
)
kernel
s
=
conf
.
get
(
'DEFAULT'
,
'kernel
s
'
)
[
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
)
[
max_time_kernel
,
max_time_app
,
max_regs
]
=
profiler_caller
(
gdb_exec
=
gdb_exec
,
kernel
s
=
kernel
s
,
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
))
print
(
"Time kernel= "
+
str
(
max_time_kernel
)
+
"Time app "
+
str
(
max_time_app
))
# saving gold
# saving gold
print
(
"Saving gold"
);
print
(
"Saving gold"
);
#
generate_gold_result = generate_gold(gdb_exec=gdb_exec,
generate_gold_result
=
generate_gold
(
gdb_exec
=
gdb_exec
,
#
benchmark_binary=benchmark_binary, benchmark_args=benchmark_args,device=args.device)
benchmark_binary
=
benchmark_binary
,
benchmark_args
=
benchmark_args
,
device
=
args
.
device
)
#
if generate_gold_result != 0:
if
generate_gold_result
!=
0
:
#
raise EnvironmentError("Gold generation did not finish well, the fault injection will not work")
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
# 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_OUTPUT_PATH
)
cf
.
remove_useless_information_from_output
(
cp
.
GOLD_ERR_PATH
)
cf
.
remove_useless_information_from_output
(
cp
.
GOLD_ERR_PATH
)
# Save the kernel configuration txt file
# 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
###################################################"
)
print
(
"1 - Profile finished
\n
###################################################"
)
...
...
codes/mmElem/matrixmul.conf
View file @
a8fc9678
...
@@ -17,7 +17,7 @@ faultModel = 0
...
@@ -17,7 +17,7 @@ faultModel = 0
# RF -> Register File
# RF -> Register File
# INST_OUT -> Instruction Output (NOT IMPLEMENTED YET)
# INST_OUT -> Instruction Output (NOT IMPLEMENTED YET)
# INST_composed -> Instruction Adress (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
# 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
# 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
# Considered as a crash is 10s
...
@@ -42,6 +42,6 @@ seqSignals = 20
...
@@ -42,6 +42,6 @@ seqSignals = 20
# Initial sleep time in seconds before start sending signals
# Initial sleep time in seconds before start sending signals
# Generally the memory setup time
# Generally the memory setup time
initSleep
=
2
.
1
initSleep
=
2
.
1
#
kernel = matrixMulCUDA
kernel
s
=
matrixMulCUDA
kernel
=
matrixMul
.
cu
:
205
section_begin
=
matrixMul
.
cu
:
205
kernel
_end
=
matrixMul
.
cu
:
217
section
_end
=
matrixMul
.
cu
:
217
fault_injector.py
View file @
a8fc9678
...
@@ -300,6 +300,7 @@ def check_injection_outcome(host_thread, logging, injection_site):
...
@@ -300,6 +300,7 @@ def check_injection_outcome(host_thread, logging, injection_site):
# if fault was injected ASSM_LINE MUST be in the logfile
# if fault was injected ASSM_LINE MUST be in the logfile
assm_line
=
logging
.
search
(
"ASSM_LINE"
)
assm_line
=
logging
.
search
(
"ASSM_LINE"
)
instruction
=
re
.
match
(
r
".*:\t(\S+) .*"
,
assm_line
).
group
(
1
)
instruction
=
re
.
match
(
r
".*:\t(\S+) .*"
,
assm_line
).
group
(
1
)
instruction
=
assm_line
except
TypeError
as
te
:
except
TypeError
as
te
:
instruction
=
new_value
=
old_value
=
None
instruction
=
new_value
=
old_value
=
None
...
@@ -701,7 +702,7 @@ def main():
...
@@ -701,7 +702,7 @@ def main():
'current_path'
:
current_path
,
'current_path'
:
current_path
,
'seq_signals'
:
int
(
conf
.
get
(
'DEFAULT'
,
'seqSignals'
)),
'seq_signals'
:
int
(
conf
.
get
(
'DEFAULT'
,
'seqSignals'
)),
'init_sleep'
:
float
(
conf
.
get
(
'DEFAULT'
,
'initSleep'
)),
'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'
)),
'gold_check_script'
:
"{}/{}"
.
format
(
current_path
,
conf
.
get
(
'DEFAULT'
,
'goldenCheckScript'
)),
'summary_file'
:
summary_file
,
'summary_file'
:
summary_file
,
'header'
:
fieldnames
'header'
:
fieldnames
...
@@ -718,7 +719,7 @@ def main():
...
@@ -718,7 +719,7 @@ def main():
for
thread
in
gpus_threads
:
for
thread
in
gpus_threads
:
thread
.
join
()
thread
.
join
()
ret
+=
thread
.
exit_code
#
ret += thread.exit_code
os
.
system
(
"rm -f {}/bin/*"
.
format
(
current_path
))
os
.
system
(
"rm -f {}/bin/*"
.
format
(
current_path
))
if
exit_injector
:
if
exit_injector
:
...
...
profiler_new.py
View file @
a8fc9678
import
gdb
import
gdb
import
time
import
time
import
re
import
sys
import
common_functions
as
cf
def
exit_handler
(
event
):
def
exit_handler
(
event
):
global
nosalir
global
nosalir
...
@@ -16,9 +19,40 @@ def exit_handler(event):
...
@@ -16,9 +19,40 @@ def exit_handler(event):
Handler that will put a breakpoint on the kernel after
Handler that will put a breakpoint on the kernel after
signal
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
):
def
set_event
(
event
):
global
trun
,
ocurrencias
,
t
,
primera
global
trun
,
ocurrencias
,
t
,
primera
...
@@ -58,37 +92,29 @@ def main():
...
@@ -58,37 +92,29 @@ def main():
# gdb_init_strings = str(os.environ["CAROL_FI_INFO"])
# gdb_init_strings = str(os.environ["CAROL_FI_INFO"])
gdb_init_strings
=
arg0
gdb_init_strings
=
arg0
cadena
=
gdb_init_strings
.
split
(
";"
,
2
)
cadena
=
gdb_init_strings
.
split
(
";"
,
3
)
#print (cadena,"-",cadena[0],'-',cadena[1],'-', cadena[2])
print
>>
sys
.
stderr
,
(
cadena
[
0
])
#,"-",cadena[0],"-",cadena[1],"-", cadena[2],"#". cadena[3])
section
=
cadena
[
0
]
==
"True"
section
=
cadena
[
0
]
==
"True"
kernel_end
=
cadena
[
1
]
onlycount
=
cadena
[
1
]
==
"True"
#print ("B "+section+"ke "+kernel_end+" ....")
#print ("B "+section+"ke "+kernel_end+" ....")
#print (cadena[2].split(";"))
#print (cadena[2].split(";"))
for
init_str
in
cadena
[
2
].
split
(
";"
):
for
init_str
in
cadena
[
3
].
split
(
";"
):
gdb
.
execute
(
init_str
)
gdb
.
execute
(
init_str
)
if
(
section
):
max
=
0.
gdb
.
execute
(
"break "
+
kernel_end
)
gdb
.
execute
(
"r"
)
gdb
.
execute
(
"r"
)
if
(
onlycount
):
#nosalir=True
ks
=
cadena
[
2
].
split
(
","
,
1
)
#while nosalir:
max
=
numreg
(
ks
[
0
])
if
(
section
):
#print ("Point 1")
gdb
.
execute
(
"c"
)
else
:
else
:
gdb
.
execute
(
"finish"
)
if
(
section
):
#print ("Punto 2
")
gdb
.
execute
(
"c
"
)
#print (" Ocurrencias "+str(ocurrencias)+" Tiempo acumulado de ejecucciones "+ str(trun)+ "\n")
else
:
gdb
.
execute
(
"
c
"
)
gdb
.
execute
(
"
finish
"
)
#print (" Ocurrencias "+str(ocurrencias)+" Tiempo acumulado de ejecucciones "+ str(trun))
f
=
open
(
"tmpxxx_return_profiler.conf"
,
"w"
)
f
=
open
(
"tmpxxx_return_profiler.conf"
,
"w"
)
f
.
write
(
"[DEFAULT]
\n
Ocurrencias = "
+
str
(
ocurrencias
)
+
"
\n
Tiempo = "
+
str
(
trun
)
+
"
\n
"
)
f
.
write
(
"[DEFAULT]
\n
Ocurrencias = "
+
str
(
ocurrencias
)
+
"
\n
Tiempo = "
+
str
(
trun
)
+
"
\n
"
)
f
.
close
()
f
.
close
()
sys
.
exit
(
max
)
#print ("End write file \n")
#sys.stdout.flush()
main
()
main
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment