From a4c038764dc3cba44759c592c760eb3f17d7c97f Mon Sep 17 00:00:00 2001 From: Nilay Vaish Date: Fri, 25 Feb 2011 17:55:20 -0600 Subject: [PATCH] Ruby: Remove store buffer This patch removes the store buffer from Ruby. It is not in use currently. Since libruby is being and store buffer makes calls to libruby, it is not possible to maintain it until substantial changes are made. --- src/mem/ruby/storebuffer/SConscript | 37 --- src/mem/ruby/storebuffer/stb_interface.cc | 85 ------ src/mem/ruby/storebuffer/stb_interface.hh | 38 --- src/mem/ruby/storebuffer/storebuffer.cc | 299 ---------------------- src/mem/ruby/storebuffer/storebuffer.hh | 151 ----------- 5 files changed, 610 deletions(-) delete mode 100644 src/mem/ruby/storebuffer/SConscript delete mode 100644 src/mem/ruby/storebuffer/stb_interface.cc delete mode 100644 src/mem/ruby/storebuffer/stb_interface.hh delete mode 100644 src/mem/ruby/storebuffer/storebuffer.cc delete mode 100644 src/mem/ruby/storebuffer/storebuffer.hh diff --git a/src/mem/ruby/storebuffer/SConscript b/src/mem/ruby/storebuffer/SConscript deleted file mode 100644 index f546b9e60..000000000 --- a/src/mem/ruby/storebuffer/SConscript +++ /dev/null @@ -1,37 +0,0 @@ -# -*- mode:python -*- - -# Copyright (c) 2009 The Hewlett-Packard Development Company -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer; -# redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution; -# neither the name of the copyright holders nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# Authors: Nathan Binkert - -Import('*') - -if not env['RUBY']: - Return() - -Source('stb_interface.cc') -Source('storebuffer.cc') diff --git a/src/mem/ruby/storebuffer/stb_interface.cc b/src/mem/ruby/storebuffer/stb_interface.cc deleted file mode 100644 index e3d6f29ed..000000000 --- a/src/mem/ruby/storebuffer/stb_interface.cc +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer; - * redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution; - * neither the name of the copyright holders nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "mem/ruby/storebuffer/stb_interface.hh" - -StoreBuffer * -createNewSTB(uint32 id, uint32 block_bits, int storebuffer_size) -{ - StoreBuffer *stb = new StoreBuffer(id, block_bits, storebuffer_size); - return stb; -} - -storebuffer_status_t -handleStore(StoreBuffer *storebuffer, const RubyRequest &request) -{ - assert(request.type == RubyRequestType_ST); - if (storebuffer->storeBufferFull()){ - return WB_FULL; - } else if (storebuffer->storeBufferFlushing()) { - return WB_FLUSHING; - } else { - storebuffer->addToStoreBuffer(request); - return WB_OK; - } -} - -uint64_t -handleLoad(StoreBuffer *storebuffer, const RubyRequest &request) -{ - assert(request.type == RubyRequestType_LD); - return storebuffer->handleLoad(request); -} - -#if 0 -uint64_t -handleAtomic(StoreBuffer *storebuffer, const RubyRequest &request) -{ - // flush the store buffer - storebuffer->flushStoreBuffer(); - // let storebuffer issue atomic - // return storebuffer->issueAtomic(request); -} -#endif - -void -flushSTB(StoreBuffer *storebuffer) -{ - // in in-order can't get a request to flushSTB if already flushing - // on out of order, have to check if already flushing - storebuffer->flushStoreBuffer(); -} - -void -registerHitCallback(StoreBuffer *storebuffer, - void (*hit_callback)(int64_t access_id)) -{ - storebuffer->registerHitCallback(hit_callback); -} diff --git a/src/mem/ruby/storebuffer/stb_interface.hh b/src/mem/ruby/storebuffer/stb_interface.hh deleted file mode 100644 index b7f1b152d..000000000 --- a/src/mem/ruby/storebuffer/stb_interface.hh +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer; - * redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution; - * neither the name of the copyright holders nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "mem/ruby/storebuffer/storebuffer.hh" - -StoreBuffer *createNewSTB(uint32 id, uint32 block_bits, int storebuffer_size); -storebuffer_status_t handleStore(StoreBuffer *storebuffer, - const RubyRequest &request); -uint64_t handleLoad(StoreBuffer *storebuffer, const RubyRequest &request); -uint64_t handleAtomic(StoreBuffer *storebuffer, const RubyRequest &request); -void flushSTB(StoreBuffer *storebuffer); -void registerHitCallback(StoreBuffer *storebuffer, - void (*hit_callback)(int64_t access_id)); diff --git a/src/mem/ruby/storebuffer/storebuffer.cc b/src/mem/ruby/storebuffer/storebuffer.cc deleted file mode 100644 index 0accf138d..000000000 --- a/src/mem/ruby/storebuffer/storebuffer.cc +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer; - * redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution; - * neither the name of the copyright holders nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include - -#include "base/trace.hh" -#include "mem/ruby/common/Global.hh" -#include "mem/ruby/storebuffer/storebuffer.hh" - -using namespace std; - -#define SYSTEM_EXIT assert(0) - -// global map of request id_s to map them back to storebuffer pointers -map request_map; - -void -hit(int64_t id) -{ - if (request_map.find(id) == request_map.end()) { - panic("Request ID %d not found in the map\n", id); - } else { - request_map[id]->complete(id); - request_map.erase(id); - } -} - -StoreBuffer::StoreBuffer(uint32 id, uint32 block_bits, int storebuffer_size) -{ - iseq = 0; - tso_iseq = 0; - char name [] = "Sequencer_"; - char port_name [13]; - sprintf(port_name, "%s%d", name, id); - m_hit_callback = NULL; - assert(storebuffer_size >= 0); - m_storebuffer_size = storebuffer_size; - m_id = id; - m_block_size = 1 << block_bits; - m_block_mask = ~(m_block_size - 1); - m_buffer_size = 0; - m_storebuffer_full = false; - m_storebuffer_flushing = false; - m_stalled_issue = true; -} - -StoreBuffer::~StoreBuffer() -{ -} - -void -StoreBuffer::registerHitCallback(void (*hit_callback)(int64_t request_id)) -{ - assert(m_hit_callback == NULL); // can't assign hit_callback twice - m_hit_callback = hit_callback; -} - - -void -StoreBuffer::addToStoreBuffer(RubyRequest request) -{ - buffer.push_front(SBEntry(request, NULL)); - - m_buffer_size++; - - if (m_buffer_size >= m_storebuffer_size) { - m_storebuffer_full = true; - } else if (m_stalled_issue) { - m_stalled_issue = false; - issueNextStore(); - } - - iseq++; -} - - -// Return value of -2 indicates that the load request was satisfied by -// the store buffer -// Return value of -3 indicates a partial match, so the load has to -// retry until NO_MATCH -// Alternatively we could satisfy the partial match, but tso gets -// complicated and more races -int64_t -StoreBuffer::handleLoad(RubyRequest request) -{ - load_match match = checkForLoadHit(request); - if (match == FULL_MATCH) { - // fill data - returnMatchedData(request); - iseq++; - return -2; - } else { // partial match - return -3; - } -} - -// This function will fill the data array if any match is found -load_match -StoreBuffer::checkForLoadHit(RubyRequest request) -{ - physical_address_t physical_address = request.paddr; - int len = request.len; - - uint8_t * data = new uint8_t[64]; - memset(data, 0, 64); - for (int i = physical_address % 64; i < len; i++) - data[i] = 1; - - bool found = false; - physical_address_t lineaddr = physical_address & m_block_mask; - - // iterate over the buffer looking for hits - deque::iterator it = buffer.begin(); - for (; it != buffer.end(); it++) { - RubyRequest &req = it->m_request; - if ((req.paddr & m_block_mask) != lineaddr) - continue; - - found = true; - for (int i = req.paddr % 64; i < req.len; i++) - data[i] = 0; - } - - // if any matching entry is found, determine if all the - // requested bytes have been matched - if (found) { - assert(m_buffer_size > 0); - int unmatched_bytes = 0; - for (int i = physical_address%64; i < len; i++) { - unmatched_bytes = unmatched_bytes + data[i]; - } - if (unmatched_bytes == 0) { - delete data; - return FULL_MATCH; - } else { - delete data; - return PARTIAL_MATCH; - } - } else { - delete data; - return NO_MATCH; - } -} - -void -StoreBuffer::returnMatchedData(RubyRequest request) -{ - if (!m_use_storebuffer) { - panic("returnMatchedData called while write buffer is not in use\n"); - } - - uint8_t * data = new uint8_t[64]; - memset(data, 0, 64); - uint8_t * written = new uint8_t[64]; - memset(written, 0, 64); - - physical_address_t physical_address = request.paddr; - int len = request.len; - - assert(checkForLoadHit(request) != NO_MATCH); - physical_address_t lineaddr = physical_address & m_block_mask; - bool found = false; - deque::iterator satisfying_store; - deque::iterator it = buffer.begin(); - for (; it != buffer.end(); it++) { - if ((it->m_request.paddr & m_block_mask) == lineaddr) { - if (!found) { - found = true; - } - uint8_t * dataPtr = it->m_request.data; - int offset = it->m_request.paddr%64; - for (int i = offset; i < it->m_request.len; i++) { - if (!written[i]) { // don't overwrite data with earlier data - data[i] = dataPtr[i-offset]; - written[i] = 1; - } - } - } - } - - int i = physical_address%64; - for (int j = 0; (i < physical_address%64 + len) && (j < len); i++, j++) { - if (written[i]) { - request.data[j] = data[i]; - } - } - - delete data; - delete written; -} - -void -StoreBuffer::flushStoreBuffer() -{ - if (!m_use_storebuffer) { - // do nothing - return; - } - - m_storebuffer_flushing = (m_buffer_size > 0); -} - -void -StoreBuffer::issueNextStore() -{ -} - -void -StoreBuffer::complete(uint64_t id) -{ - if (!m_use_storebuffer) { - m_hit_callback(id); - return; - } - - assert(outstanding_requests.find(id) != outstanding_requests.end()); - physical_address_t physical_address = - outstanding_requests.find(id)->second.paddr; - RubyRequestType type = outstanding_requests.find(id)->second.type; - - if (type == RubyRequestType_ST) { - physical_address_t lineaddr = physical_address & m_block_mask; - - // Note fastpath hits are handled like regular requests - they - // must remove the WB entry! - if (lineaddr != physical_address) { - warn("error: StoreBuffer: ruby returns pa 0x%0llx " - "which is not a cache line: 0x%0llx\n", - physical_address, lineaddr); - } - - SBEntry from_buffer = buffer.back(); - if ((from_buffer.m_request.paddr & m_block_mask) == lineaddr && - from_buffer.m_request.type == type) { - buffer.pop_back(); - m_buffer_size--; - assert(m_buffer_size >= 0); - - // schedule the next request - if (m_buffer_size > 0) { - issueNextStore(); - } else if (m_buffer_size == 0) { - m_storebuffer_flushing = false; - m_stalled_issue = true; - } - - m_storebuffer_full = false; - } else { - panic("[%d] error: StoreBuffer: at complete, address 0x%0llx " - "not found.\n" - "StoreBuffer:: complete FAILS\n", - m_id, lineaddr); - } - - } else if (type == RubyRequestType_LD) { - m_hit_callback(id); - } - - // LD, ST or FETCH hit callback - outstanding_requests.erase(id); -} - -void -StoreBuffer::print() -{ - DPRINTF(RubyStorebuffer, "[%d] StoreBuffer: Total entries: %d " - "Outstanding: %d\n", - m_id, m_storebuffer_size, m_buffer_size); - - if (!m_use_storebuffer) - DPRINTF(RubyStorebuffer, "\t WRITE BUFFER NOT USED\n"); -} diff --git a/src/mem/ruby/storebuffer/storebuffer.hh b/src/mem/ruby/storebuffer/storebuffer.hh deleted file mode 100644 index b2b8483fd..000000000 --- a/src/mem/ruby/storebuffer/storebuffer.hh +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer; - * redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution; - * neither the name of the copyright holders nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __MEM_RUBY_STOREBUFFER_STOREBUFFER_HH__ -#define __MEM_RUBY_STOREBUFFER_STOREBUFFER_HH__ - -#include -#include - -#include "mem/ruby/common/TypeDefines.hh" -#include "mem/ruby/slicc_interface/RubyRequest.hh" - -/** - * Status for write buffer accesses. The Write buffer can hit in - * fastpath, be full, or successfully enqueue the store request - */ -enum storebuffer_status_t { WB_FULL, WB_OK, WB_FLUSHING }; - -/** - * Status of a load match - */ -enum load_match { NO_MATCH, PARTIAL_MATCH, FULL_MATCH }; - -struct SBEntry -{ - RubyRequest m_request; - - SBEntry(RubyRequest request, void * ptr) - : m_request(request) - { - } -}; - -class StoreBuffer -{ - public: - /// Note that the size of the Write Buffer is determined by the - /// WRITE_BUFFER_SIZE config parameter - StoreBuffer(uint32_t id, uint32_t block_bits, int storebuffer_size); - - ~StoreBuffer(); - - /// Register hitcallback back to CPU - void registerHitCallback(void (*hit_callback)(int64_t request_id)); - - ///Adds a store entry to the write buffer - void addToStoreBuffer(RubyRequest request); - - ///Flushes the entire write buffer - void flushStoreBuffer(); - - ///A pseq object calls this when Ruby completes our request - void complete(uint64_t); - - /// Returns ID. If ID == -2, HIT, else it's an ID to wait on - int64_t handleLoad(RubyRequest request); - - /// Used by all load insts to check whether it hits to any entry - /// in the WB. If so, the WB is flushed - load_match checkForLoadHit(RubyRequest request); - - /// Used to fill the load in case of FULL_MATCH - void returnMatchedData(RubyRequest request); - - /// Issue next store in line - void issueNextStore(); - - /// prints out the contents of the Write Buffer - void print(); - - /// Returns flag indicating whether we are using the write buffer - bool useStoreBuffer() { return m_use_storebuffer; } - - bool storeBufferFull() { return m_storebuffer_full; } - - bool storeBufferFlushing() { return m_storebuffer_flushing; } - - private: - /// id of this write buffer (one per sequencer object) - uint32_t m_id; - - /// number of bytes in cacheline - uint32_t m_block_size; - - /// the size of the write buffer - uint32_t m_storebuffer_size; - - /// mask to strip off non-cache line bits - pa_t m_block_mask; - - /// list of store requests in the write buffer - std::deque buffer; - - /// the current length of the write buffer - uint32_t m_buffer_size; - - /// whether we want to simulate the write buffer or not: - bool m_use_storebuffer; - - /// indicates whether the write buffer is full or not - bool m_storebuffer_full; - - /// indicates that we are currently flushing the write buffer - bool m_storebuffer_flushing; - - /// indicates that automatic issue is stalled and the next store - /// to be added should issue itself - bool m_stalled_issue; - - /// RubyPort to make requests to - RubyPortHandle m_port; - - /// HitCallback to CPU - void (*m_hit_callback)(int64_t); - - /// Map the request id to rubyrequest - std::map outstanding_requests; - - /// current instruction counter - uint64_t iseq; - - /// input into tso counter - uint64_t tso_iseq; -}; - -#endif // __MEM_RUBY_STOREBUFFER_STOREBUFFER_HH__ -- 2.30.2