util: add m5_fail op.

Used as a command in full-system scripts helps the user ensure the benchmarks have finished successfully.

For example, one can use:

    /path/to/benchmark args || /sbin/m5 fail 1

and thus ensure gem5 will exit with an error if the benchmark fails.
This commit is contained in:
Lluís Vilanova 2013-01-08 08:54:12 -05:00
parent 858d99b7cc
commit 807168a1de
8 changed files with 27 additions and 0 deletions

View file

@ -27,6 +27,7 @@
#
# Authors: Lisa Hsu
import sys
from os import getcwd
from os.path import join as joinpath
@ -505,3 +506,5 @@ def run(options, root, testsys, cpu_class):
print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_cause)
if options.checkpoint_at_end:
m5.checkpoint(joinpath(cptdir, "cpt.%d"))
sys.exit(exit_event.getCode())

View file

@ -157,6 +157,9 @@
0x21: m5exit({{
PseudoInst::m5exit(xc->tcBase(), Rdi);
}}, IsNonSpeculative);
0x22: m5fail({{
PseudoInst::m5fail(xc->tcBase(), Rdi, Rsi);
}}, IsNonSpeculative);
0x30: m5initparam({{
Rax = PseudoInst::initParam(xc->tcBase());
}}, IsNonSpeculative);

View file

@ -218,6 +218,13 @@ m5exit(ThreadContext *tc, Tick delay)
exitSimLoop("m5_exit instruction encountered", 0, when);
}
void
m5fail(ThreadContext *tc, Tick delay, uint64_t code)
{
Tick when = curTick() + delay * SimClock::Int::ns;
exitSimLoop("m5_fail instruction encountered", code, when);
}
void
loadsymbol(ThreadContext *tc)
{

View file

@ -54,6 +54,7 @@ uint64_t initParam(ThreadContext *xc);
uint64_t rpns(ThreadContext *tc);
void wakeCPU(ThreadContext *tc, uint64_t cpuid);
void m5exit(ThreadContext *tc, Tick delay);
void m5fail(ThreadContext *tc, Tick delay, uint64_t code);
void resetstats(ThreadContext *tc, Tick delay, Tick period);
void dumpstats(ThreadContext *tc, Tick delay, Tick period);
void dumpresetstats(ThreadContext *tc, Tick delay, Tick period);

View file

@ -134,6 +134,15 @@ do_exit(int argc, char *argv[])
m5_exit(ints[0]);
}
void
do_fail(int argc, char *argv[])
{
if (argc < 1 || argc > 2)
usage();
m5_fail((argc > 1) ? strtoul(argv[1], NULL, 0) : 0, strtoul(argv[0], NULL, 0));
}
void
do_reset_stats(int argc, char *argv[])
{
@ -273,6 +282,7 @@ struct MainFunc
struct MainFunc mainfuncs[] = {
{ "exit", do_exit, "[delay]" },
{ "fail", do_fail, "<code> [delay]" },
{ "resetstats", do_reset_stats, "[delay [period]]" },
{ "dumpstats", do_dump_stats, "[delay [period]]" },
{ "dumpresetstats", do_dump_reset_stats, "[delay [period]]" },

View file

@ -47,6 +47,7 @@ uint64_t rpns();
void wakeCPU(uint64_t cpuid);
void m5_exit(uint64_t ns_delay);
void m5_fail(uint64_t ns_delay, uint64_t code);
uint64_t m5_initparam(void);
void m5_checkpoint(uint64_t ns_delay, uint64_t ns_period);
void m5_reset_stats(uint64_t ns_delay, uint64_t ns_period);

View file

@ -48,6 +48,7 @@ TWO_BYTE_OP(quiesceCycle, quiescecycle_func)
TWO_BYTE_OP(quiesceTime, quiescetime_func)
TWO_BYTE_OP(rpns, rpns_func)
TWO_BYTE_OP(m5_exit, exit_func)
TWO_BYTE_OP(m5_fail, fail_func)
TWO_BYTE_OP(m5_initparam, initparam_func)
TWO_BYTE_OP(m5_loadsymbol, loadsymbol_func)
TWO_BYTE_OP(m5_reset_stats, resetstats_func)

View file

@ -40,6 +40,7 @@
#define deprecated2_func 0x11 // obsolete ivle
#define deprecated3_func 0x20 // deprecated exit function
#define exit_func 0x21
#define fail_func 0x22
#define initparam_func 0x30
#define loadsymbol_func 0x31
#define resetstats_func 0x40