Deleted Added
sdiff udiff text old ( 5536:17c0c17726ff ) new ( 5606:6da7a58b0bc8 )
full compact
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;

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

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
63CPUProgressEvent::CPUProgressEvent(BaseCPU *_cpu, Tick ival)
64 : Event(Event::Progress_Event_Pri), interval(ival), lastNumInst(0),
65 cpu(_cpu)
66{
67 if (interval)
68 cpu->schedule(this, curTick + interval);
69}
70
71void
72CPUProgressEvent::process()
73{
74 Counter temp = cpu->totalInstructions();
75#ifndef NDEBUG
76 double ipc = double(temp - lastNumInst) / (interval / cpu->ticks(1));
77
78 DPRINTFN("%s progress event, instructions committed: %lli, IPC: %0.8d\n",
79 cpu->name(), temp - lastNumInst, ipc);
80 ipc = 0.0;
81#else
82 cprintf("%lli: %s progress event, instructions committed: %lli\n",
83 curTick, cpu->name(), temp - lastNumInst);
84#endif
85 lastNumInst = temp;
86 cpu->schedule(this, curTick + interval);
87}
88
89const char *
90CPUProgressEvent::description() const
91{
92 return "CPU Progress";
93}
94

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

115 // allocate per-thread instruction-based event queues
116 comInstEventQueue = new EventQueue *[number_of_threads];
117 for (int i = 0; i < number_of_threads; ++i)
118 comInstEventQueue[i] = new EventQueue("instruction-based event queue");
119
120 //
121 // set up instruction-count-based termination events, if any
122 //
123 if (p->max_insts_any_thread != 0) {
124 const char *cause = "a thread reached the max instruction count";
125 for (int i = 0; i < number_of_threads; ++i) {
126 Event *event = new SimLoopExitEvent(cause, 0);
127 comInstEventQueue[i]->schedule(event, p->max_insts_any_thread);
128 }
129 }
130
131 if (p->max_insts_all_threads != 0) {
132 const char *cause = "all threads reached the max instruction count";
133
134 // allocate & initialize shared downcounter: each event will
135 // decrement this when triggered; simulation will terminate
136 // when counter reaches 0
137 int *counter = new int;
138 *counter = number_of_threads;
139 for (int i = 0; i < number_of_threads; ++i) {
140 Event *event = new CountedExitEvent(cause, *counter);
141 comInstEventQueue[i]->schedule(event, p->max_insts_any_thread);
142 }
143 }
144
145 // allocate per-thread load-based event queues
146 comLoadEventQueue = new EventQueue *[number_of_threads];
147 for (int i = 0; i < number_of_threads; ++i)
148 comLoadEventQueue[i] = new EventQueue("load-based event queue");
149
150 //
151 // set up instruction-count-based termination events, if any
152 //
153 if (p->max_loads_any_thread != 0) {
154 const char *cause = "a thread reached the max load count";
155 for (int i = 0; i < number_of_threads; ++i) {
156 Event *event = new SimLoopExitEvent(cause, 0);
157 comLoadEventQueue[i]->schedule(event, p->max_loads_any_thread);
158 }
159 }
160
161 if (p->max_loads_all_threads != 0) {
162 const char *cause = "all threads reached the max load count";
163 // allocate & initialize shared downcounter: each event will
164 // decrement this when triggered; simulation will terminate
165 // when counter reaches 0
166 int *counter = new int;
167 *counter = number_of_threads;
168 for (int i = 0; i < number_of_threads; ++i) {
169 Event *event = new CountedExitEvent(cause, *counter);
170 comLoadEventQueue[i]->schedule(event, p->max_loads_all_threads);
171 }
172 }
173
174 functionTracingEnabled = false;
175 if (p->function_trace) {
176 functionTraceStream = simout.find(csprintf("ftrace.%s", name()));
177 currentFunctionStart = currentFunctionEnd = 0;
178 functionEntryTick = p->function_trace_start;
179
180 if (p->function_trace_start == 0) {
181 functionTracingEnabled = true;
182 } else {
183 typedef EventWrapper<BaseCPU, &BaseCPU::enableFunctionTrace> wrap;
184 Event *event = new wrap(this, true);
185 schedule(event, p->function_trace_start);
186 }
187 }
188#if FULL_SYSTEM
189 profileEvent = NULL;
190 if (params()->profile)
191 profileEvent = new ProfileEvent(this, params()->profile);
192#endif
193 tracer = params()->tracer;

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

210 registerThreadContexts();
211}
212
213void
214BaseCPU::startup()
215{
216#if FULL_SYSTEM
217 if (!params()->defer_registration && profileEvent)
218 schedule(profileEvent, curTick);
219#endif
220
221 if (params()->progress_interval) {
222 Tick num_ticks = ticks(params()->progress_interval);
223 Event *event = new CPUProgressEvent(this, num_ticks);
224 schedule(event, curTick + num_ticks);
225 }
226}
227
228
229void
230BaseCPU::regStats()
231{
232 using namespace Stats;

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

301}
302
303void
304BaseCPU::switchOut()
305{
306// panic("This CPU doesn't support sampling!");
307#if FULL_SYSTEM
308 if (profileEvent && profileEvent->scheduled())
309 deschedule(profileEvent);
310#endif
311}
312
313void
314BaseCPU::takeOverFrom(BaseCPU *oldCPU, Port *ic, Port *dc)
315{
316 assert(threadContexts.size() == oldCPU->threadContexts.size());
317

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

337
338#if FULL_SYSTEM
339 interrupts = oldCPU->interrupts;
340
341 for (int i = 0; i < threadContexts.size(); ++i)
342 threadContexts[i]->profileClear();
343
344 if (profileEvent)
345 schedule(profileEvent, curTick);
346#endif
347
348 // Connect new CPU to old CPU's memory only if new CPU isn't
349 // connected to anything. Also connect old CPU's memory to new
350 // CPU.
351 if (!ic->isConnected()) {
352 Port *peer = oldCPU->getPort("icache_port")->getPeer();
353 ic->setPeer(peer);

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

359 dc->setPeer(peer);
360 peer->setPeer(dc);
361 }
362}
363
364
365#if FULL_SYSTEM
366BaseCPU::ProfileEvent::ProfileEvent(BaseCPU *_cpu, Tick _interval)
367 : cpu(_cpu), interval(_interval)
368{ }
369
370void
371BaseCPU::ProfileEvent::process()
372{
373 for (int i = 0, size = cpu->threadContexts.size(); i < size; ++i) {
374 ThreadContext *tc = cpu->threadContexts[i];
375 tc->profileSample();
376 }
377
378 cpu->schedule(this, curTick + interval);
379}
380
381void
382BaseCPU::post_interrupt(int int_num, int index)
383{
384 interrupts.post(int_num, index);
385}
386

--- 60 unchanged lines hidden ---