diff --git a/cache/coherence_multi.hpp b/cache/coherence_multi.hpp index 1b86837..1ede8e7 100644 --- a/cache/coherence_multi.hpp +++ b/cache/coherence_multi.hpp @@ -75,21 +75,6 @@ class InnerAddressDataMap }; -///////////////////////////////// -// Multi-thread support for outer ports -class OuterCohPortMultiThreadSupport -{ -public: - OuterCohPortMultiThreadSupport() {} - virtual ~OuterCohPortMultiThreadSupport() {} - - //virtual void acquire_req(uint64_t addr, CMMetadataBase *meta, CMDataBase *data, coh_cmd_t cmd, - // uint64_t *delay, uint32_t ai, uint32_t s, uint32_t w) = 0; - // Compared to single thread, multi-threaded adds an 'acquire ack' mechanism - virtual void acquire_ack_req(uint64_t addr, coh_cmd_t cmd, uint64_t* delay) {} - -}; - ///////////////////////////////// // Multi-thread support for inner ports class InnerCohPortMultiThreadSupport @@ -98,36 +83,11 @@ class InnerCohPortMultiThreadSupport InnerCohPortMultiThreadSupport() {} virtual ~InnerCohPortMultiThreadSupport() {} - virtual void acquire_ack_resp(uint64_t addr, coh_cmd_t cmd, uint64_t *delay) = 0; - protected: virtual std::tuple access_line_multithread(uint64_t addr, coh_cmd_t cmd, uint64_t *delay) = 0; }; -// common behvior for multi-thread uncached outer ports -class OuterCohPortMultiThreadUncached : public OuterCohPortUncached, public OuterCohPortMultiThreadSupport -{ -public: - OuterCohPortMultiThreadUncached(policy_ptr policy) : OuterCohPortUncached(policy), OuterCohPortMultiThreadSupport() {} - virtual ~OuterCohPortMultiThreadUncached() {} - - // virtual void acquire_req(uint64_t addr, CMMetadataBase *meta, CMDataBase *data, coh_cmd_t outer_cmd, - // uint64_t *delay, uint32_t ai, uint32_t s, uint32_t w) - // { - // outer_cmd.id = coh_id; - // /** When issuing an acquire request to the lower-level cache, need to unlock the cacheline mutex. */ - // meta->unlock(); - - // coh->acquire_resp(addr, data, meta->get_outer_meta(), outer_cmd, delay); - - // /** When receiving an acquire response from the lower-level cache, re-lock the cacheline mutex. */ - // meta->lock(); - // policy->meta_after_fetch(outer_cmd, meta, addr); - // } - -}; - // common behavior for cached outer ports template requires C_DERIVE @@ -144,9 +104,9 @@ class OuterCohPortMultiThreadT : public OPUC OuterCohPortMultiThreadT(policy_ptr policy) : OPUC(policy) {} virtual ~OuterCohPortMultiThreadT() {} - virtual void acquire_ack_req(uint64_t addr, coh_cmd_t outer_cmd, uint64_t* delay){ - outer_cmd.id = coh_id; - (static_cast(coh))->acquire_ack_resp(addr, outer_cmd, delay); + virtual void finish_req(uint64_t addr){ + assert(!this->is_uncached()); + OuterCohPortBase::coh->finish_resp(addr, this->policy->cmd_for_finish(coh_id)); } virtual std::pair probe_resp(uint64_t addr, CMMetadataBase *meta_outer, CMDataBase *data_outer, coh_cmd_t outer_cmd, uint64_t *delay){ @@ -188,10 +148,10 @@ class OuterCohPortMultiThreadT : public OPUC template requires C_DERIVE -using OuterCohMultiThreadPort = OuterCohPortMultiThreadT; +using OuterCohMultiThreadPort = OuterCohPortMultiThreadT, IT, CT>; template - requires C_DERIVE + requires C_DERIVE && C_DERIVE class InnerCohPortMultiThreadUncached : public InnerCohPortUncached, public InnerCohPortMultiThreadSupport { @@ -314,7 +274,7 @@ class InnerCohPortMultiThreadUncached : public InnerCohPortUncached, publi } /** After the upper-level cache modifies the meta, an acquire_ack request is sent to the lower-level cache */ - (static_cast(outer))->acquire_ack_req(addr, (p_policy->cmd_for_acquire_ack()), delay); + outer->finish_req(addr); /** * If the upper-level cache is uncached, the lower-level cache can modify the state @@ -331,7 +291,7 @@ class InnerCohPortMultiThreadUncached : public InnerCohPortUncached, publi } } - virtual void acquire_ack_resp(uint64_t addr, coh_cmd_t cmd, uint64_t* delay){ + virtual void finish_resp(uint64_t addr, coh_cmd_t cmd){ /** query whether the information of this address exists in the database */ auto info = database->query(cmd.id, addr); if(info.first){ @@ -374,12 +334,12 @@ class InnerCohPortMultiThreadT : public IPUC }; template - requires C_DERIVE + requires C_DERIVE && C_DERIVE using InnerCohMultiThreadPort = InnerCohPortMultiThreadT >; template - requires C_DERIVE + requires C_DERIVE && C_DERIVE class CoreMultiThreadInterface : public InnerCohPortMultiThreadUncached, public CoreInterfaceBase { @@ -405,7 +365,7 @@ class CoreMultiThreadInterface : public InnerCohPortMultiThreadUncachedacquire_need_ack(outer->is_uncached()); - if(ack.first) (static_cast(outer))->acquire_ack_req(addr, ack.second, delay); + outer->finish_req(addr); meta->unlock(); cache->reset_mt_state(ai, s, Priority::read); @@ -424,7 +384,7 @@ class CoreMultiThreadInterface : public InnerCohPortMultiThreadUncachedhook_write(addr, ai, s, w, hit, false, meta, data, delay); auto ack = policy->acquire_need_ack(outer->is_uncached()); - if(ack.first) (static_cast(outer))->acquire_ack_req(addr, ack.second, delay); + outer->finish_req(addr); meta->unlock(); cache->reset_mt_state(ai, s, Priority::read); diff --git a/util/cache_type.hpp b/util/cache_type.hpp index 6041b41..152d993 100644 --- a/util/cache_type.hpp +++ b/util/cache_type.hpp @@ -208,7 +208,7 @@ inline auto cache_multi_thread_type_compile(int size, const std::string& name_pr typedef CacheNormMultiThread cache_base_type; - typedef OuterCohPortMultiThreadUncached uncached_output_type; + typedef OuterCohPortUncached uncached_output_type; typedef typename std::conditional, InnerCohMultiThreadPort>::type input_type;