Jordi Vaquero has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/20208 )

Change subject: mem-cache: implementation of in_mem amo_policy.
......................................................................

mem-cache: implementation of in_mem amo_policy.

Implementation in_mem amo_policy where all the atomic
operations are skipped in cache and moved to memory.

Change-Id: I2da1485a05f090267ea3cdf3d4d08a9d2be9296c
---
M src/mem/cache/Cache.py
A src/mem/cache/amo_policy/AmoPolicy.py
A src/mem/cache/amo_policy/SConscript
A src/mem/cache/amo_policy/base.hh
A src/mem/cache/amo_policy/in_mem.cc
A src/mem/cache/amo_policy/in_mem.hh
M src/mem/cache/base.cc
M src/mem/cache/base.hh
8 files changed, 313 insertions(+), 3 deletions(-)



diff --git a/src/mem/cache/Cache.py b/src/mem/cache/Cache.py
index 7a28136..15beaf7 100644
--- a/src/mem/cache/Cache.py
+++ b/src/mem/cache/Cache.py
@@ -48,6 +48,7 @@
 from m5.objects.Prefetcher import BasePrefetcher
 from m5.objects.ReplacementPolicies import *
 from m5.objects.Tags import *
+from m5.objects.AmoPolicy import *

 # Enum for cache clusivity, currently mostly inclusive or mostly
 # exclusive.
@@ -118,6 +119,10 @@

     system = Param.System(Parent.any, "System we belong to")

+    amo_policy = Param.BaseAmoPolicy(InMemAmoPolicy(),
+            'AMO instruction policy')
+
+
     # Determine if this cache sends out writebacks for clean lines, or
     # simply clean evicts. In cases where a downstream cache is mostly
     # exclusive with respect to this cache (acting as a victim cache),
diff --git a/src/mem/cache/amo_policy/AmoPolicy.py b/src/mem/cache/amo_policy/AmoPolicy.py
new file mode 100644
index 0000000..bb1b383
--- /dev/null
+++ b/src/mem/cache/amo_policy/AmoPolicy.py
@@ -0,0 +1,52 @@
+# Copyright (c) 2019 Metempsy Technologies
+# All rights reserved.
+#
+# The license below extends only to copyright in the software and shall
+# not be construed as granting a license to any other intellectual
+# property including but not limited to intellectual property relating
+# to a hardware implementation of the functionality of the software
+# licensed hereunder.  You may use the software subject to the license
+# terms below provided that you ensure that this notice is replicated
+# unmodified and in its entirety in all distributions of the software,
+# modified or unmodified, in source code or in binary form.
+#
+# 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: Jordi Vaquero
+
+from m5.SimObject import *
+from m5.params import *
+from m5.proxy import *
+
+
+class BaseAmoPolicy(SimObject):
+    type = 'BaseAmoPolicy'
+    abstract = True
+    cxx_header = "mem/cache/amo_policy/base.hh"
+
+class InMemAmoPolicy(BaseAmoPolicy):
+    type = 'InMemAmoPolicy'
+    cxx_class = 'InMemAmoPolicy'
+    cxx_header = "mem/cache/amo_policy/in_mem.hh"
+
diff --git a/src/mem/cache/amo_policy/SConscript b/src/mem/cache/amo_policy/SConscript
new file mode 100644
index 0000000..107f993
--- /dev/null
+++ b/src/mem/cache/amo_policy/SConscript
@@ -0,0 +1,35 @@
+# -*- mode:python -*-
+
+# Copyright (c) 2019 Metempsy Technologies
+# 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: Jordi Vaquero
+
+Import('*')
+
+SimObject('AmoPolicy.py')
+
+Source('in_mem.cc')
diff --git a/src/mem/cache/amo_policy/base.hh b/src/mem/cache/amo_policy/base.hh
new file mode 100644
index 0000000..e3e23f1
--- /dev/null
+++ b/src/mem/cache/amo_policy/base.hh
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2019 Metempsy Technologies
+ * All rights reserved.
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder.  You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
+ * 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: Jordi Vaquero
+ */
+
+#ifndef __MEM_CACHE_AMOPOLICIES_BASE_HH__
+#define __MEM_CACHE_AMOPOLICIES_BASE_HH__
+
+#include <memory>
+
+#include "mem/cache/base.hh"
+#include "mem/cache/cache_blk.hh"
+#include "mem/packet.hh"
+#include "params/BaseAmoPolicy.hh"
+#include "sim/sim_object.hh"
+
+/**
+ * A common base class of cache replacement policy objects.
+ */
+class BaseAmoPolicy : public SimObject
+{
+  public:
+    /**
+      * Convenience typedef.
+      */
+    typedef BaseAmoPolicyParams Params;
+
+    /**
+     * Construct and initiliaze this amo Operation policy.
+     */
+    BaseAmoPolicy(const Params *p) : SimObject(p) {}
+
+    /**
+     * Destructor.
+     */
+    virtual ~BaseAmoPolicy() {}
+
+
+    virtual bool satisfyPolicy(Packet* pkt) const = 0;
+
+    virtual bool checkPolicy(Packet* pkt, CacheBlk* blk) const = 0 ;
+};
+
+#endif // __MEM_CACHE_AMOPOLICIES_BASE_HH__
diff --git a/src/mem/cache/amo_policy/in_mem.cc b/src/mem/cache/amo_policy/in_mem.cc
new file mode 100644
index 0000000..59eadc5
--- /dev/null
+++ b/src/mem/cache/amo_policy/in_mem.cc
@@ -0,0 +1,58 @@
+ /**
+  * Copyright (c) 2019 Metempsy Technologies
+  * 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: Jordi Vaquero
+  */
+#include "mem/cache/amo_policy/in_mem.hh"
+
+#include <memory>
+
+#include "mem/packet.hh"
+#include "params/InMemAmoPolicy.hh"
+
+InMemAmoPolicy::InMemAmoPolicy(const Params *p)
+    : BaseAmoPolicy(p)
+{
+}
+
+bool
+InMemAmoPolicy::satisfyPolicy(Packet* pkt) const
+{
+    return true;
+}
+
+bool
+InMemAmoPolicy::checkPolicy(Packet* pkt, CacheBlk* blk) const
+{
+    return invalidateInCache;
+}
+
+InMemAmoPolicy*
+InMemAmoPolicyParams::create()
+{
+    return new InMemAmoPolicy(this);
+}
diff --git a/src/mem/cache/amo_policy/in_mem.hh b/src/mem/cache/amo_policy/in_mem.hh
new file mode 100644
index 0000000..faf688f
--- /dev/null
+++ b/src/mem/cache/amo_policy/in_mem.hh
@@ -0,0 +1,70 @@
+/**
+ * Copyright (c) 2019 Metempsy Technologies
+ * 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: Jordi Vaquero
+ */
+
+/**
+ * @file
+ * Declaration of the WriteTrough atomic memory operation policy.
+ * When a change is done the updated value is sent to memory right away.
+ */
+
+#ifndef __MEM_AMO_POLICY_WRTAMOOP_HH__
+#define __MEM_AMO_POLICY_WRTAMOOP_HH__
+
+#include "base/types.hh"
+#include "mem/cache/amo_policy/base.hh"
+#include "mem/cache/base.hh"
+#include "mem/cache/cache_blk.hh"
+#include "mem/packet.hh"
+
+struct InMemAmoPolicyParams;
+
+class InMemAmoPolicy : public BaseAmoPolicy
+{
+  private:
+    bool invalidateInCache = true ;
+
+  public:
+    typedef InMemAmoPolicyParams Params;
+
+    /**
+     * Construct and initiliaze this amo Operation policy.
+     */
+    InMemAmoPolicy(const Params *p);
+
+    /**
+     * Destructor.
+     */
+    ~InMemAmoPolicy() {}
+
+    bool satisfyPolicy(Packet* pkt) const override;
+    bool checkPolicy(Packet* pkt, CacheBlk* blk) const override ;
+};
+
+#endif //__MEM_AMO_POLICY_WRTAMOOP_HH__
diff --git a/src/mem/cache/base.cc b/src/mem/cache/base.cc
index 0de7f21..c407a18 100644
--- a/src/mem/cache/base.cc
+++ b/src/mem/cache/base.cc
@@ -55,6 +55,7 @@
 #include "debug/CachePort.hh"
 #include "debug/CacheRepl.hh"
 #include "debug/CacheVerbose.hh"
+#include "mem/cache/amo_policy/base.hh"
 #include "mem/cache/compressors/base.hh"
 #include "mem/cache/mshr.hh"
 #include "mem/cache/prefetch/base.hh"
@@ -88,6 +89,7 @@
       tags(p->tags),
       compressor(p->compressor),
       prefetcher(p->prefetcher),
+      amoPolicy(p->amo_policy),
       writeAllocator(p->write_allocator),
       writebackClean(p->writeback_clean),
       tempBlockWriteback(nullptr),
@@ -1299,11 +1301,17 @@
         } else {
             lat = calculateTagOnlyLatency(pkt->headerDelay, tag_latency);
         }
+        if (!pkt->isAtomicOp() ||
+            (pkt->isAtomicOp() && amoPolicy->checkPolicy(pkt, blk))){

-        satisfyRequest(pkt, blk);
-        maintainClusivity(pkt->fromCache(), blk);
+            satisfyRequest(pkt, blk);
+            maintainClusivity(pkt->fromCache(), blk);
+            return amoPolicy->satisfyPolicy(pkt);
+        } else if (pkt->isAtomicOp()){
+            evictBlock(blk, writebacks);
+            return false ;
+        }

-        return true;
     }

     // Can't satisfy access normally... either no block (blk == nullptr)
diff --git a/src/mem/cache/base.hh b/src/mem/cache/base.hh
index 8794829..8675718 100644
--- a/src/mem/cache/base.hh
+++ b/src/mem/cache/base.hh
@@ -87,6 +87,7 @@
 class MSHR;
 class MasterPort;
 class QueueEntry;
+class BaseAmoPolicy;
 struct BaseCacheParams;

 /**
@@ -331,6 +332,9 @@
     /** Prefetcher */
     BasePrefetcher *prefetcher;

+    /** Atomic Memory operation Policy **/
+    BaseAmoPolicy *amoPolicy;
+
     /** To probe when a cache hit occurs */
     ProbePointArg<PacketPtr> *ppHit;


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/20208
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I2da1485a05f090267ea3cdf3d4d08a9d2be9296c
Gerrit-Change-Number: 20208
Gerrit-PatchSet: 1
Gerrit-Owner: Jordi Vaquero <jordi.vaqu...@metempsy.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to