1 2/* 3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 48 unchanged lines hidden (view full) --- 57 m_outstanding_count = 0; 58 59 m_max_outstanding_requests = 0; 60 m_deadlock_threshold = 0; 61 m_version = -1; 62 m_instCache_ptr = NULL; 63 m_dataCache_ptr = NULL; 64 m_controller = NULL; |
65 m_atomic_reads = 0; 66 m_atomic_writes = 0; |
67 for (size_t i=0; i<argv.size(); i+=2) { 68 if ( argv[i] == "controller") { 69 m_controller = RubySystem::getController(argv[i+1]); // args[i] = "L1Cache" 70 m_mandatory_q_ptr = m_controller->getMandatoryQueue(); 71 } else if ( argv[i] == "icache") 72 m_instCache_ptr = RubySystem::getCache(argv[i+1]); 73 else if ( argv[i] == "dcache") 74 m_dataCache_ptr = RubySystem::getCache(argv[i+1]); --- 185 unchanged lines hidden (view full) --- 260} 261 262void Sequencer::writeCallback(const Address& address, DataBlock& data) { 263 264 assert(address == line_address(address)); 265 assert(m_writeRequestTable.exist(line_address(address))); 266 267 SequencerRequest* request = m_writeRequestTable.lookup(address); |
268 |
269 removeRequest(request); 270 271 assert((request->ruby_request.type == RubyRequestType_ST) || 272 (request->ruby_request.type == RubyRequestType_RMW_Read) || 273 (request->ruby_request.type == RubyRequestType_RMW_Write) || 274 (request->ruby_request.type == RubyRequestType_Locked_Read) || 275 (request->ruby_request.type == RubyRequestType_Locked_Write)); 276 // POLINA: the assumption is that atomics are only on data cache and not instruction cache 277 if (request->ruby_request.type == RubyRequestType_Locked_Read) { 278 m_dataCache_ptr->setLocked(address, m_version); 279 } 280 else if (request->ruby_request.type == RubyRequestType_RMW_Read) { 281 m_controller->set_atomic(address); 282 } 283 else if (request->ruby_request.type == RubyRequestType_RMW_Write) { |
284 m_controller->clear_atomic(address); |
285 } 286 287 hitCallback(request, data); 288} 289 290void Sequencer::readCallback(const Address& address, DataBlock& data) { 291 292 assert(address == line_address(address)); --- 49 unchanged lines hidden (view full) --- 342 if ((type == RubyRequestType_LD) || 343 (type == RubyRequestType_IFETCH) || 344 (type == RubyRequestType_RMW_Read)) { 345 memcpy(ruby_request.data, data.getData(request_address.getOffset(), ruby_request.len), ruby_request.len); 346 } else { 347 data.setData(ruby_request.data, request_address.getOffset(), ruby_request.len); 348 } 349 } |
350 |
351 m_hit_callback(srequest->id); 352 delete srequest; 353} 354 355// Returns true if the sequencer already has a load or store outstanding 356int Sequencer::isReady(const RubyRequest& request) { 357 // POLINA: check if we are currently flushing the write buffer, if so Ruby is returned as not ready 358 // to simulate stalling of the front-end --- 4 unchanged lines hidden (view full) --- 363 364 if( m_writeRequestTable.exist(line_address(Address(request.paddr))) || 365 m_readRequestTable.exist(line_address(Address(request.paddr))) ){ 366 //cout << "OUTSTANDING REQUEST EXISTS " << p << " VER " << m_version << endl; 367 //printProgress(cout); 368 return LIBRUBY_ALIASED_REQUEST; 369 } 370 |
371 return 1; 372} 373 374bool Sequencer::empty() const { 375 return (m_writeRequestTable.size() == 0) && (m_readRequestTable.size() == 0); 376} 377 378 --- 11 unchanged lines hidden (view full) --- 390 // ensuring that nothing comes between checking the flag and servicing the store 391 if (!m_dataCache_ptr->isLocked(line_address(Address(request.paddr)), m_version)) { 392 return LLSC_FAIL; 393 } 394 else { 395 m_dataCache_ptr->clearLocked(line_address(Address(request.paddr))); 396 } 397 } |
398 issueRequest(request); 399 400 // TODO: issue hardware prefetches here 401 return id; 402 } 403 else { 404 assert(0); 405 } --- 4 unchanged lines hidden (view full) --- 410} 411 412void Sequencer::issueRequest(const RubyRequest& request) { 413 414 // TODO: get rid of CacheMsg, CacheRequestType, and AccessModeTYpe, & have SLICC use RubyRequest and subtypes natively 415 CacheRequestType ctype; 416 switch(request.type) { 417 case RubyRequestType_IFETCH: |
418 if (m_atomic_reads > 0 && m_atomic_writes == 0) { 419 m_controller->reset_atomics(); 420 } 421 else if (m_atomic_writes > 0) { 422 assert(m_atomic_reads > m_atomic_writes); 423 cerr << "WARNING: Expected: " << m_atomic_reads << " RMW_Writes, but only received: " << m_atomic_writes << endl; 424 assert(false); 425 } |
426 ctype = CacheRequestType_IFETCH; 427 break; 428 case RubyRequestType_LD: |
429 if (m_atomic_reads > 0 && m_atomic_writes == 0) { 430 m_controller->reset_atomics(); 431 } 432 else if (m_atomic_writes > 0) { 433 assert(m_atomic_reads > m_atomic_writes); 434 cerr << "WARNING: Expected: " << m_atomic_reads << " RMW_Writes, but only received: " << m_atomic_writes << endl; 435 assert(false); 436 } |
437 ctype = CacheRequestType_LD; 438 break; 439 case RubyRequestType_ST: |
440 if (m_atomic_reads > 0 && m_atomic_writes == 0) { 441 m_controller->reset_atomics(); 442 } 443 else if (m_atomic_writes > 0) { 444 assert(m_atomic_reads > m_atomic_writes); 445 cerr << "WARNING: Expected: " << m_atomic_reads << " RMW_Writes, but only received: " << m_atomic_writes << endl; 446 assert(false); 447 } |
448 ctype = CacheRequestType_ST; 449 break; 450 case RubyRequestType_Locked_Read: 451 case RubyRequestType_Locked_Write: |
452 ctype = CacheRequestType_ATOMIC; 453 break; |
454 case RubyRequestType_RMW_Read: |
455 assert(m_atomic_writes == 0); 456 m_atomic_reads++; 457 ctype = CacheRequestType_ATOMIC; 458 break; |
459 case RubyRequestType_RMW_Write: |
460 assert(m_atomic_reads > 0); 461 assert(m_atomic_writes < m_atomic_reads); 462 m_atomic_writes++; 463 if (m_atomic_reads == m_atomic_writes) { 464 m_atomic_reads = 0; 465 m_atomic_writes = 0; 466 } |
467 ctype = CacheRequestType_ATOMIC; 468 break; 469 default: 470 assert(0); 471 } 472 AccessModeType amtype; 473 switch(request.access_mode){ 474 case RubyAccessMode_User: --- 67 unchanged lines hidden --- |