changeset eee5bb0fb8ea in /z/repo/m5 details: http://repo.m5sim.org/m5?cmd=changeset;node=eee5bb0fb8ea description: m5: added work completed monitoring support
diffstat: configs/common/FSConfig.py | 19 ++++- configs/common/Options.py | 14 +++ configs/example/fs.py | 2 +- configs/example/ruby_fs.py | 2 +- src/arch/x86/isa/decoder/two_byte_opcodes.isa | 6 + src/cpu/base.cc | 10 ++ src/cpu/base.hh | 4 + src/sim/SConscript | 1 + src/sim/System.py | 14 +++ src/sim/pseudo_inst.cc | 117 ++++++++++++++++++++++++++ src/sim/pseudo_inst.hh | 2 + src/sim/system.cc | 9 +- src/sim/system.hh | 42 +++++++++ util/m5/m5op_x86.S | 2 + util/m5/m5ops.h | 3 + 15 files changed, 243 insertions(+), 4 deletions(-) diffs (truncated from 423 to 300 lines): diff -r 70b56a9ac1b2 -r eee5bb0fb8ea configs/common/FSConfig.py --- a/configs/common/FSConfig.py Sun Feb 06 22:14:18 2011 -0800 +++ b/configs/common/FSConfig.py Sun Feb 06 22:14:19 2011 -0800 @@ -405,7 +405,8 @@ for i in range(3, 15): assignISAInt(i, i) -def makeLinuxX86System(mem_mode, numCPUs = 1, mdesc = None, Ruby = False): +def makeLinuxX86System(mem_mode, options, mdesc = None, Ruby = False): + numCPUs = options.num_cpus self = LinuxX86System() # Build up the x86 system and then specialize it for Linux @@ -415,6 +416,22 @@ # just to avoid corner cases. assert(self.physmem.range.second.getValue() >= 0x200000) + # set work count options + if options.work_item_id != None: + self.work_item_id = options.work_item_id + if options.work_begin_cpu_id_exit != None: + self.work_begin_cpu_id_exit = options.work_begin_cpu_id_exit + if options.work_end_exit_count != None: + self.work_end_exit_count = options.work_end_exit_count + if options.work_end_checkpoint_count != None: + self.work_end_ckpt_count = options.work_end_checkpoint_count + if options.work_begin_exit_count != None: + self.work_begin_exit_count = options.work_begin_exit_count + if options.work_begin_checkpoint_count != None: + self.work_begin_ckpt_count = options.work_begin_checkpoint_count + if options.work_cpus_checkpoint_count != None: + self.work_cpus_ckpt_count = options.work_cpus_checkpoint_count + # Mark the first megabyte of memory as reserved self.e820_table.entries.append(X86E820Entry( addr = 0, diff -r 70b56a9ac1b2 -r eee5bb0fb8ea configs/common/Options.py --- a/configs/common/Options.py Sun Feb 06 22:14:18 2011 -0800 +++ b/configs/common/Options.py Sun Feb 06 22:14:19 2011 -0800 @@ -54,6 +54,14 @@ parser.add_option("--maxtime", type="float") parser.add_option("--maxinsts", type="int") parser.add_option("--prog_intvl", type="int") +parser.add_option("--work-item-id", action="store", type="int", + help="the specific work id for exit & checkpointing") +parser.add_option("--work-begin-cpu-id-exit", action="store", type="int", + help="exit when work starts on the specified cpu") +parser.add_option("--work-end-exit-count", action="store", type="int", + help="exit at specified work end count") +parser.add_option("--work-begin-exit-count", action="store", type="int", + help="exit at specified work begin count") # Checkpointing options @@ -69,6 +77,12 @@ help="restore from checkpoint <N>") parser.add_option("--checkpoint-at-end", action="store_true", help="take a checkpoint at end of run") +parser.add_option("--work-begin-checkpoint-count", action="store", type="int", + help="checkpoint at specified work begin count") +parser.add_option("--work-end-checkpoint-count", action="store", type="int", + help="checkpoint at specified work end count") +parser.add_option("--work-cpus-checkpoint-count", action="store", type="int", + help="checkpoint and exit when active cpu count is reached") # CPU Switching - default switch model goes from a checkpoint diff -r 70b56a9ac1b2 -r eee5bb0fb8ea configs/example/fs.py --- a/configs/example/fs.py Sun Feb 06 22:14:18 2011 -0800 +++ b/configs/example/fs.py Sun Feb 06 22:14:19 2011 -0800 @@ -131,7 +131,7 @@ elif buildEnv['TARGET_ISA'] == "sparc": test_sys = makeSparcSystem(test_mem_mode, bm[0]) elif buildEnv['TARGET_ISA'] == "x86": - test_sys = makeLinuxX86System(test_mem_mode, np, bm[0]) + test_sys = makeLinuxX86System(test_mem_mode, options, bm[0]) elif buildEnv['TARGET_ISA'] == "arm": test_sys = makeLinuxArmSystem(test_mem_mode, bm[0], bare_metal=options.bare_metal, machine_type=options.machine_type) diff -r 70b56a9ac1b2 -r eee5bb0fb8ea configs/example/ruby_fs.py --- a/configs/example/ruby_fs.py Sun Feb 06 22:14:18 2011 -0800 +++ b/configs/example/ruby_fs.py Sun Feb 06 22:14:19 2011 -0800 @@ -116,7 +116,7 @@ system.piobus, system.dma_devices) elif buildEnv['TARGET_ISA'] == "x86": - system = makeLinuxX86System(test_mem_mode, options.num_cpus, bm[0], True) + system = makeLinuxX86System(test_mem_mode, options, bm[0], True) system.ruby = Ruby.create_system(options, system, system.piobus) diff -r 70b56a9ac1b2 -r eee5bb0fb8ea src/arch/x86/isa/decoder/two_byte_opcodes.isa --- a/src/arch/x86/isa/decoder/two_byte_opcodes.isa Sun Feb 06 22:14:18 2011 -0800 +++ b/src/arch/x86/isa/decoder/two_byte_opcodes.isa Sun Feb 06 22:14:19 2011 -0800 @@ -216,6 +216,12 @@ 0x59: m5reserved5({{ warn("M5 reserved opcode 5 ignored.\n"); }}, IsNonSpeculative); + 0x5a: m5_work_begin({{ + PseudoInst::workbegin(xc->tcBase(), Rdi, Rsi); + }}, IsNonSpeculative); + 0x5b: m5_work_end({{ + PseudoInst::workend(xc->tcBase(), Rdi, Rsi); + }}, IsNonSpeculative); default: Inst::UD2(); } } diff -r 70b56a9ac1b2 -r eee5bb0fb8ea src/cpu/base.cc --- a/src/cpu/base.cc Sun Feb 06 22:14:18 2011 -0800 +++ b/src/cpu/base.cc Sun Feb 06 22:14:19 2011 -0800 @@ -255,6 +255,16 @@ .desc("number of cpu cycles simulated") ; + numWorkItemsStarted + .name(name() + ".numWorkItemsStarted") + .desc("number of work items this cpu started") + ; + + numWorkItemsCompleted + .name(name() + ".numWorkItemsCompleted") + .desc("number of work items this cpu completed") + ; + int size = threadContexts.size(); if (size > 1) { for (int i = 0; i < size; ++i) { diff -r 70b56a9ac1b2 -r eee5bb0fb8ea src/cpu/base.hh --- a/src/cpu/base.hh Sun Feb 06 22:14:18 2011 -0800 +++ b/src/cpu/base.hh Sun Feb 06 22:14:19 2011 -0800 @@ -104,6 +104,8 @@ inline Tick ticks(int numCycles) const { return clock * numCycles; } inline Tick curCycle() const { return curTick() / clock; } inline Tick tickToCycles(Tick val) const { return val / clock; } + inline void workItemBegin() { numWorkItemsStarted++; } + inline void workItemEnd() { numWorkItemsCompleted++; } // @todo remove me after debugging with legion done Tick instCount() { return instCnt; } @@ -317,6 +319,8 @@ public: // Number of CPU cycles simulated Stats::Scalar numCycles; + Stats::Scalar numWorkItemsStarted; + Stats::Scalar numWorkItemsCompleted; }; #endif // __CPU_BASE_HH__ diff -r 70b56a9ac1b2 -r eee5bb0fb8ea src/sim/SConscript --- a/src/sim/SConscript Sun Feb 06 22:14:18 2011 -0800 +++ b/src/sim/SConscript Sun Feb 06 22:14:19 2011 -0800 @@ -78,3 +78,4 @@ TraceFlag('Thread') TraceFlag('Timer') TraceFlag('VtoPhys') +TraceFlag('WorkItems') diff -r 70b56a9ac1b2 -r eee5bb0fb8ea src/sim/System.py --- a/src/sim/System.py Sun Feb 06 22:14:18 2011 -0800 +++ b/src/sim/System.py Sun Feb 06 22:14:19 2011 -0800 @@ -47,6 +47,20 @@ physmem = Param.PhysicalMemory(Parent.any, "physical memory") mem_mode = Param.MemoryMode('atomic', "The mode the memory system is in") + work_item_id = Param.Int(-1, "specific work item id") + work_begin_cpu_id_exit = Param.Int(-1, + "work started on specific id, now exit simulation") + work_begin_ckpt_count = Param.Counter(0, + "create checkpoint when work items begin count value is reached") + work_begin_exit_count = Param.Counter(0, + "exit simulation when work items begin count value is reached") + work_end_ckpt_count = Param.Counter(0, + "create checkpoint when work items end count value is reached") + work_end_exit_count = Param.Counter(0, + "exit simulation when work items end count value is reached") + work_cpus_ckpt_count = Param.Counter(0, + "create checkpoint when active cpu count value is reached") + if buildEnv['FULL_SYSTEM']: abstract = True boot_cpu_frequency = Param.Frequency(Self.cpu[0].clock.frequency, diff -r 70b56a9ac1b2 -r eee5bb0fb8ea src/sim/pseudo_inst.cc --- a/src/sim/pseudo_inst.cc Sun Feb 06 22:14:18 2011 -0800 +++ b/src/sim/pseudo_inst.cc Sun Feb 06 22:14:19 2011 -0800 @@ -328,4 +328,121 @@ exitSimLoop("switchcpu"); } +// +// This function is executed when annotated work items begin. Depending on +// what the user specified at the command line, the simulation may exit and/or +// take a checkpoint when a certain work item begins. +// +void +workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid) +{ + tc->getCpuPtr()->workItemBegin(); + System *sys = tc->getSystemPtr(); + + DPRINTF(WorkItems, "Work Begin workid: %d, threadid %d\n", workid, + threadid); + + // + // If specified, determine if this is the specific work item the user + // identified + // + if (sys->params()->work_item_id == -1 || + sys->params()->work_item_id == workid) { + + uint64_t systemWorkBeginCount = sys->incWorkItemsBegin(); + int cpuId = tc->getCpuPtr()->cpuId(); + + if (sys->params()->work_cpus_ckpt_count != 0 && + sys->markWorkItem(cpuId) >= sys->params()->work_cpus_ckpt_count) { + // + // If active cpus equals checkpoint count, create checkpoint + // + Event *event = new SimLoopExitEvent("checkpoint", 0); + mainEventQueue.schedule(event, curTick()); + } + + if (systemWorkBeginCount == sys->params()->work_begin_ckpt_count) { + // + // Note: the string specified as the cause of the exit event must + // exactly equal "checkpoint" inorder to create a checkpoint + // + Event *event = new SimLoopExitEvent("checkpoint", 0); + mainEventQueue.schedule(event, curTick()); + } + + if (systemWorkBeginCount == sys->params()->work_begin_exit_count) { + // + // If a certain number of work items started, exit simulation + // + Event *event = new SimLoopExitEvent("work started count reach", 0); + mainEventQueue.schedule(event, curTick()); + } + + if (tc->getCpuPtr()->cpuId() == sys->params()->work_begin_cpu_id_exit) { + // + // If work started on the specific cpu id specified, exit simulation + // + Event *event = new SimLoopExitEvent("work started on specific cpu", + 0); + + mainEventQueue.schedule(event, curTick() + 1); + } + } +} + +// +// This function is executed when annotated work items end. Depending on +// what the user specified at the command line, the simulation may exit and/or +// take a checkpoint when a certain work item ends. +// +void +workend(ThreadContext *tc, uint64_t workid, uint64_t threadid) +{ + tc->getCpuPtr()->workItemEnd(); + System *sys = tc->getSystemPtr(); + + DPRINTF(WorkItems, "Work End workid: %d, threadid %d\n", workid, threadid); + + // + // If specified, determine if this is the specific work item the user + // identified + // + if (sys->params()->work_item_id == -1 || + sys->params()->work_item_id == workid) { + + uint64_t systemWorkEndCount = sys->incWorkItemsEnd(); + int cpuId = tc->getCpuPtr()->cpuId(); + + if (sys->params()->work_cpus_ckpt_count != 0 && + sys->markWorkItem(cpuId) >= sys->params()->work_cpus_ckpt_count) { + // + // If active cpus equals checkpoint count, create checkpoint + // + Event *event = new SimLoopExitEvent("checkpoint", 0); + mainEventQueue.schedule(event, curTick()); + } + + if (sys->params()->work_end_ckpt_count != 0 && + systemWorkEndCount == sys->params()->work_end_ckpt_count) { + // + // If total work items completed equals checkpoint count, create + // checkpoint + // + Event *event = new SimLoopExitEvent("checkpoint", 0); + mainEventQueue.schedule(event, curTick()); + } + + if (sys->params()->work_end_exit_count != 0 && + systemWorkEndCount == sys->params()->work_end_exit_count) { + // + // If total work items completed equals exit count, exit simulation + // + Event *event = new SimLoopExitEvent("work items exit count reached", + 0); + + mainEventQueue.schedule(event, curTick()); _______________________________________________ m5-dev mailing list m5-dev@m5sim.org http://m5sim.org/mailman/listinfo/m5-dev