atomic.cc (3169:65bef767b5de) | atomic.cc (3170:37fd1e73f836) |
---|---|
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; --- 14 unchanged lines hidden (view full) --- 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Steve Reinhardt 29 */ 30 | 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; --- 14 unchanged lines hidden (view full) --- 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Steve Reinhardt 29 */ 30 |
31#include "arch/locked_mem.hh" |
|
31#include "arch/utility.hh" 32#include "cpu/exetrace.hh" 33#include "cpu/simple/atomic.hh" 34#include "mem/packet_impl.hh" 35#include "sim/builder.hh" 36#include "sim/system.hh" 37 38using namespace std; --- 89 unchanged lines hidden (view full) --- 128 129AtomicSimpleCPU::AtomicSimpleCPU(Params *p) 130 : BaseSimpleCPU(p), tickEvent(this), 131 width(p->width), simulate_stalls(p->simulate_stalls), 132 icachePort(name() + "-iport", this), dcachePort(name() + "-iport", this) 133{ 134 _status = Idle; 135 | 32#include "arch/utility.hh" 33#include "cpu/exetrace.hh" 34#include "cpu/simple/atomic.hh" 35#include "mem/packet_impl.hh" 36#include "sim/builder.hh" 37#include "sim/system.hh" 38 39using namespace std; --- 89 unchanged lines hidden (view full) --- 129 130AtomicSimpleCPU::AtomicSimpleCPU(Params *p) 131 : BaseSimpleCPU(p), tickEvent(this), 132 width(p->width), simulate_stalls(p->simulate_stalls), 133 icachePort(name() + "-iport", this), dcachePort(name() + "-iport", this) 134{ 135 _status = Idle; 136 |
136 // @todo fix me and get the real cpu id & thread number!!! | |
137 ifetch_req = new Request(); | 137 ifetch_req = new Request(); |
138 ifetch_req->setThreadContext(0,0); //Need CPU/Thread IDS HERE | 138 ifetch_req->setThreadContext(p->cpu_id, 0); // Add thread ID if we add MT |
139 ifetch_pkt = new Packet(ifetch_req, Packet::ReadReq, Packet::Broadcast); 140 ifetch_pkt->dataStatic(&inst); 141 142 data_read_req = new Request(); | 139 ifetch_pkt = new Packet(ifetch_req, Packet::ReadReq, Packet::Broadcast); 140 ifetch_pkt->dataStatic(&inst); 141 142 data_read_req = new Request(); |
143 data_read_req->setThreadContext(0,0); //Need CPU/Thread IDS HERE | 143 data_read_req->setThreadContext(p->cpu_id, 0); // Add thread ID here too |
144 data_read_pkt = new Packet(data_read_req, Packet::ReadReq, 145 Packet::Broadcast); 146 data_read_pkt->dataStatic(&dataReg); 147 148 data_write_req = new Request(); | 144 data_read_pkt = new Packet(data_read_req, Packet::ReadReq, 145 Packet::Broadcast); 146 data_read_pkt->dataStatic(&dataReg); 147 148 data_write_req = new Request(); |
149 data_write_req->setThreadContext(0,0); //Need CPU/Thread IDS HERE | 149 data_write_req->setThreadContext(p->cpu_id, 0); // Add thread ID here too |
150 data_write_pkt = new Packet(data_write_req, Packet::WriteReq, 151 Packet::Broadcast); 152} 153 154 155AtomicSimpleCPU::~AtomicSimpleCPU() 156{ 157} --- 112 unchanged lines hidden (view full) --- 270 if (fault == NoFault) { 271 pkt->reinitFromRequest(); 272 273 dcache_latency = dcachePort.sendAtomic(pkt); 274 dcache_access = true; 275 276 assert(pkt->result == Packet::Success); 277 data = pkt->get<T>(); | 150 data_write_pkt = new Packet(data_write_req, Packet::WriteReq, 151 Packet::Broadcast); 152} 153 154 155AtomicSimpleCPU::~AtomicSimpleCPU() 156{ 157} --- 112 unchanged lines hidden (view full) --- 270 if (fault == NoFault) { 271 pkt->reinitFromRequest(); 272 273 dcache_latency = dcachePort.sendAtomic(pkt); 274 dcache_access = true; 275 276 assert(pkt->result == Packet::Success); 277 data = pkt->get<T>(); |
278 279 if (req->isLocked()) { 280 TheISA::handleLockedRead(thread, req); 281 } |
|
278 } 279 280 // This will need a new way to tell if it has a dcache attached. 281 if (req->getFlags() & UNCACHEABLE) 282 recordEvent("Uncached Read"); 283 284 return fault; 285} --- 55 unchanged lines hidden (view full) --- 341 traceData->setAddr(addr); 342 } 343 344 // translate to physical address 345 Fault fault = thread->translateDataWriteReq(req); 346 347 // Now do the access. 348 if (fault == NoFault) { | 282 } 283 284 // This will need a new way to tell if it has a dcache attached. 285 if (req->getFlags() & UNCACHEABLE) 286 recordEvent("Uncached Read"); 287 288 return fault; 289} --- 55 unchanged lines hidden (view full) --- 345 traceData->setAddr(addr); 346 } 347 348 // translate to physical address 349 Fault fault = thread->translateDataWriteReq(req); 350 351 // Now do the access. 352 if (fault == NoFault) { |
349 data = htog(data); 350 pkt->reinitFromRequest(); 351 pkt->dataStatic(&data); | 353 bool do_access = true; // flag to suppress cache access |
352 | 354 |
353 dcache_latency = dcachePort.sendAtomic(pkt); 354 dcache_access = true; | 355 if (req->isLocked()) { 356 do_access = TheISA::handleLockedWrite(thread, req); 357 } |
355 | 358 |
356 assert(pkt->result == Packet::Success); | 359 if (do_access) { 360 data = htog(data); 361 pkt->reinitFromRequest(); 362 pkt->dataStatic(&data); |
357 | 363 |
358 if (res && req->getFlags() & LOCKED) { 359 *res = req->getScResult(); | 364 dcache_latency = dcachePort.sendAtomic(pkt); 365 dcache_access = true; 366 367 assert(pkt->result == Packet::Success); |
360 } | 368 } |
369 370 if (req->isLocked()) { 371 uint64_t scResult = req->getScResult(); 372 if (scResult != 0) { 373 // clear failure counter 374 thread->setStCondFailures(0); 375 } 376 if (res) { 377 *res = req->getScResult(); 378 } 379 } |
|
361 } 362 363 // This will need a new way to tell if it's hooked up to a cache or not. 364 if (req->getFlags() & UNCACHEABLE) 365 recordEvent("Uncached Write"); 366 367 // If the write needs to have a fault on the access, consider calling 368 // changeStatus() and changing it to "bad addr write" or something. --- 100 unchanged lines hidden (view full) --- 469 470 Param<Counter> max_insts_any_thread; 471 Param<Counter> max_insts_all_threads; 472 Param<Counter> max_loads_any_thread; 473 Param<Counter> max_loads_all_threads; 474 Param<Tick> progress_interval; 475 SimObjectParam<MemObject *> mem; 476 SimObjectParam<System *> system; | 380 } 381 382 // This will need a new way to tell if it's hooked up to a cache or not. 383 if (req->getFlags() & UNCACHEABLE) 384 recordEvent("Uncached Write"); 385 386 // If the write needs to have a fault on the access, consider calling 387 // changeStatus() and changing it to "bad addr write" or something. --- 100 unchanged lines hidden (view full) --- 488 489 Param<Counter> max_insts_any_thread; 490 Param<Counter> max_insts_all_threads; 491 Param<Counter> max_loads_any_thread; 492 Param<Counter> max_loads_all_threads; 493 Param<Tick> progress_interval; 494 SimObjectParam<MemObject *> mem; 495 SimObjectParam<System *> system; |
496 Param<int> cpu_id; |
|
477 478#if FULL_SYSTEM 479 SimObjectParam<AlphaITB *> itb; 480 SimObjectParam<AlphaDTB *> dtb; | 497 498#if FULL_SYSTEM 499 SimObjectParam<AlphaITB *> itb; 500 SimObjectParam<AlphaDTB *> dtb; |
481 Param<int> cpu_id; | |
482 Param<Tick> profile; 483#else 484 SimObjectParam<Process *> workload; 485#endif // FULL_SYSTEM 486 487 Param<int> clock; 488 489 Param<bool> defer_registration; --- 12 unchanged lines hidden (view full) --- 502 "terminate when all threads have reached this inst count"), 503 INIT_PARAM(max_loads_any_thread, 504 "terminate when any thread reaches this load count"), 505 INIT_PARAM(max_loads_all_threads, 506 "terminate when all threads have reached this load count"), 507 INIT_PARAM(progress_interval, "Progress interval"), 508 INIT_PARAM(mem, "memory"), 509 INIT_PARAM(system, "system object"), | 501 Param<Tick> profile; 502#else 503 SimObjectParam<Process *> workload; 504#endif // FULL_SYSTEM 505 506 Param<int> clock; 507 508 Param<bool> defer_registration; --- 12 unchanged lines hidden (view full) --- 521 "terminate when all threads have reached this inst count"), 522 INIT_PARAM(max_loads_any_thread, 523 "terminate when any thread reaches this load count"), 524 INIT_PARAM(max_loads_all_threads, 525 "terminate when all threads have reached this load count"), 526 INIT_PARAM(progress_interval, "Progress interval"), 527 INIT_PARAM(mem, "memory"), 528 INIT_PARAM(system, "system object"), |
529 INIT_PARAM(cpu_id, "processor ID"), |
|
510 511#if FULL_SYSTEM 512 INIT_PARAM(itb, "Instruction TLB"), 513 INIT_PARAM(dtb, "Data TLB"), | 530 531#if FULL_SYSTEM 532 INIT_PARAM(itb, "Instruction TLB"), 533 INIT_PARAM(dtb, "Data TLB"), |
514 INIT_PARAM(cpu_id, "processor ID"), | |
515 INIT_PARAM(profile, ""), 516#else 517 INIT_PARAM(workload, "processes to run"), 518#endif // FULL_SYSTEM 519 520 INIT_PARAM(clock, "clock speed"), 521 INIT_PARAM(defer_registration, "defer system registration (for sampling)"), 522 INIT_PARAM(width, "cpu width"), --- 17 unchanged lines hidden (view full) --- 540 params->deferRegistration = defer_registration; 541 params->clock = clock; 542 params->functionTrace = function_trace; 543 params->functionTraceStart = function_trace_start; 544 params->width = width; 545 params->simulate_stalls = simulate_stalls; 546 params->mem = mem; 547 params->system = system; | 534 INIT_PARAM(profile, ""), 535#else 536 INIT_PARAM(workload, "processes to run"), 537#endif // FULL_SYSTEM 538 539 INIT_PARAM(clock, "clock speed"), 540 INIT_PARAM(defer_registration, "defer system registration (for sampling)"), 541 INIT_PARAM(width, "cpu width"), --- 17 unchanged lines hidden (view full) --- 559 params->deferRegistration = defer_registration; 560 params->clock = clock; 561 params->functionTrace = function_trace; 562 params->functionTraceStart = function_trace_start; 563 params->width = width; 564 params->simulate_stalls = simulate_stalls; 565 params->mem = mem; 566 params->system = system; |
567 params->cpu_id = cpu_id; |
|
548 549#if FULL_SYSTEM 550 params->itb = itb; 551 params->dtb = dtb; | 568 569#if FULL_SYSTEM 570 params->itb = itb; 571 params->dtb = dtb; |
552 params->cpu_id = cpu_id; | |
553 params->profile = profile; 554#else 555 params->process = workload; 556#endif 557 558 AtomicSimpleCPU *cpu = new AtomicSimpleCPU(params); 559 return cpu; 560} 561 562REGISTER_SIM_OBJECT("AtomicSimpleCPU", AtomicSimpleCPU) 563 | 572 params->profile = profile; 573#else 574 params->process = workload; 575#endif 576 577 AtomicSimpleCPU *cpu = new AtomicSimpleCPU(params); 578 return cpu; 579} 580 581REGISTER_SIM_OBJECT("AtomicSimpleCPU", AtomicSimpleCPU) 582 |