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.
This commit is contained in:
parent
4a4bc2e18b
commit
ba79155d9d
|
@ -11,6 +11,7 @@
|
||||||
* unmodified and in its entirety in all distributions of the software,
|
* unmodified and in its entirety in all distributions of the software,
|
||||||
* modified or unmodified, in source code or in binary form.
|
* 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
|
* Copyright (c) 2003-2006 The Regents of The University of Michigan
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -381,6 +382,7 @@ workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid)
|
||||||
{
|
{
|
||||||
tc->getCpuPtr()->workItemBegin();
|
tc->getCpuPtr()->workItemBegin();
|
||||||
System *sys = tc->getSystemPtr();
|
System *sys = tc->getSystemPtr();
|
||||||
|
const System::Params *params = sys->params();
|
||||||
|
|
||||||
DPRINTF(WorkItems, "Work Begin workid: %d, threadid %d\n", workid,
|
DPRINTF(WorkItems, "Work Begin workid: %d, threadid %d\n", workid,
|
||||||
threadid);
|
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
|
// If specified, determine if this is the specific work item the user
|
||||||
// identified
|
// identified
|
||||||
//
|
//
|
||||||
if (sys->params()->work_item_id == -1 ||
|
if (params->work_item_id == -1 || params->work_item_id == workid) {
|
||||||
sys->params()->work_item_id == workid) {
|
|
||||||
|
|
||||||
uint64_t systemWorkBeginCount = sys->incWorkItemsBegin();
|
uint64_t systemWorkBeginCount = sys->incWorkItemsBegin();
|
||||||
int cpuId = tc->getCpuPtr()->cpuId();
|
int cpuId = tc->getCpuPtr()->cpuId();
|
||||||
|
|
||||||
if (sys->params()->work_cpus_ckpt_count != 0 &&
|
if (params->work_cpus_ckpt_count != 0 &&
|
||||||
sys->markWorkItem(cpuId) >= sys->params()->work_cpus_ckpt_count) {
|
sys->markWorkItem(cpuId) >= params->work_cpus_ckpt_count) {
|
||||||
//
|
//
|
||||||
// If active cpus equals checkpoint count, create checkpoint
|
// If active cpus equals checkpoint count, create checkpoint
|
||||||
//
|
//
|
||||||
Event *event = new SimLoopExitEvent("checkpoint", 0);
|
exitSimLoop("checkpoint");
|
||||||
mainEventQueue.schedule(event, curTick());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// Note: the string specified as the cause of the exit event must
|
||||||
// exactly equal "checkpoint" inorder to create a checkpoint
|
// exactly equal "checkpoint" inorder to create a checkpoint
|
||||||
//
|
//
|
||||||
Event *event = new SimLoopExitEvent("checkpoint", 0);
|
exitSimLoop("checkpoint");
|
||||||
mainEventQueue.schedule(event, curTick());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// If a certain number of work items started, exit simulation
|
||||||
//
|
//
|
||||||
Event *event = new SimLoopExitEvent("work started count reach", 0);
|
exitSimLoop("work started count reach");
|
||||||
mainEventQueue.schedule(event, curTick());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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",
|
exitSimLoop("work started on specific cpu");
|
||||||
0);
|
|
||||||
|
|
||||||
mainEventQueue.schedule(event, curTick() + 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -443,6 +438,7 @@ workend(ThreadContext *tc, uint64_t workid, uint64_t threadid)
|
||||||
{
|
{
|
||||||
tc->getCpuPtr()->workItemEnd();
|
tc->getCpuPtr()->workItemEnd();
|
||||||
System *sys = tc->getSystemPtr();
|
System *sys = tc->getSystemPtr();
|
||||||
|
const System::Params *params = sys->params();
|
||||||
|
|
||||||
DPRINTF(WorkItems, "Work End workid: %d, threadid %d\n", workid, threadid);
|
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
|
// If specified, determine if this is the specific work item the user
|
||||||
// identified
|
// identified
|
||||||
//
|
//
|
||||||
if (sys->params()->work_item_id == -1 ||
|
if (params->work_item_id == -1 || params->work_item_id == workid) {
|
||||||
sys->params()->work_item_id == workid) {
|
|
||||||
|
|
||||||
uint64_t systemWorkEndCount = sys->incWorkItemsEnd();
|
uint64_t systemWorkEndCount = sys->incWorkItemsEnd();
|
||||||
int cpuId = tc->getCpuPtr()->cpuId();
|
int cpuId = tc->getCpuPtr()->cpuId();
|
||||||
|
|
||||||
if (sys->params()->work_cpus_ckpt_count != 0 &&
|
if (params->work_cpus_ckpt_count != 0 &&
|
||||||
sys->markWorkItem(cpuId) >= sys->params()->work_cpus_ckpt_count) {
|
sys->markWorkItem(cpuId) >= params->work_cpus_ckpt_count) {
|
||||||
//
|
//
|
||||||
// If active cpus equals checkpoint count, create checkpoint
|
// If active cpus equals checkpoint count, create checkpoint
|
||||||
//
|
//
|
||||||
Event *event = new SimLoopExitEvent("checkpoint", 0);
|
exitSimLoop("checkpoint");
|
||||||
mainEventQueue.schedule(event, curTick());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sys->params()->work_end_ckpt_count != 0 &&
|
if (params->work_end_ckpt_count != 0 &&
|
||||||
systemWorkEndCount == sys->params()->work_end_ckpt_count) {
|
systemWorkEndCount == params->work_end_ckpt_count) {
|
||||||
//
|
//
|
||||||
// If total work items completed equals checkpoint count, create
|
// If total work items completed equals checkpoint count, create
|
||||||
// checkpoint
|
// checkpoint
|
||||||
//
|
//
|
||||||
Event *event = new SimLoopExitEvent("checkpoint", 0);
|
exitSimLoop("checkpoint");
|
||||||
mainEventQueue.schedule(event, curTick());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sys->params()->work_end_exit_count != 0 &&
|
if (params->work_end_exit_count != 0 &&
|
||||||
systemWorkEndCount == sys->params()->work_end_exit_count) {
|
systemWorkEndCount == params->work_end_exit_count) {
|
||||||
//
|
//
|
||||||
// If total work items completed equals exit count, exit simulation
|
// If total work items completed equals exit count, exit simulation
|
||||||
//
|
//
|
||||||
Event *event = new SimLoopExitEvent("work items exit count reached",
|
exitSimLoop("work items exit count reached");
|
||||||
0);
|
|
||||||
|
|
||||||
mainEventQueue.schedule(event, curTick());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue