gpu-compute: Init CU object for pipe stages in their ctors
authorTony Gutierrez <anthony.gutierrez@amd.com>
Fri, 29 Jun 2018 20:06:36 +0000 (16:06 -0400)
committerAnthony Gutierrez <anthony.gutierrez@amd.com>
Thu, 16 Jul 2020 20:37:22 +0000 (20:37 +0000)
This change updates the constructors of the CU's pipe
stages/memory pipelines to accept a pointer to their
parent CU. Because the CU creates these objects, and
can pass a pointer to itself to these object via their
constructors, this is the safer way to initalize these
classes.

Change-Id: I0b3732ce7c03781ee15332dac7a21c097ad387a4
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/29945
Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com>
Maintainer: Anthony Gutierrez <anthony.gutierrez@amd.com>
Tested-by: kokoro <noreply+kokoro@google.com>
17 files changed:
src/gpu-compute/compute_unit.cc
src/gpu-compute/exec_stage.cc
src/gpu-compute/exec_stage.hh
src/gpu-compute/fetch_stage.cc
src/gpu-compute/fetch_stage.hh
src/gpu-compute/fetch_unit.cc
src/gpu-compute/fetch_unit.hh
src/gpu-compute/global_memory_pipeline.cc
src/gpu-compute/global_memory_pipeline.hh
src/gpu-compute/local_memory_pipeline.cc
src/gpu-compute/local_memory_pipeline.hh
src/gpu-compute/scalar_memory_pipeline.cc
src/gpu-compute/scalar_memory_pipeline.hh
src/gpu-compute/schedule_stage.cc
src/gpu-compute/schedule_stage.hh
src/gpu-compute/scoreboard_check_stage.cc
src/gpu-compute/scoreboard_check_stage.hh

index 0fcbb1ac6f02905b1332d52b9b8872c9d135269f..f3387a7b7aa0050e70f1e68dee9a64fedec6bb7c 100644 (file)
@@ -66,9 +66,14 @@ ComputeUnit::ComputeUnit(const Params *p) : ClockedObject(p),
     numScalarALUs(p->num_scalar_cores),
     vrfToCoalescerBusWidth(p->vrf_to_coalescer_bus_width),
     coalescerToVrfBusWidth(p->coalescer_to_vrf_bus_width),
-    registerManager(p->register_manager), fetchStage(p),
-    scoreboardCheckStage(p), scheduleStage(p, this), execStage(p),
-    globalMemoryPipe(p), localMemoryPipe(p), scalarMemoryPipe(p),
+    registerManager(p->register_manager),
+    fetchStage(p, this),
+    scoreboardCheckStage(p, this),
+    scheduleStage(p, this),
+    execStage(p, this),
+    globalMemoryPipe(p, this),
+    localMemoryPipe(p, this),
+    scalarMemoryPipe(p, this),
     tickEvent([this]{ exec(); }, "Compute unit tick event",
           false, Event::CPU_Tick_Pri),
     cu_id(p->cu_id),
@@ -788,13 +793,11 @@ ComputeUnit::init()
         dispatchList.push_back(std::make_pair(nullptr, EMPTY));
     }
 
-    fetchStage.init(this);
-    scoreboardCheckStage.init(this);
-    scheduleStage.init(this);
-    execStage.init(this);
-    globalMemoryPipe.init(this);
-    localMemoryPipe.init(this);
-    scalarMemoryPipe.init(this);
+    fetchStage.init();
+    scoreboardCheckStage.init();
+    scheduleStage.init();
+    execStage.init();
+    globalMemoryPipe.init();
 
     gmTokenPort.setTokenManager(memPortTokens);
 }
index 2dece180b140b088fb82d352b90896b937b8d973..e420579c97da2dbe843717a00d8b4dcd14f9ffe7 100644 (file)
 #include "gpu-compute/vector_register_file.hh"
 #include "gpu-compute/wavefront.hh"
 
-ExecStage::ExecStage(const ComputeUnitParams *p) : lastTimeInstExecuted(false),
-    thisTimeInstExecuted(false), instrExecuted (false),
-    executionResourcesUsed(0)
+ExecStage::ExecStage(const ComputeUnitParams *p, ComputeUnit *cu)
+    : computeUnit(cu), lastTimeInstExecuted(false),
+      thisTimeInstExecuted(false), instrExecuted (false),
+      executionResourcesUsed(0), _name(cu->name() + ".ExecStage")
+
 {
     numTransActiveIdle = 0;
     idle_dur = 0;
 }
 
 void
-ExecStage::init(ComputeUnit *cu)
+ExecStage::init()
 {
-    computeUnit = cu;
-    _name = computeUnit->name() + ".ExecStage";
     dispatchList = &computeUnit->dispatchList;
     idle_dur = 0;
 }
index 670252cdeec1e4196f2f8ba9f0c194e3be94fa36..f984d729cdde5f7fcaa3e9ca47114edbb0464271 100644 (file)
@@ -69,9 +69,9 @@ enum DISPATCH_STATUS
 class ExecStage
 {
   public:
-    ExecStage(const ComputeUnitParams* params);
+    ExecStage(const ComputeUnitParams* p, ComputeUnit *cu);
     ~ExecStage() { }
-    void init(ComputeUnit *cu);
+    void init();
     void exec();
 
     std::string dispStatusToStr(int j);
index cf0b39e70394af7115a9e09f1bf9861b4ed6c67e..b9df6ce4f8e5aebbe9140d7565e4bccd9d614ee3 100644 (file)
 #include "gpu-compute/compute_unit.hh"
 #include "gpu-compute/wavefront.hh"
 
-FetchStage::FetchStage(const ComputeUnitParams* p) :
-    numVectorALUs(p->num_SIMDs), computeUnit(nullptr)
+FetchStage::FetchStage(const ComputeUnitParams* p, ComputeUnit *cu)
+    : numVectorALUs(p->num_SIMDs), computeUnit(cu),
+      _name(cu->name() + ".FetchStage")
 {
     for (int j = 0; j < numVectorALUs; ++j) {
-        FetchUnit newFetchUnit(p);
+        FetchUnit newFetchUnit(p, cu);
         _fetchUnit.push_back(newFetchUnit);
     }
 }
@@ -51,14 +52,11 @@ FetchStage::~FetchStage()
 }
 
 void
-FetchStage::init(ComputeUnit *cu)
+FetchStage::init()
 {
-    computeUnit = cu;
-    _name = computeUnit->name() + ".FetchStage";
-
     for (int j = 0; j < numVectorALUs; ++j) {
         _fetchUnit[j].bindWaveList(&computeUnit->wfList[j]);
-        _fetchUnit[j].init(computeUnit);
+        _fetchUnit[j].init();
     }
 }
 
index afaf81b5a2d8c4dd9b1a5ec0f3b8108075eca224..afecce7cb6f4f8c5181314754d95cc1ed3a04795 100644 (file)
@@ -51,9 +51,9 @@ class Wavefront;
 class FetchStage
 {
   public:
-    FetchStage(const ComputeUnitParams* params);
+    FetchStage(const ComputeUnitParams* p, ComputeUnit *cu);
     ~FetchStage();
-    void init(ComputeUnit *cu);
+    void init();
     void exec();
     void processFetchReturn(PacketPtr pkt);
     void fetch(PacketPtr pkt, Wavefront *wave);
index 447ff12faa6150c63f0b1db4fdf770a003ed9bd8..e0127e868c5be59418fdcbc16777e95f3bc2991d 100644 (file)
@@ -45,9 +45,9 @@
 
 uint32_t FetchUnit::globalFetchUnitID;
 
-FetchUnit::FetchUnit(const ComputeUnitParams* params)
-    : timingSim(true), computeUnit(nullptr), fetchScheduler(params),
-      waveList(nullptr), fetchDepth(params->fetch_depth)
+FetchUnit::FetchUnit(const ComputeUnitParams *p, ComputeUnit *cu)
+    : timingSim(true), computeUnit(cu), fetchScheduler(p),
+      waveList(nullptr), fetchDepth(p->fetch_depth)
 {
 }
 
@@ -58,9 +58,8 @@ FetchUnit::~FetchUnit()
 }
 
 void
-FetchUnit::init(ComputeUnit *cu)
+FetchUnit::init()
 {
-    computeUnit = cu;
     timingSim = computeUnit->shader->timingSim;
     fetchQueue.clear();
     fetchStatusQueue.resize(computeUnit->shader->n_wf);
index 798c26465521613f7de7035d3bd3a100f6a0f09b..1615d81bb43ca019c7da96d5dc23b7d64983da7e 100644 (file)
@@ -49,9 +49,9 @@ class Wavefront;
 class FetchUnit
 {
   public:
-    FetchUnit(const ComputeUnitParams* params);
+    FetchUnit(const ComputeUnitParams* p, ComputeUnit *cu);
     ~FetchUnit();
-    void init(ComputeUnit *cu);
+    void init();
     void exec();
     void bindWaveList(std::vector<Wavefront*> *list);
     void initiateFetch(Wavefront *wavefront);
index cfd7c3db1ced3af80c3618d2936cfc25b50ac140..2619360a4367e3ca21b1a60f2080b5747f2f65e9 100644 (file)
 #include "gpu-compute/vector_register_file.hh"
 #include "gpu-compute/wavefront.hh"
 
-GlobalMemPipeline::GlobalMemPipeline(const ComputeUnitParams* p) :
-    computeUnit(nullptr), gmQueueSize(p->global_mem_queue_size),
-    maxWaveRequests(p->max_wave_requests), inflightStores(0),
-    inflightLoads(0)
+GlobalMemPipeline::GlobalMemPipeline(const ComputeUnitParams* p,
+                                     ComputeUnit *cu)
+    : computeUnit(cu), _name(cu->name() + ".GlobalMemPipeline"),
+      gmQueueSize(p->global_mem_queue_size),
+      maxWaveRequests(p->max_wave_requests), inflightStores(0),
+      inflightLoads(0)
 {
 }
 
 void
-GlobalMemPipeline::init(ComputeUnit *cu)
+GlobalMemPipeline::init()
 {
-    computeUnit = cu;
     globalMemSize = computeUnit->shader->globalMemSize;
-    _name = computeUnit->name() + ".GlobalMemPipeline";
 }
 
 bool
index 6fb1db7b4e398bef45004f4ac15bef968df36c77..97c0e8d5955fad907225677e0641fe81c5a690ab 100644 (file)
@@ -56,8 +56,8 @@ class ComputeUnit;
 class GlobalMemPipeline
 {
   public:
-    GlobalMemPipeline(const ComputeUnitParams *params);
-    void init(ComputeUnit *cu);
+    GlobalMemPipeline(const ComputeUnitParams *p, ComputeUnit *cu);
+    void init();
     void exec();
 
     /**
index b31ed6f4af659cde87052d8c296dc04f04b2d4c1..6644a0bf454981b06783d552a54ffd8135117073 100644 (file)
 #include "gpu-compute/vector_register_file.hh"
 #include "gpu-compute/wavefront.hh"
 
-LocalMemPipeline::LocalMemPipeline(const ComputeUnitParams* p) :
-    computeUnit(nullptr), lmQueueSize(p->local_mem_queue_size)
+LocalMemPipeline::LocalMemPipeline(const ComputeUnitParams* p, ComputeUnit *cu)
+    : computeUnit(cu), _name(cu->name() + ".LocalMemPipeline"),
+      lmQueueSize(p->local_mem_queue_size)
 {
 }
 
-void
-LocalMemPipeline::init(ComputeUnit *cu)
-{
-    computeUnit = cu;
-    _name = computeUnit->name() + ".LocalMemPipeline";
-}
-
 void
 LocalMemPipeline::exec()
 {
index d9ab485b225a8c60dd9876213873a785e0b0925d..7821785c29483fb5be81fe981500823aedc6a4fa 100644 (file)
@@ -55,8 +55,7 @@ class Wavefront;
 class LocalMemPipeline
 {
   public:
-    LocalMemPipeline(const ComputeUnitParams *params);
-    void init(ComputeUnit *cu);
+    LocalMemPipeline(const ComputeUnitParams *p, ComputeUnit *cu);
     void exec();
     std::queue<GPUDynInstPtr> &getLMRespFIFO() { return lmReturnedRequests; }
 
index c8823b8a6c24ac5c8f546c1cc9e74cbdbf046fbf..9ec354c1b1be7b74c78ab6573d8af4068edbdf6b 100644 (file)
 #include "gpu-compute/shader.hh"
 #include "gpu-compute/wavefront.hh"
 
-ScalarMemPipeline::ScalarMemPipeline(const ComputeUnitParams* p) :
-    computeUnit(nullptr), queueSize(p->scalar_mem_queue_size),
-    inflightStores(0), inflightLoads(0)
+ScalarMemPipeline::ScalarMemPipeline(const ComputeUnitParams* p,
+                                     ComputeUnit *cu)
+    : computeUnit(cu), _name(cu->name() + ".ScalarMemPipeline"),
+      queueSize(p->scalar_mem_queue_size),
+      inflightStores(0), inflightLoads(0)
 {
 }
 
-void
-ScalarMemPipeline::init(ComputeUnit *cu)
-{
-    computeUnit = cu;
-    _name = computeUnit->name() + ".ScalarMemPipeline";
-}
-
 void
 ScalarMemPipeline::exec()
 {
index 1944477cfff3578e661f1721689c54918b6296ac..03211a291113474605864e67a548f06eca7b5ce1 100644 (file)
@@ -59,8 +59,7 @@ class ComputeUnit;
 class ScalarMemPipeline
 {
   public:
-    ScalarMemPipeline(const ComputeUnitParams *params);
-    void init(ComputeUnit *cu);
+    ScalarMemPipeline(const ComputeUnitParams *p, ComputeUnit *cu);
     void exec();
 
     std::queue<GPUDynInstPtr> &getGMReqFIFO() { return issuedRequests; }
index 949eed155b5b0591ca771c2335fb506bcd2cc854..510d3f34775093314f38d11cecacafd2445217fc 100644 (file)
@@ -44,7 +44,8 @@
 #include "gpu-compute/wavefront.hh"
 
 ScheduleStage::ScheduleStage(const ComputeUnitParams *p, ComputeUnit *cu)
-    : vectorAluRdy(false), scalarAluRdy(false), scalarMemBusRdy(false),
+    : computeUnit(cu), _name(cu->name() + ".ScheduleStage"),
+      vectorAluRdy(false), scalarAluRdy(false), scalarMemBusRdy(false),
       scalarMemIssueRdy(false), glbMemBusRdy(false), glbMemIssueRdy(false),
       locMemBusRdy(false), locMemIssueRdy(false)
 {
@@ -66,10 +67,8 @@ ScheduleStage::~ScheduleStage()
 }
 
 void
-ScheduleStage::init(ComputeUnit *cu)
+ScheduleStage::init()
 {
-    computeUnit = cu;
-    _name = computeUnit->name() + ".ScheduleStage";
 
     fatal_if(scheduler.size() != computeUnit->readyList.size(),
              "Scheduler should have same number of entries as CU's readyList");
index 98519701aba7e985b99c9e8efcc80c5882e83065..be2691b28a262d92243449132c066ba19236a30b 100644 (file)
@@ -57,9 +57,9 @@ struct ComputeUnitParams;
 class ScheduleStage
 {
   public:
-    ScheduleStage(const ComputeUnitParams *params, ComputeUnit *cu);
+    ScheduleStage(const ComputeUnitParams *p, ComputeUnit *cu);
     ~ScheduleStage();
-    void init(ComputeUnit *cu);
+    void init();
     void exec();
 
     // Stats related variables and methods
index 7b715cebf977ab59a361a25a5a23c03105328160..e14a2f2b21d8dd0bfd9d31f06ffc4c5df3fe9b67 100644 (file)
@@ -44,7 +44,9 @@
 #include "gpu-compute/wavefront.hh"
 #include "params/ComputeUnit.hh"
 
-ScoreboardCheckStage::ScoreboardCheckStage(const ComputeUnitParams *p)
+ScoreboardCheckStage::ScoreboardCheckStage(const ComputeUnitParams *p,
+                                           ComputeUnit *cu)
+    : computeUnit(cu), _name(cu->name() + ".ScoreboardCheckStage")
 {
 }
 
@@ -54,11 +56,8 @@ ScoreboardCheckStage::~ScoreboardCheckStage()
 }
 
 void
-ScoreboardCheckStage::init(ComputeUnit *cu)
+ScoreboardCheckStage::init()
 {
-    computeUnit = cu;
-    _name = computeUnit->name() + ".ScoreboardCheckStage";
-
     for (int unitId = 0; unitId < computeUnit->numExeUnits(); ++unitId) {
         readyList.push_back(&computeUnit->readyList[unitId]);
     }
index 1e5695139eb25252b39ebecfc6d046e7e04e0628..3cdae278c4185048ed2e4c2298a98497ccde3ce1 100644 (file)
@@ -70,9 +70,9 @@ class ScoreboardCheckStage
         NRDY_CONDITIONS
     };
 
-    ScoreboardCheckStage(const ComputeUnitParams* params);
+    ScoreboardCheckStage(const ComputeUnitParams* p, ComputeUnit *cu);
     ~ScoreboardCheckStage();
-    void init(ComputeUnit *cu);
+    void init();
     void exec();
 
     // Stats related variables and methods