Skip to content

Commit

Permalink
simplify the support of finish
Browse files Browse the repository at this point in the history
  • Loading branch information
wsong83 committed Jun 5, 2024
1 parent eebd478 commit 313c2a8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 28 deletions.
2 changes: 0 additions & 2 deletions cache/coh_policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ class CohPolicyBase {
return std::make_pair(false, cmd_for_null());
}

// finish
virtual bool finish_need_req() const = 0;
};

#endif
37 changes: 18 additions & 19 deletions cache/coherence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ class OuterCohPortBase

virtual void acquire_req(uint64_t addr, CMMetadataBase *meta, CMDataBase *data, coh_cmd_t cmd, uint64_t *delay) = 0;
virtual void writeback_req(uint64_t addr, CMMetadataBase *meta, CMDataBase *data, coh_cmd_t cmd, uint64_t *delay) = 0;
virtual std::pair<bool, bool> probe_resp(uint64_t addr, CMMetadataBase *meta, CMDataBase *data, coh_cmd_t cmd, uint64_t *delay) { return std::make_pair(false,false); } // may not implement if not supported

// may not implement probe_resp() and finish_req() if the port is uncached
virtual std::pair<bool, bool> probe_resp(uint64_t addr, CMMetadataBase *meta, CMDataBase *data, coh_cmd_t cmd, uint64_t *delay) { return std::make_pair(false,false); }
virtual void finish_req(uint64_t addr) {}

bool is_uncached() const { return coh_id == -1; }
virtual void query_loc_req(uint64_t addr, std::list<LocInfo> *locs) = 0;

virtual void finish_req(uint64_t addr) = 0;

friend CoherentCacheBase; // deferred assignment for cache
};

Expand Down Expand Up @@ -73,11 +73,12 @@ class InnerCohPortBase

virtual void acquire_resp(uint64_t addr, CMDataBase *data_inner, CMMetadataBase *meta_inner, coh_cmd_t outer_cmd, uint64_t *delay) = 0;
virtual void writeback_resp(uint64_t addr, CMDataBase *data_inner, CMMetadataBase *meta_inner, coh_cmd_t cmd, uint64_t *delay) = 0;
virtual std::pair<bool,bool> probe_req(uint64_t addr, CMMetadataBase *meta, CMDataBase *data, coh_cmd_t cmd, uint64_t *delay) { return std::make_pair(false,false); } // may not implement if not supported

virtual void query_loc_resp(uint64_t addr, std::list<LocInfo> *locs) = 0;

// may not implement probe_req() and finish_resp() if the port is uncached
virtual std::pair<bool,bool> probe_req(uint64_t addr, CMMetadataBase *meta, CMDataBase *data, coh_cmd_t cmd, uint64_t *delay) { return std::make_pair(false,false); }
virtual void finish_resp(uint64_t addr) {};

virtual void query_loc_resp(uint64_t addr, std::list<LocInfo> *locs) = 0;

friend CoherentCacheBase; // deferred assignment for cache
};
Expand Down Expand Up @@ -105,9 +106,6 @@ class OuterCohPortUncached : public OuterCohPortBase
virtual void query_loc_req(uint64_t addr, std::list<LocInfo> *locs){
coh->query_loc_resp(addr, locs);
}
virtual void finish_req(uint64_t addr){
coh->finish_resp(addr);
}
};

// common behavior for cached outer ports
Expand Down Expand Up @@ -148,6 +146,11 @@ class OuterCohPortT : public OPUC
cache->hook_manage(addr, ai, s, w, hit, OPUC::policy->is_outer_evict(outer_cmd), writeback, meta, data, delay);
return std::make_pair(hit, writeback);
}

virtual void finish_req(uint64_t addr){
assert(!OPUC::is_uncached());
OPUC::coh->finish_resp(addr);
}
};

typedef OuterCohPortT<OuterCohPortUncached> OuterCohPort;
Expand Down Expand Up @@ -273,7 +276,6 @@ class InnerCohPortT : public IPUC
protected:
using IPUC::coh;
using IPUC::outer;
using IPUC::policy;
public:
InnerCohPortT(policy_ptr policy) : IPUC(policy) {}
virtual ~InnerCohPortT() {}
Expand All @@ -290,10 +292,9 @@ class InnerCohPortT : public IPUC
}
return std::make_pair(hit, writeback);
}

virtual void finish_resp(uint64_t addr){
if(policy->finish_need_req()) {
outer->finish_req(addr);
}
outer->finish_req(addr);
}
};

Expand Down Expand Up @@ -346,9 +347,9 @@ class CoreInterface : public InnerCohPortUncached, public CoreInterfaceBase {
outer->finish_req(addr);
}

virtual void flush(uint64_t addr, uint64_t *delay) { addr = normalize(addr); flush_line(addr, policy->cmd_for_flush(), delay); outer->finish_req(addr);}
virtual void flush(uint64_t addr, uint64_t *delay) { addr = normalize(addr); flush_line(addr, policy->cmd_for_flush(), delay); }

virtual void writeback(uint64_t addr, uint64_t *delay) { addr = normalize(addr); flush_line(addr, policy->cmd_for_writeback(), delay); outer->finish_req(addr);}
virtual void writeback(uint64_t addr, uint64_t *delay) { addr = normalize(addr); flush_line(addr, policy->cmd_for_writeback(), delay); }

virtual void writeback_invalidate(uint64_t *delay) {
assert(nullptr == "Error: L1.writeback_invalidate() is not implemented yet!");
Expand All @@ -360,10 +361,8 @@ class CoreInterface : public InnerCohPortUncached, public CoreInterfaceBase {
for(int iset=0; iset < nset; iset++)
for(int iway=0; iway < nway; iway++) {
auto [meta, data] = cache->access_line(ipar, iset, iway);
if(meta->is_valid()){
if(meta->is_valid())
flush_line(meta->addr(iset), policy->cmd_for_flush(), delay);
outer->finish_req(meta->addr(iset));
}
}
}

Expand Down
7 changes: 0 additions & 7 deletions cache/mi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ class MIPolicy : public CohPolicyBase
return std::make_tuple(false, false, cmd_for_null());
}

virtual bool finish_need_req() const {
if constexpr (isLLC) {
return false;
} else {
return true;
}
}
};

#endif

0 comments on commit 313c2a8

Please sign in to comment.