base.cc (2881:5bcfebdbd31d) base.cc (3125:febd811bccc6)
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;

--- 34 unchanged lines hidden (view full) ---

43#include "cpu/profile.hh"
44#include "sim/param.hh"
45#include "sim/process.hh"
46#include "sim/sim_events.hh"
47#include "sim/system.hh"
48
49#include "base/trace.hh"
50
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;

--- 34 unchanged lines hidden (view full) ---

43#include "cpu/profile.hh"
44#include "sim/param.hh"
45#include "sim/process.hh"
46#include "sim/sim_events.hh"
47#include "sim/system.hh"
48
49#include "base/trace.hh"
50
51// Hack
52#include "sim/stat_control.hh"
53
51using namespace std;
52
53vector<BaseCPU *> BaseCPU::cpuList;
54
55// This variable reflects the max number of threads in any CPU. Be
56// careful to only use it once all the CPUs that you care about have
57// been initialized
58int maxThreadsPerCPU = 1;
59
54using namespace std;
55
56vector<BaseCPU *> BaseCPU::cpuList;
57
58// This variable reflects the max number of threads in any CPU. Be
59// careful to only use it once all the CPUs that you care about have
60// been initialized
61int maxThreadsPerCPU = 1;
62
63void
64CPUProgressEvent::process()
65{
66 Counter temp = cpu->totalInstructions();
67#ifndef NDEBUG
68 double ipc = double(temp - lastNumInst) / (interval / cpu->cycles(1));
69
70 DPRINTFN("%s progress event, instructions committed: %lli, IPC: %0.8d\n",
71 cpu->name(), temp - lastNumInst, ipc);
72 ipc = 0.0;
73#else
74 cprintf("%lli: %s progress event, instructions committed: %lli\n",
75 curTick, cpu->name(), temp - lastNumInst);
76#endif
77 lastNumInst = temp;
78 schedule(curTick + interval);
79}
80
81const char *
82CPUProgressEvent::description()
83{
84 return "CPU Progress event";
85}
86
60#if FULL_SYSTEM
61BaseCPU::BaseCPU(Params *p)
62 : MemObject(p->name), clock(p->clock), checkInterrupts(true),
63 params(p), number_of_threads(p->numberOfThreads), system(p->system)
64#else
65BaseCPU::BaseCPU(Params *p)
66 : MemObject(p->name), clock(p->clock), params(p),
67 number_of_threads(p->numberOfThreads), system(p->system)
68#endif
69{
87#if FULL_SYSTEM
88BaseCPU::BaseCPU(Params *p)
89 : MemObject(p->name), clock(p->clock), checkInterrupts(true),
90 params(p), number_of_threads(p->numberOfThreads), system(p->system)
91#else
92BaseCPU::BaseCPU(Params *p)
93 : MemObject(p->name), clock(p->clock), params(p),
94 number_of_threads(p->numberOfThreads), system(p->system)
95#endif
96{
97// currentTick = curTick;
70 DPRINTF(FullCPU, "BaseCPU: Creating object, mem address %#x.\n", this);
71
72 // add self to global list of CPUs
73 cpuList.push_back(this);
74
75 DPRINTF(FullCPU, "BaseCPU: CPU added to cpuList, mem address %#x.\n",
76 this);
77

--- 45 unchanged lines hidden (view full) ---

123 int *counter = new int;
124 *counter = number_of_threads;
125 for (int i = 0; i < number_of_threads; ++i)
126 new CountedExitEvent(comLoadEventQueue[i],
127 "all threads reached the max load count",
128 p->max_loads_all_threads, *counter);
129 }
130
98 DPRINTF(FullCPU, "BaseCPU: Creating object, mem address %#x.\n", this);
99
100 // add self to global list of CPUs
101 cpuList.push_back(this);
102
103 DPRINTF(FullCPU, "BaseCPU: CPU added to cpuList, mem address %#x.\n",
104 this);
105

--- 45 unchanged lines hidden (view full) ---

151 int *counter = new int;
152 *counter = number_of_threads;
153 for (int i = 0; i < number_of_threads; ++i)
154 new CountedExitEvent(comLoadEventQueue[i],
155 "all threads reached the max load count",
156 p->max_loads_all_threads, *counter);
157 }
158
159 if (p->stats_reset_inst != 0) {
160 Stats::SetupEvent(Stats::Reset, p->stats_reset_inst, 0, comInstEventQueue[0]);
161 cprintf("Stats reset event scheduled for %lli insts\n",
162 p->stats_reset_inst);
163 }
164
131#if FULL_SYSTEM
132 memset(interrupts, 0, sizeof(interrupts));
133 intstatus = 0;
134#endif
135
136 functionTracingEnabled = false;
137 if (p->functionTrace) {
138 functionTraceStream = simout.find(csprintf("ftrace.%s", name()));

--- 9 unchanged lines hidden (view full) ---

148 e->schedule(p->functionTraceStart);
149 }
150 }
151#if FULL_SYSTEM
152 profileEvent = NULL;
153 if (params->profile)
154 profileEvent = new ProfileEvent(this, params->profile);
155#endif
165#if FULL_SYSTEM
166 memset(interrupts, 0, sizeof(interrupts));
167 intstatus = 0;
168#endif
169
170 functionTracingEnabled = false;
171 if (p->functionTrace) {
172 functionTraceStream = simout.find(csprintf("ftrace.%s", name()));

--- 9 unchanged lines hidden (view full) ---

182 e->schedule(p->functionTraceStart);
183 }
184 }
185#if FULL_SYSTEM
186 profileEvent = NULL;
187 if (params->profile)
188 profileEvent = new ProfileEvent(this, params->profile);
189#endif
156
157}
158
159BaseCPU::Params::Params()
160{
161#if FULL_SYSTEM
162 profile = false;
163#endif
164 checker = NULL;

--- 18 unchanged lines hidden (view full) ---

183
184void
185BaseCPU::startup()
186{
187#if FULL_SYSTEM
188 if (!params->deferRegistration && profileEvent)
189 profileEvent->schedule(curTick);
190#endif
190}
191
192BaseCPU::Params::Params()
193{
194#if FULL_SYSTEM
195 profile = false;
196#endif
197 checker = NULL;

--- 18 unchanged lines hidden (view full) ---

216
217void
218BaseCPU::startup()
219{
220#if FULL_SYSTEM
221 if (!params->deferRegistration && profileEvent)
222 profileEvent->schedule(curTick);
223#endif
224
225 if (params->progress_interval) {
226 new CPUProgressEvent(&mainEventQueue, params->progress_interval,
227 this);
228 }
191}
192
193
194void
195BaseCPU::regStats()
196{
197 using namespace Stats;
198

--- 34 unchanged lines hidden (view full) ---

233#endif
234 }
235}
236
237
238void
239BaseCPU::switchOut()
240{
229}
230
231
232void
233BaseCPU::regStats()
234{
235 using namespace Stats;
236

--- 34 unchanged lines hidden (view full) ---

271#endif
272 }
273}
274
275
276void
277BaseCPU::switchOut()
278{
241 panic("This CPU doesn't support sampling!");
279// panic("This CPU doesn't support sampling!");
280#if FULL_SYSTEM
281 if (profileEvent && profileEvent->scheduled())
282 profileEvent->deschedule();
283#endif
242}
243
244void
245BaseCPU::takeOverFrom(BaseCPU *oldCPU)
246{
247 assert(threadContexts.size() == oldCPU->threadContexts.size());
248
249 for (int i = 0; i < threadContexts.size(); ++i) {

--- 6 unchanged lines hidden (view full) ---

256
257 assert(newTC->readCpuId() == oldTC->readCpuId());
258#if FULL_SYSTEM
259 system->replaceThreadContext(newTC, newTC->readCpuId());
260#else
261 assert(newTC->getProcessPtr() == oldTC->getProcessPtr());
262 newTC->getProcessPtr()->replaceThreadContext(newTC, newTC->readCpuId());
263#endif
284}
285
286void
287BaseCPU::takeOverFrom(BaseCPU *oldCPU)
288{
289 assert(threadContexts.size() == oldCPU->threadContexts.size());
290
291 for (int i = 0; i < threadContexts.size(); ++i) {

--- 6 unchanged lines hidden (view full) ---

298
299 assert(newTC->readCpuId() == oldTC->readCpuId());
300#if FULL_SYSTEM
301 system->replaceThreadContext(newTC, newTC->readCpuId());
302#else
303 assert(newTC->getProcessPtr() == oldTC->getProcessPtr());
304 newTC->getProcessPtr()->replaceThreadContext(newTC, newTC->readCpuId());
305#endif
306
307// TheISA::compareXCs(oldXC, newXC);
264 }
265
266#if FULL_SYSTEM
267 for (int i = 0; i < TheISA::NumInterruptLevels; ++i)
268 interrupts[i] = oldCPU->interrupts[i];
269 intstatus = oldCPU->intstatus;
308 }
309
310#if FULL_SYSTEM
311 for (int i = 0; i < TheISA::NumInterruptLevels; ++i)
312 interrupts[i] = oldCPU->interrupts[i];
313 intstatus = oldCPU->intstatus;
314 checkInterrupts = oldCPU->checkInterrupts;
270
271 for (int i = 0; i < threadContexts.size(); ++i)
272 threadContexts[i]->profileClear();
273
315
316 for (int i = 0; i < threadContexts.size(); ++i)
317 threadContexts[i]->profileClear();
318
274 if (profileEvent)
275 profileEvent->schedule(curTick);
319 // The Sampler must take care of this!
320// if (profileEvent)
321// profileEvent->schedule(curTick);
276#endif
277}
278
279
280#if FULL_SYSTEM
281BaseCPU::ProfileEvent::ProfileEvent(BaseCPU *_cpu, int _interval)
282 : Event(&mainEventQueue), cpu(_cpu), interval(_interval)
283{ }

--- 99 unchanged lines hidden ---
322#endif
323}
324
325
326#if FULL_SYSTEM
327BaseCPU::ProfileEvent::ProfileEvent(BaseCPU *_cpu, int _interval)
328 : Event(&mainEventQueue), cpu(_cpu), interval(_interval)
329{ }

--- 99 unchanged lines hidden ---