changeset bd7d06ea90f5 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=bd7d06ea90f5
description:
        mem: write combining for ruby protocols

        This patch adds support for write-combining in ruby.

diffstat:

 src/mem/protocol/RubySlicc_Exports.sm          |   13 +
 src/mem/protocol/RubySlicc_Types.sm            |    2 +
 src/mem/ruby/SConscript                        |    1 +
 src/mem/ruby/common/DataBlock.cc               |   27 +++
 src/mem/ruby/common/DataBlock.hh               |    6 +
 src/mem/ruby/common/SConscript                 |    1 +
 src/mem/ruby/common/WriteMask.cc               |   46 +++++
 src/mem/ruby/common/WriteMask.hh               |  202 +++++++++++++++++++++++++
 src/mem/ruby/slicc_interface/RubyRequest.hh    |    7 +
 src/mem/ruby/slicc_interface/RubySlicc_Util.hh |   38 ++++
 10 files changed, 343 insertions(+), 0 deletions(-)

diffs (truncated from 498 to 300 lines):

diff -r a5340a2a24f9 -r bd7d06ea90f5 src/mem/protocol/RubySlicc_Exports.sm
--- a/src/mem/protocol/RubySlicc_Exports.sm     Tue Jan 19 13:57:50 2016 -0500
+++ b/src/mem/protocol/RubySlicc_Exports.sm     Tue Jan 19 14:05:03 2016 -0500
@@ -39,12 +39,25 @@
 external_type(Cycles, primitive="yes", default="Cycles(0)");
 external_type(Tick, primitive="yes", default="0");
 
+structure(WriteMask, external="yes", desc="...") {
+  void clear();
+  bool cmpMask(WriteMask);
+  bool isEmpty();
+  bool isFull();
+  bool isOverlap(WriteMask);
+  void orMask(WriteMask);
+  void fillMask();
+}
+
 structure(DataBlock, external = "yes", desc="..."){
   void clear();
+  void copyPartial(DataBlock, int, int);
+  void copyPartial(DataBlock, WriteMask);
   void atomicPartial(DataBlock, WriteMask);
 }
 
 bool testAndRead(Addr addr, DataBlock datablk, Packet *pkt);
+bool testAndReadMask(Addr addr, DataBlock datablk, WriteMask mask, Packet 
*pkt);
 bool testAndWrite(Addr addr, DataBlock datablk, Packet *pkt);
 
 // AccessPermission
diff -r a5340a2a24f9 -r bd7d06ea90f5 src/mem/protocol/RubySlicc_Types.sm
--- a/src/mem/protocol/RubySlicc_Types.sm       Tue Jan 19 13:57:50 2016 -0500
+++ b/src/mem/protocol/RubySlicc_Types.sm       Tue Jan 19 14:05:03 2016 -0500
@@ -126,6 +126,8 @@
   int Size,                  desc="size in bytes of access";
   PrefetchBit Prefetch,      desc="Is this a prefetch request";
   int contextId,             desc="this goes away but must be replace with 
Nilay";
+  WriteMask writeMask,       desc="Writethrough mask";
+  DataBlock WTData,          desc="Writethrough data block";
   int wfid,                  desc="Writethrough wavefront";
   HSAScope scope,            desc="HSA scope";
   HSASegment segment,        desc="HSA segment";
diff -r a5340a2a24f9 -r bd7d06ea90f5 src/mem/ruby/SConscript
--- a/src/mem/ruby/SConscript   Tue Jan 19 13:57:50 2016 -0500
+++ b/src/mem/ruby/SConscript   Tue Jan 19 14:05:03 2016 -0500
@@ -121,6 +121,7 @@
 MakeInclude('common/MachineID.hh')
 MakeInclude('common/NetDest.hh')
 MakeInclude('common/Set.hh')
+MakeInclude('common/WriteMask.hh')
 MakeInclude('filters/AbstractBloomFilter.hh')
 MakeInclude('network/MessageBuffer.hh')
 MakeInclude('structures/Prefetcher.hh')
diff -r a5340a2a24f9 -r bd7d06ea90f5 src/mem/ruby/common/DataBlock.cc
--- a/src/mem/ruby/common/DataBlock.cc  Tue Jan 19 13:57:50 2016 -0500
+++ b/src/mem/ruby/common/DataBlock.cc  Tue Jan 19 14:05:03 2016 -0500
@@ -27,6 +27,8 @@
  */
 
 #include "mem/ruby/common/DataBlock.hh"
+
+#include "mem/ruby/common/WriteMask.hh"
 #include "mem/ruby/system/RubySystem.hh"
 
 DataBlock::DataBlock(const DataBlock &cp)
@@ -57,6 +59,25 @@
 }
 
 void
+DataBlock::copyPartial(const DataBlock &dblk, const WriteMask &mask)
+{
+    for (int i = 0; i < RubySystem::getBlockSizeBytes(); i++) {
+        if (mask.getMask(i, 1)) {
+            m_data[i] = dblk.m_data[i];
+        }
+    }
+}
+
+void
+DataBlock::atomicPartial(const DataBlock &dblk, const WriteMask &mask)
+{
+    for (int i = 0; i < RubySystem::getBlockSizeBytes(); i++) {
+        m_data[i] = dblk.m_data[i];
+    }
+    mask.performAtomic(m_data);
+}
+
+void
 DataBlock::print(std::ostream& out) const
 {
     using namespace std;
@@ -77,6 +98,12 @@
     return &m_data[offset];
 }
 
+uint8_t*
+DataBlock::getDataMod(int offset)
+{
+    return &m_data[offset];
+}
+
 void
 DataBlock::setData(const uint8_t *data, int offset, int len)
 {
diff -r a5340a2a24f9 -r bd7d06ea90f5 src/mem/ruby/common/DataBlock.hh
--- a/src/mem/ruby/common/DataBlock.hh  Tue Jan 19 13:57:50 2016 -0500
+++ b/src/mem/ruby/common/DataBlock.hh  Tue Jan 19 14:05:03 2016 -0500
@@ -35,6 +35,8 @@
 #include <iomanip>
 #include <iostream>
 
+class WriteMask;
+
 class DataBlock
 {
   public:
@@ -58,8 +60,12 @@
     void clear();
     uint8_t getByte(int whichByte) const;
     const uint8_t *getData(int offset, int len) const;
+    uint8_t *getDataMod(int offset);
     void setByte(int whichByte, uint8_t data);
     void setData(const uint8_t *data, int offset, int len);
+    void copyPartial(const DataBlock &dblk, int offset, int len);
+    void copyPartial(const DataBlock &dblk, const WriteMask &mask);
+    void atomicPartial(const DataBlock & dblk, const WriteMask & mask);
     bool equal(const DataBlock& obj) const;
     void print(std::ostream& out) const;
 
diff -r a5340a2a24f9 -r bd7d06ea90f5 src/mem/ruby/common/SConscript
--- a/src/mem/ruby/common/SConscript    Tue Jan 19 13:57:50 2016 -0500
+++ b/src/mem/ruby/common/SConscript    Tue Jan 19 14:05:03 2016 -0500
@@ -41,3 +41,4 @@
 Source('IntVec.cc')
 Source('NetDest.cc')
 Source('SubBlock.cc')
+Source('WriteMask.cc')
diff -r a5340a2a24f9 -r bd7d06ea90f5 src/mem/ruby/common/WriteMask.cc
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mem/ruby/common/WriteMask.cc  Tue Jan 19 14:05:03 2016 -0500
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2012-2015 Advanced Micro Devices, Inc.
+ * 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/common/WriteMask.hh"
+
+#include <string>
+
+#include "mem/ruby/system/RubySystem.hh"
+
+void
+WriteMask::print(std::ostream& out) const
+{
+    std::string str(mSize,'0');
+    for (int i = 0; i < mSize; i++) {
+        str[i] = mMask[i] ? ('1') : ('0');
+    }
+    out << "dirty mask="
+        << str
+        << std::flush;
+}
+
diff -r a5340a2a24f9 -r bd7d06ea90f5 src/mem/ruby/common/WriteMask.hh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mem/ruby/common/WriteMask.hh  Tue Jan 19 14:05:03 2016 -0500
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2012-15 Advanced Micro Devices, Inc.
+ * 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_COMMON_WRITEMASK_HH__
+#define __MEM_RUBY_COMMON_WRITEMASK_HH__
+
+#include <cassert>
+#include <iomanip>
+#include <iostream>
+#include <vector>
+
+#include "mem/ruby/common/TypeDefines.hh"
+#include "mem/ruby/system/RubySystem.hh"
+
+class WriteMask
+{
+  public:
+    WriteMask()
+      : mSize(RubySystem::getBlockSizeBytes()), mMask(mSize, false),
+        mAtomic(false)
+    {}
+
+    WriteMask(int size)
+      : mSize(size), mMask(size, false), mAtomic(false)
+    {}
+
+    WriteMask(int size, std::vector<bool> & mask)
+      : mSize(size), mMask(mask), mAtomic(false)
+    {}
+
+    WriteMask(int size, std::vector<bool> &mask,
+              std::vector<std::pair<int, AtomicOpFunctor*> > atomicOp)
+      : mSize(size), mMask(mask), mAtomic(true), mAtomicOp(atomicOp)
+    {}
+
+    ~WriteMask()
+    {}
+
+    void
+    clear()
+    {
+        mMask = std::vector<bool>(mSize, false);
+    }
+
+    bool
+    test(int offset)
+    {
+        assert(offset < mSize);
+        return mMask[offset] == true;
+    }
+
+    void
+    setMask(int offset, int len)
+    {
+        assert(mSize >= (offset + len));
+        for (int i = 0; i < len; i++) {
+            mMask[offset + i] = true;
+        }
+    }
+    void
+    fillMask()
+    {
+        for (int i = 0; i < mSize; i++) {
+            mMask[i] = true;
+        }
+    }
+
+    bool
+    getMask(int offset, int len) const
+    {
+        bool tmp = true;
+        assert(mSize >= (offset + len));
+        for (int i = 0; i < len; i++) {
+            tmp = tmp & mMask.at(offset + i);
+        }
+        return tmp;
+    }
+
+    bool
+    isOverlap(const WriteMask &readMask) const
+    {
+        bool tmp = false;
+        assert(mSize == readMask.mSize);
+        for (int i = 0; i < mSize; i++) {
+            if (readMask.mMask.at(i)) {
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to