Skip to content

Commit

Permalink
remove OuterCohPortMultiThreadSupport
Browse files Browse the repository at this point in the history
  • Loading branch information
wsong83 committed Jun 27, 2024
1 parent 72db9d8 commit 9634d79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 52 deletions.
62 changes: 11 additions & 51 deletions cache/coherence_multi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<CMMetadataBase *, CMDataBase *, uint32_t, uint32_t, uint32_t, bool>
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<true>, public OuterCohPortMultiThreadSupport
{
public:
OuterCohPortMultiThreadUncached(policy_ptr policy) : OuterCohPortUncached<true>(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 <class OPUC, typename IT, typename CT>
requires C_DERIVE<IT, InnerCohPortMultiThreadSupport, InnerCohPortBase>
Expand All @@ -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<IT*>(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<bool,bool> probe_resp(uint64_t addr, CMMetadataBase *meta_outer, CMDataBase *data_outer, coh_cmd_t outer_cmd, uint64_t *delay){
Expand Down Expand Up @@ -188,10 +148,10 @@ class OuterCohPortMultiThreadT : public OPUC

template <typename IT, typename CT>
requires C_DERIVE<IT, InnerCohPortBase, InnerCohPortMultiThreadSupport>
using OuterCohMultiThreadPort = OuterCohPortMultiThreadT<OuterCohPortMultiThreadUncached, IT, CT>;
using OuterCohMultiThreadPort = OuterCohPortMultiThreadT<OuterCohPortUncached<true>, IT, CT>;

template <typename OT, typename CT, typename CPT>
requires C_DERIVE<OT, OuterCohPortBase, OuterCohPortMultiThreadSupport>
requires C_DERIVE<OT, OuterCohPortBase>
&& C_DERIVE<CPT, CohPolicyBase, CohPolicyMultiThreadSupport>
class InnerCohPortMultiThreadUncached : public InnerCohPortUncached<true>, public InnerCohPortMultiThreadSupport
{
Expand Down Expand Up @@ -314,7 +274,7 @@ class InnerCohPortMultiThreadUncached : public InnerCohPortUncached<true>, publi
}

/** After the upper-level cache modifies the meta, an acquire_ack request is sent to the lower-level cache */
(static_cast<OT *>(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
Expand All @@ -331,7 +291,7 @@ class InnerCohPortMultiThreadUncached : public InnerCohPortUncached<true>, 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){
Expand Down Expand Up @@ -374,12 +334,12 @@ class InnerCohPortMultiThreadT : public IPUC
};

template <typename OT, typename CT, typename CPT>
requires C_DERIVE<OT, OuterCohPortBase, OuterCohPortMultiThreadSupport>
requires C_DERIVE<OT, OuterCohPortBase>
&& C_DERIVE<CPT, CohPolicyBase, CohPolicyMultiThreadSupport>
using InnerCohMultiThreadPort = InnerCohPortMultiThreadT<InnerCohPortMultiThreadUncached<OT, CT, CPT> >;

template <typename OT, typename CT, typename CPT>
requires C_DERIVE<OT, OuterCohPortBase, OuterCohPortMultiThreadSupport>
requires C_DERIVE<OT, OuterCohPortBase>
&& C_DERIVE<CPT, CohPolicyBase, CohPolicyMultiThreadSupport>
class CoreMultiThreadInterface : public InnerCohPortMultiThreadUncached<OT, CT, CPT>, public CoreInterfaceBase
{
Expand All @@ -405,7 +365,7 @@ class CoreMultiThreadInterface : public InnerCohPortMultiThreadUncached<OT, CT,

/** Uncached cache will not issue an ack request */
auto ack = policy->acquire_need_ack(outer->is_uncached());
if(ack.first) (static_cast<OT *>(outer))->acquire_ack_req(addr, ack.second, delay);
outer->finish_req(addr);

meta->unlock();
cache->reset_mt_state(ai, s, Priority::read);
Expand All @@ -424,7 +384,7 @@ class CoreMultiThreadInterface : public InnerCohPortMultiThreadUncached<OT, CT,
cache->hook_write(addr, ai, s, w, hit, false, meta, data, delay);

auto ack = policy->acquire_need_ack(outer->is_uncached());
if(ack.first) (static_cast<OT *>(outer))->acquire_ack_req(addr, ack.second, delay);
outer->finish_req(addr);

meta->unlock();
cache->reset_mt_state(ai, s, Priority::read);
Expand Down
2 changes: 1 addition & 1 deletion util/cache_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ inline auto cache_multi_thread_type_compile(int size, const std::string& name_pr

typedef CacheNormMultiThread<IW, WN, metadata_type, DT, index_type, replace_type, DLY, EnMon> cache_base_type;

typedef OuterCohPortMultiThreadUncached uncached_output_type;
typedef OuterCohPortUncached<true> uncached_output_type;

typedef typename std::conditional<isL1, CoreMultiThreadInterface<uncached_output_type, cache_base_type, policy_type>,
InnerCohMultiThreadPort<uncached_output_type, cache_base_type, policy_type>>::type input_type;
Expand Down

0 comments on commit 9634d79

Please sign in to comment.