From ba79155d9d0f42457f74b533e27f0af2ab1b5e4a Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Thu, 22 Sep 2011 18:59:54 -0700 Subject: [PATCH] pseudo_inst: clean up workbegin/workend functions Use exitSimLoop() function instead of explicitly scheduling on mainEventQueue (which won't work once we go to multiple event queues). Also introduced a local params variable to shorten a lot of expressions. --- src/sim/pseudo_inst.cc | 58 +++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/src/sim/pseudo_inst.cc b/src/sim/pseudo_inst.cc index 226495847..2062dfb8c 100644 --- a/src/sim/pseudo_inst.cc +++ b/src/sim/pseudo_inst.cc @@ -11,6 +11,7 @@ * unmodified and in its entirety in all distributions of the software, * modified or unmodified, in source code or in binary form. * + * Copyright (c) 2011 Advanced Micro Devices, Inc. * Copyright (c) 2003-2006 The Regents of The University of Michigan * All rights reserved. * @@ -381,6 +382,7 @@ workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid) { tc->getCpuPtr()->workItemBegin(); System *sys = tc->getSystemPtr(); + const System::Params *params = sys->params(); DPRINTF(WorkItems, "Work Begin workid: %d, threadid %d\n", workid, threadid); @@ -389,46 +391,39 @@ workbegin(ThreadContext *tc, uint64_t workid, uint64_t 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) { + if (params->work_item_id == -1 || 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 (params->work_cpus_ckpt_count != 0 && + sys->markWorkItem(cpuId) >= params->work_cpus_ckpt_count) { // // If active cpus equals checkpoint count, create checkpoint // - Event *event = new SimLoopExitEvent("checkpoint", 0); - mainEventQueue.schedule(event, curTick()); + exitSimLoop("checkpoint"); } - if (systemWorkBeginCount == sys->params()->work_begin_ckpt_count) { + if (systemWorkBeginCount == 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()); + exitSimLoop("checkpoint"); } - if (systemWorkBeginCount == sys->params()->work_begin_exit_count) { + if (systemWorkBeginCount == 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()); + exitSimLoop("work started count reach"); } - if (tc->getCpuPtr()->cpuId() == sys->params()->work_begin_cpu_id_exit) { + if (cpuId == params->work_begin_cpu_id_exit) { // - // If work started on the specific cpu id specified, exit simulation + // If work started on the cpu id specified, exit simulation // - Event *event = new SimLoopExitEvent("work started on specific cpu", - 0); - - mainEventQueue.schedule(event, curTick() + 1); + exitSimLoop("work started on specific cpu"); } } } @@ -443,6 +438,7 @@ workend(ThreadContext *tc, uint64_t workid, uint64_t threadid) { tc->getCpuPtr()->workItemEnd(); System *sys = tc->getSystemPtr(); + const System::Params *params = sys->params(); DPRINTF(WorkItems, "Work End workid: %d, threadid %d\n", workid, threadid); @@ -450,40 +446,34 @@ workend(ThreadContext *tc, uint64_t workid, uint64_t 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) { + if (params->work_item_id == -1 || 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 (params->work_cpus_ckpt_count != 0 && + sys->markWorkItem(cpuId) >= params->work_cpus_ckpt_count) { // // If active cpus equals checkpoint count, create checkpoint // - Event *event = new SimLoopExitEvent("checkpoint", 0); - mainEventQueue.schedule(event, curTick()); + exitSimLoop("checkpoint"); } - if (sys->params()->work_end_ckpt_count != 0 && - systemWorkEndCount == sys->params()->work_end_ckpt_count) { + if (params->work_end_ckpt_count != 0 && + systemWorkEndCount == 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()); + exitSimLoop("checkpoint"); } - if (sys->params()->work_end_exit_count != 0 && - systemWorkEndCount == sys->params()->work_end_exit_count) { + if (params->work_end_exit_count != 0 && + systemWorkEndCount == 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()); + exitSimLoop("work items exit count reached"); } } } -- 2.30.2