From 8136d004c99a7aa221c658c4219d5b3a2e8050c4 Mon Sep 17 00:00:00 2001 From: Michael Goldstein Date: Wed, 17 Jul 2024 20:56:15 -0400 Subject: [PATCH] add hw prefetchers to prefetch factory swap memory and core initialization to stop seg fault in prefetch init --- src/macsim.cc | 6 +++--- src/memory.cc | 17 +++++++++++++++++ src/pref_factory.cc | 26 ++++++++++++++++++++++++-- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/macsim.cc b/src/macsim.cc index 92d5e414..a8171bd1 100644 --- a/src/macsim.cc +++ b/src/macsim.cc @@ -730,12 +730,12 @@ void macsim_c::initialize(int argc, char** argv) { new manifold::kernel::Clock(1); // clock has to be global or static #endif - // initialize cores - init_cores(m_num_sim_cores); - // init memory init_memory(); + // initialize cores + init_cores(m_num_sim_cores); + // initialize some of my output streams to the standards */ init_output_streams(); diff --git a/src/memory.cc b/src/memory.cc index a7e609f3..21fd89c7 100644 --- a/src/memory.cc +++ b/src/memory.cc @@ -627,6 +627,23 @@ int dcu_c::access(uop_c* uop) { else if (req_type == MRT_DPRF) { return m_latency; } + + // // TODO: insert hardware prefetch code here? -- need to init somewhere + // if (*m_simBase->m_knobs->KNOB_PREF_2DC_ON) { + // // + // } + + // if (*m_simBase->m_knobs->KNOB_PREF_STREAM_ON) { + // // + // } + + // if (*m_simBase->m_knobs->KNOB_PREF_STRIDE_ON) { + // // + // } + + // if (*m_simBase->m_knobs->KNOB_PREF_GHB_ON) { + // // + // } } // !cache_hit return -1; // cache miss diff --git a/src/pref_factory.cc b/src/pref_factory.cc index d8e4bafd..26d114fb 100644 --- a/src/pref_factory.cc +++ b/src/pref_factory.cc @@ -37,13 +37,35 @@ POSSIBILITY OF SUCH DAMAGE. #include "pref_factory.h" #include "assert.h" #include "pref_stride.h" +#include "all_knobs.h" +#include "hw_prefetcher/pref_2dc.h" +#include "hw_prefetcher/pref_ghb.h" +#include "hw_prefetcher/pref_stream.h" +#include "hw_prefetcher/pref_stridepc.h" /////////////////////////////////////////////////////////////////////////////////////////////// void pref_factory(vector &pref_table, hwp_common_c *hcc, Unit_Type type, macsim_c *simBase) { - pref_base_c *pref_stride = new pref_stride_c(hcc, type, simBase); - pref_table.push_back(pref_stride); + pref_base_c *pref = nullptr; + if (*simBase->m_knobs->KNOB_PREF_2DC_ON) { + pref = new pref_2dc_c(hcc, type, simBase); + } + + if (*simBase->m_knobs->KNOB_PREF_GHB_ON) { + pref = new pref_ghb_c(hcc, type, simBase); + } + + if (*simBase->m_knobs->KNOB_PREF_STREAM_ON) { + pref = new pref_stream_c(hcc, type, simBase); + } + + if (*simBase->m_knobs->KNOB_PREF_STRIDEPC_ON) { + pref = new pref_stridepc_c(hcc, type, simBase); + } + + assert(pref != nullptr); + pref_table.push_back(pref); } // Singleton pointer to pref_factory_c