Skip to content

Commit

Permalink
Merge pull request #10 from sixshotx/cache-counters
Browse files Browse the repository at this point in the history
Cache counters
  • Loading branch information
sixshotx authored Feb 13, 2017
2 parents 3b40425 + ce9cfc0 commit 9977999
Show file tree
Hide file tree
Showing 37 changed files with 2,702 additions and 721 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ A Parallel Simulation Framework For Multicore Systems

**Installation Instructions**

If you are on Ubuntu (>= 14.04), just run setup.sh script in the root directory
after QSim is installed. This will link the manifold to the QSim library specifi
ed by $QSIM_PREFIX variable, download multi-thread benchmarks supported by manif
old, and build the manifold components and simulators.
If you are on Ubuntu (>= 14.04), just run setup.sh script in the root directory after QSim is installed. This will link the manifold to the QSim library specified by $QSIM_PREFIX variable, download multi-thread benchmarks supported by manifold, and build the manifold components and simulators.

Manifold now integrates [KitFox multi-physics library](http://manifold.gatech.edu/projects/kitfox) to simulate physical phenomena including power, thermal and lifetime reliability models. After KitFox framework is installed and exported to system variable $KITFOX_PREFIX, the setup.sh script will configure manifold to enable KitfoxProxy that interacts with the given KitFox framekwork. The lastest KitFox source code tarball can be found [here](http://manifold.gatech.edu/wp-content/uploads/2017/01/kitfox-v1.1.tar.gz). Please refer to [KitFox user manual](http://manifold.gatech.edu/wp-content/uploads/2015/04/kitfox-v1.0.0.pdf) for details.

Expand Down
56 changes: 56 additions & 0 deletions models/cache/mcp-cache/L1_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,23 @@ void L1_cache :: process_processor_request (cache_req *request, bool first)

DBG_L1_CACHE_TICK_ID( cout, "###### " << " process_processor_request(): addr= " <<hex<< request->addr <<dec<< ((request->op_type==OpMemLd) ? " LD" : " ST") << "\n" );

#ifdef LIBKITFOX
if(request->op_type==OpMemLd) {
counter.cache.read += 3;
counter.cache.search += 3;
counter.cache.read_tag += 3;
} else {
counter.cache.write += 3;
counter.cache.search += 3;
counter.cache.read_tag += 3;
counter.cache.write_tag += 3;
}
counter.tlb.search += 3;
counter.tlb.read += 3;
counter.tlb.write += 3;
counter.tlb.read_tag += 3;
#endif

/** This code may be modified in the future to enable parallel events while transient (read while waiting for previous read-unblock). For the time being, just assume no parallel events for a single address */
if (mshr->has_match(request->addr))
{
Expand Down Expand Up @@ -189,6 +206,17 @@ void L1_cache :: process_processor_request (cache_req *request, bool first)
if (!my_table->has_match (request->addr)) {
DBG_L1_CACHE(cout, " miss.\n");

#ifdef LIBKITFOX
counter.missbuf.search += 3;
counter.missbuf.read_tag += 3;
counter.missbuf.write_tag += 3;
counter.missbuf.write += 3;
counter.prefetch.search += 3;
counter.prefetch.read_tag += 3;
counter.prefetch.write_tag += 3;
counter.prefetch.write += 3;
#endif

/** Check if an invalid block exists already or the LRU block can begin eviction. */
hash_table_entry = my_table->reserve_block_for (request->addr);

Expand All @@ -200,6 +228,16 @@ void L1_cache :: process_processor_request (cache_req *request, bool first)
DBG_L1_CACHE(cout, " start eviction line= " <<hex<< my_table->get_replacement_entry(request->addr)->get_line_addr() <<dec<< "\n");

start_eviction (mshr_entry, request);

#ifdef LIBKITFOX
counter.linefill.search += 3;
counter.linefill.write_tag += 3;
counter.linefill.write += 3;
counter.writeback.search += 3;
counter.writeback.write_tag += 3;
counter.writeback.write += 3;
#endif

}
else {
//the client for the victim is in transient, so it must have a stalled request in the
Expand Down Expand Up @@ -401,6 +439,24 @@ void L1_cache :: process_peer_and_manager_request(Coh_msg* request)
stall request
*/

#ifdef LIBKITFOX
if(request->rw == 0) {
counter.cache.read += 3;
counter.cache.search += 3;
counter.cache.read_tag += 3;
} else {
counter.cache.write += 3;
counter.cache.search += 3;
counter.cache.read_tag += 3;
counter.cache.write_tag += 3;
}

counter.tlb.search += 3;
counter.tlb.read += 3;
counter.tlb.write += 3;
counter.tlb.read_tag += 3;
#endif

if(request->type == Coh_msg::COH_RPLY) {
DBG_L1_CACHE(cout, " it is a reply.\n");

Expand Down
28 changes: 27 additions & 1 deletion models/cache/mcp-cache/L1_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include "uarch/DestMap.h"
#include "uarch/networkPacket.h"

#ifdef LIBKITFOX
#include "uarch/kitfoxCounter.h"
#endif


namespace manifold {
Expand All @@ -27,7 +30,7 @@ struct L1_cache_settings {
class L1_cache : public manifold::kernel::Component {
public:

enum {PORT_PROC=0, PORT_L2};
enum {PORT_PROC=0, PORT_L2, PORT_KITFOX};

L1_cache (int nid, const cache_settings&, const L1_cache_settings&);
virtual ~L1_cache (void);
Expand Down Expand Up @@ -61,6 +64,11 @@ class L1_cache : public manifold::kernel::Component {
CREDIT_MSG = credit;
}

#ifdef LIBKITFOX
template<typename T>
void handle_kitfox_proxy_request(int temp, T *kitfox_proxy_request);
#endif

private:
//void issue_to_client (cache_req *request);
//void issue_to_manager (cache_req *request);
Expand Down Expand Up @@ -170,6 +178,10 @@ class L1_cache : public manifold::kernel::Component {
unsigned stats_stall_buffer_max_size;
unsigned long stats_table_occupancy; //accumulated hash table occupancy
unsigned stats_table_empty_cycles;

#ifdef LIBKITFOX
manifold::uarch::cache_counter_t counter;
#endif
};


Expand Down Expand Up @@ -198,6 +210,20 @@ void L1_cache :: handle_processor_request(int, T* request)
}


#ifdef LIBKITFOX
template <typename T>
void L1_cache :: handle_kitfox_proxy_request(int temp, T *kitfox_proxy_request)
{
assert(kitfox_proxy_request->get_type() == manifold::uarch::KitFoxType::l1cache_type);
assert(kitfox_proxy_request->get_id() == node_id);

kitfox_proxy_request->set_counter(counter);
counter.clear();

Send(PORT_KITFOX, kitfox_proxy_request);
}
#endif // LIBKITFOX



} //namespace mcp_cache
Expand Down
40 changes: 39 additions & 1 deletion models/cache/mcp-cache/L2_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,15 @@ void L2_cache :: process_incoming_coh(Coh_msg* request)
{
DBG_L2_CACHE_TICK_ID(cout, "###### handle_incoming()_coh, srcID= " << request->src_id << " type= " << int(request->type) << " addr=(" <<hex<< request->addr <<dec<< ")" << endl);


#ifdef LIBKITFOX
counter.cache.read_tag += 100;
counter.cache.search += 100;
if (request->rw == 1) { //write
counter.cache.write_tag += 100;
counter.cache.write += 100;
} else
counter.cache.read += 100;
#endif

if(request->type == Coh_msg :: COH_REQ) {
stats_num_reqs++;
Expand All @@ -141,6 +149,15 @@ void L2_cache :: process_mem_resp (Mem_msg *request)
{
DBG_L2_CACHE_TICK_ID(cout, "######## process_mem_resp(), addr= " << hex << request->addr << dec << endl);

#ifdef LIBKITFOX
counter.cache.read_tag += 100;
counter.cache.search += 100;
if (request->op_type == OpMemSt) { //write
counter.cache.write_tag += 100;
counter.cache.write += 100;
} else
counter.cache.read += 100;
#endif

if(request->op_type == OpMemLd) {
assert(l2_map);
Expand Down Expand Up @@ -225,6 +242,17 @@ void L2_cache::process_client_request (Coh_msg* request, bool first)
{
DBG_L2_CACHE(cout, " L2_cache: request is miss.\n");

#ifdef LIBKITFOX
counter.missbuf.search += 35;
counter.missbuf.read_tag += 35;
counter.missbuf.write_tag += 35;
counter.missbuf.write += 35;
counter.prefetch.search += 35;
counter.prefetch.read_tag += 35;
counter.prefetch.write_tag += 35;
counter.prefetch.write += 35;
#endif

//first check if request is an invalidation request; a missed invalidation request should
//be ignored.
if(managers[0]->is_invalidation_request(request)) {
Expand Down Expand Up @@ -259,6 +287,16 @@ void L2_cache::process_client_request (Coh_msg* request, bool first)
assert(mshr->has_match(victim->get_line_addr()) == false); //victim shouldn't have an mshr entry.

start_eviction(victim_manager, request);

#ifdef LIBKITFOX
counter.linefill.search += 35;
counter.linefill.write_tag += 35;
counter.linefill.write += 35;
counter.writeback.search += 35;
counter.writeback.write_tag += 35;
counter.writeback.write += 35;
#endif

}
else
{
Expand Down
29 changes: 28 additions & 1 deletion models/cache/mcp-cache/L2_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include "uarch/networkPacket.h"
#include "uarch/DestMap.h"

#ifdef LIBKITFOX
#include "uarch/kitfoxCounter.h"
#endif


using namespace std;

Expand All @@ -29,7 +33,7 @@ struct L2_cache_settings {

class L2_cache : public manifold::kernel::Component {
public:
enum {PORT_L1=0};
enum {PORT_L1=0, PORT_KITFOX};

L2_cache (int nid, const cache_settings&, const L2_cache_settings&);
virtual ~L2_cache (void);
Expand Down Expand Up @@ -59,6 +63,12 @@ class L2_cache : public manifold::kernel::Component {
MEM_MSG = mem;
CREDIT_MSG = credit;
}

#ifdef LIBKITFOX
template <typename T>
void handle_kitfox_proxy_request(int temp, T *kitfox_proxy_request);
#endif

private:
void process_client_request (Coh_msg* request, bool first);
void process_client_reply (Coh_msg* reply);
Expand Down Expand Up @@ -152,6 +162,10 @@ class L2_cache : public manifold::kernel::Component {
unsigned stats_mshr_empty_cycles;
unsigned stats_read_mem;
unsigned stats_dirty_to_mem;

#ifdef LIBKITFOX
manifold::uarch::cache_counter_t counter;
#endif
};


Expand Down Expand Up @@ -193,6 +207,19 @@ void L2_cache :: handle_incoming (int, manifold::uarch::NetworkPacket* pkt)
}


#ifdef LIBKITFOX
template <typename T>
void L2_cache :: handle_kitfox_proxy_request(int temp, T *kitfox_proxy_request)
{
assert(kitfox_proxy_request->get_type() == manifold::uarch::KitFoxType::l2cache_type);
assert(kitfox_proxy_request->get_id() == node_id);

kitfox_proxy_request->set_counter(counter);
counter.clear();

Send(PORT_KITFOX, kitfox_proxy_request);
}
#endif // LIBKITFOX



Expand Down
2 changes: 1 addition & 1 deletion models/cache/mcp-cache/LLP_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class LLP_cache : public L1_cache {
public:
friend class MuxDemux;

enum {PORT_LOCAL_L2=2};
enum {PORT_LOCAL_L2=3};

// enum {LLP_ID=234, LLS_ID};

Expand Down
3 changes: 2 additions & 1 deletion models/cache/mcp-cache/LLS_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class LLS_cache : public L2_cache {
public:
friend class MuxDemux;

enum {PORT_L1=0, PORT_LOCAL_L1};
// enum {PORT_L1=0, PORT_LOCAL_L1=2};
enum {PORT_LOCAL_L1=3};

LLS_cache (int nid, const cache_settings&, const L2_cache_settings&);
~LLS_cache (void);
Expand Down
2 changes: 1 addition & 1 deletion models/cache/mcp-cache/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pkginclude_mcp_cache_HEADERS = \
lp_lls_unit.h \
mux_demux.h

libmcp_cache_a_CPPFLAGS = -I$(KERNEL_INC)
libmcp_cache_a_CPPFLAGS = -I$(KERNEL_INC) -I$(KITFOX_INC) --std=c++11

EXTRA_DIST = doc

Expand Down
32 changes: 32 additions & 0 deletions models/cache/mcp-cache/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,38 @@ if test "x${forecast_null}" = xyes ; then
AC_DEFINE(FORECAST_NULL)
fi

# check kitfox integration
AC_ARG_WITH([kitfox],
[AS_HELP_STRING([--without-kitfox],
[do not use QSim @<:@default: no@:>@])],
[kitfox=${enableval}], [kitfox=yes])

if test "x${kitfox}" = xyes ; then
#check if QSim header files exist
# We allow user to specify the location of the header files, e.g.,
# configure KITFOXINC=/foo/kitfox
if test -z "$KITFOXINC" ; then
KITFOXINC='/usr/local/include'
fi

if test ! -e "$KITFOXINC/kitfox.h"; then
AC_MSG_ERROR([
-----------------------------------------
ERROR: kitfox.h not found in $KITFOXINC!
-----------------------------------------
])
else
AC_DEFINE(LIBKITFOX)
AC_SUBST([KITFOX_INC], [$KITFOXINC])
fi
else # use_kitfox disabled
AC_MSG_WARN([
-----------------------------------------------------------------
LIBKITFOX disabled! Building only processor models not using KitFox.
-----------------------------------------------------------------])
AC_SUBST([KITFOX_INC], ["."])
fi


# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
Expand Down
Loading

0 comments on commit 9977999

Please sign in to comment.