base.cc (7781:a9f9eed35b18) | base.cc (7823:dac01f14f20f) |
---|---|
1/* 2 * Copyright (c) 2002-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 52 unchanged lines hidden (view full) --- 61// been initialized 62int maxThreadsPerCPU = 1; 63 64CPUProgressEvent::CPUProgressEvent(BaseCPU *_cpu, Tick ival) 65 : Event(Event::Progress_Event_Pri), _interval(ival), lastNumInst(0), 66 cpu(_cpu), _repeatEvent(true) 67{ 68 if (_interval) | 1/* 2 * Copyright (c) 2002-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 52 unchanged lines hidden (view full) --- 61// been initialized 62int maxThreadsPerCPU = 1; 63 64CPUProgressEvent::CPUProgressEvent(BaseCPU *_cpu, Tick ival) 65 : Event(Event::Progress_Event_Pri), _interval(ival), lastNumInst(0), 66 cpu(_cpu), _repeatEvent(true) 67{ 68 if (_interval) |
69 cpu->schedule(this, curTick + _interval); | 69 cpu->schedule(this, curTick() + _interval); |
70} 71 72void 73CPUProgressEvent::process() 74{ 75 Counter temp = cpu->totalInstructions(); 76#ifndef NDEBUG 77 double ipc = double(temp - lastNumInst) / (_interval / cpu->ticks(1)); 78 79 DPRINTFN("%s progress event, total committed:%i, progress insts committed: " 80 "%lli, IPC: %0.8d\n", cpu->name(), temp, temp - lastNumInst, 81 ipc); 82 ipc = 0.0; 83#else 84 cprintf("%lli: %s progress event, total committed:%i, progress insts " | 70} 71 72void 73CPUProgressEvent::process() 74{ 75 Counter temp = cpu->totalInstructions(); 76#ifndef NDEBUG 77 double ipc = double(temp - lastNumInst) / (_interval / cpu->ticks(1)); 78 79 DPRINTFN("%s progress event, total committed:%i, progress insts committed: " 80 "%lli, IPC: %0.8d\n", cpu->name(), temp, temp - lastNumInst, 81 ipc); 82 ipc = 0.0; 83#else 84 cprintf("%lli: %s progress event, total committed:%i, progress insts " |
85 "committed: %lli\n", curTick, cpu->name(), temp, | 85 "committed: %lli\n", curTick(), cpu->name(), temp, |
86 temp - lastNumInst); 87#endif 88 lastNumInst = temp; 89 90 if (_repeatEvent) | 86 temp - lastNumInst); 87#endif 88 lastNumInst = temp; 89 90 if (_repeatEvent) |
91 cpu->schedule(this, curTick + _interval); | 91 cpu->schedule(this, curTick() + _interval); |
92} 93 94const char * 95CPUProgressEvent::description() const 96{ 97 return "CPU Progress"; 98} 99 --- 5 unchanged lines hidden (view full) --- 105 phase(p->phase) 106#else 107BaseCPU::BaseCPU(Params *p) 108 : MemObject(p), clock(p->clock), _cpuId(p->cpu_id), 109 numThreads(p->numThreads), system(p->system), 110 phase(p->phase) 111#endif 112{ | 92} 93 94const char * 95CPUProgressEvent::description() const 96{ 97 return "CPU Progress"; 98} 99 --- 5 unchanged lines hidden (view full) --- 105 phase(p->phase) 106#else 107BaseCPU::BaseCPU(Params *p) 108 : MemObject(p), clock(p->clock), _cpuId(p->cpu_id), 109 numThreads(p->numThreads), system(p->system), 110 phase(p->phase) 111#endif 112{ |
113// currentTick = curTick; | 113// currentTick = curTick(); |
114 115 // if Python did not provide a valid ID, do it here 116 if (_cpuId == -1 ) { 117 _cpuId = cpuList.size(); 118 } 119 120 // add self to global list of CPUs 121 cpuList.push_back(this); --- 104 unchanged lines hidden (view full) --- 226 registerThreadContexts(); 227} 228 229void 230BaseCPU::startup() 231{ 232#if FULL_SYSTEM 233 if (!params()->defer_registration && profileEvent) | 114 115 // if Python did not provide a valid ID, do it here 116 if (_cpuId == -1 ) { 117 _cpuId = cpuList.size(); 118 } 119 120 // add self to global list of CPUs 121 cpuList.push_back(this); --- 104 unchanged lines hidden (view full) --- 226 registerThreadContexts(); 227} 228 229void 230BaseCPU::startup() 231{ 232#if FULL_SYSTEM 233 if (!params()->defer_registration && profileEvent) |
234 schedule(profileEvent, curTick); | 234 schedule(profileEvent, curTick()); |
235#endif 236 237 if (params()->progress_interval) { 238 Tick num_ticks = ticks(params()->progress_interval); 239 240 Event *event; 241 event = new CPUProgressEvent(this, num_ticks); 242 } --- 22 unchanged lines hidden (view full) --- 265 266#if FULL_SYSTEM 267#endif 268} 269 270Tick 271BaseCPU::nextCycle() 272{ | 235#endif 236 237 if (params()->progress_interval) { 238 Tick num_ticks = ticks(params()->progress_interval); 239 240 Event *event; 241 event = new CPUProgressEvent(this, num_ticks); 242 } --- 22 unchanged lines hidden (view full) --- 265 266#if FULL_SYSTEM 267#endif 268} 269 270Tick 271BaseCPU::nextCycle() 272{ |
273 Tick next_tick = curTick - phase + clock - 1; | 273 Tick next_tick = curTick() - phase + clock - 1; |
274 next_tick -= (next_tick % clock); 275 next_tick += phase; 276 return next_tick; 277} 278 279Tick 280BaseCPU::nextCycle(Tick begin_tick) 281{ 282 Tick next_tick = begin_tick; 283 if (next_tick % clock != 0) 284 next_tick = next_tick - (next_tick % clock) + clock; 285 next_tick += phase; 286 | 274 next_tick -= (next_tick % clock); 275 next_tick += phase; 276 return next_tick; 277} 278 279Tick 280BaseCPU::nextCycle(Tick begin_tick) 281{ 282 Tick next_tick = begin_tick; 283 if (next_tick % clock != 0) 284 next_tick = next_tick - (next_tick % clock) + clock; 285 next_tick += phase; 286 |
287 assert(next_tick >= curTick); | 287 assert(next_tick >= curTick()); |
288 return next_tick; 289} 290 291void 292BaseCPU::registerThreadContexts() 293{ 294 ThreadID size = threadContexts.size(); 295 for (ThreadID tid = 0; tid < size; ++tid) { --- 89 unchanged lines hidden (view full) --- 385#if FULL_SYSTEM 386 interrupts = oldCPU->interrupts; 387 interrupts->setCPU(this); 388 389 for (ThreadID i = 0; i < size; ++i) 390 threadContexts[i]->profileClear(); 391 392 if (profileEvent) | 288 return next_tick; 289} 290 291void 292BaseCPU::registerThreadContexts() 293{ 294 ThreadID size = threadContexts.size(); 295 for (ThreadID tid = 0; tid < size; ++tid) { --- 89 unchanged lines hidden (view full) --- 385#if FULL_SYSTEM 386 interrupts = oldCPU->interrupts; 387 interrupts->setCPU(this); 388 389 for (ThreadID i = 0; i < size; ++i) 390 threadContexts[i]->profileClear(); 391 392 if (profileEvent) |
393 schedule(profileEvent, curTick); | 393 schedule(profileEvent, curTick()); |
394#endif 395 396 // Connect new CPU to old CPU's memory only if new CPU isn't 397 // connected to anything. Also connect old CPU's memory to new 398 // CPU. 399 if (!ic->isConnected()) { 400 Port *peer = oldCPU->getPort("icache_port")->getPeer(); 401 ic->setPeer(peer); --- 17 unchanged lines hidden (view full) --- 419BaseCPU::ProfileEvent::process() 420{ 421 ThreadID size = cpu->threadContexts.size(); 422 for (ThreadID i = 0; i < size; ++i) { 423 ThreadContext *tc = cpu->threadContexts[i]; 424 tc->profileSample(); 425 } 426 | 394#endif 395 396 // Connect new CPU to old CPU's memory only if new CPU isn't 397 // connected to anything. Also connect old CPU's memory to new 398 // CPU. 399 if (!ic->isConnected()) { 400 Port *peer = oldCPU->getPort("icache_port")->getPeer(); 401 ic->setPeer(peer); --- 17 unchanged lines hidden (view full) --- 419BaseCPU::ProfileEvent::process() 420{ 421 ThreadID size = cpu->threadContexts.size(); 422 for (ThreadID i = 0; i < size; ++i) { 423 ThreadContext *tc = cpu->threadContexts[i]; 424 tc->profileSample(); 425 } 426 |
427 cpu->schedule(this, curTick + interval); | 427 cpu->schedule(this, curTick() + interval); |
428} 429 430void 431BaseCPU::serialize(std::ostream &os) 432{ 433 SERIALIZE_SCALAR(instCnt); 434 interrupts->serialize(os); 435} --- 24 unchanged lines hidden (view full) --- 460 if (!found) { 461 // no symbol found: use addr as label 462 sym_str = csprintf("0x%x", pc); 463 currentFunctionStart = pc; 464 currentFunctionEnd = pc + 1; 465 } 466 467 ccprintf(*functionTraceStream, " (%d)\n%d: %s", | 428} 429 430void 431BaseCPU::serialize(std::ostream &os) 432{ 433 SERIALIZE_SCALAR(instCnt); 434 interrupts->serialize(os); 435} --- 24 unchanged lines hidden (view full) --- 460 if (!found) { 461 // no symbol found: use addr as label 462 sym_str = csprintf("0x%x", pc); 463 currentFunctionStart = pc; 464 currentFunctionEnd = pc + 1; 465 } 466 467 ccprintf(*functionTraceStream, " (%d)\n%d: %s", |
468 curTick - functionEntryTick, curTick, sym_str); 469 functionEntryTick = curTick; | 468 curTick() - functionEntryTick, curTick(), sym_str); 469 functionEntryTick = curTick(); |
470 } 471} | 470 } 471} |