Hello Tony Gutierrez,

I'd like you to do a code review. Please visit

    https://gem5-review.googlesource.com/c/public/gem5/+/29945

to review the following change.


Change subject: gpu-compute: Init CU object for pipe stages in their ctors
......................................................................

gpu-compute: Init CU object for pipe stages in their ctors

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
---
M src/gpu-compute/compute_unit.cc
M src/gpu-compute/exec_stage.cc
M src/gpu-compute/exec_stage.hh
M src/gpu-compute/fetch_stage.cc
M src/gpu-compute/fetch_stage.hh
M src/gpu-compute/fetch_unit.cc
M src/gpu-compute/fetch_unit.hh
M src/gpu-compute/global_memory_pipeline.cc
M src/gpu-compute/global_memory_pipeline.hh
M src/gpu-compute/local_memory_pipeline.cc
M src/gpu-compute/local_memory_pipeline.hh
M src/gpu-compute/scalar_memory_pipeline.cc
M src/gpu-compute/scalar_memory_pipeline.hh
M src/gpu-compute/schedule_stage.cc
M src/gpu-compute/schedule_stage.hh
M src/gpu-compute/scoreboard_check_stage.cc
M src/gpu-compute/scoreboard_check_stage.hh
17 files changed, 65 insertions(+), 80 deletions(-)



diff --git a/src/gpu-compute/compute_unit.cc b/src/gpu-compute/compute_unit.cc
index 0fcbb1a..f3387a7 100644
--- a/src/gpu-compute/compute_unit.cc
+++ b/src/gpu-compute/compute_unit.cc
@@ -66,9 +66,14 @@
     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 @@
         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);
 }
diff --git a/src/gpu-compute/exec_stage.cc b/src/gpu-compute/exec_stage.cc
index 686e621..3c6aaad 100644
--- a/src/gpu-compute/exec_stage.cc
+++ b/src/gpu-compute/exec_stage.cc
@@ -40,19 +40,19 @@
 #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;
 }
diff --git a/src/gpu-compute/exec_stage.hh b/src/gpu-compute/exec_stage.hh
index 670252c..f984d72 100644
--- a/src/gpu-compute/exec_stage.hh
+++ b/src/gpu-compute/exec_stage.hh
@@ -69,9 +69,9 @@
 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);
diff --git a/src/gpu-compute/fetch_stage.cc b/src/gpu-compute/fetch_stage.cc
index cf0b39e..b9df6ce 100644
--- a/src/gpu-compute/fetch_stage.cc
+++ b/src/gpu-compute/fetch_stage.cc
@@ -36,11 +36,12 @@
 #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 @@
 }

 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();
     }
 }

diff --git a/src/gpu-compute/fetch_stage.hh b/src/gpu-compute/fetch_stage.hh
index afaf81b..afecce7 100644
--- a/src/gpu-compute/fetch_stage.hh
+++ b/src/gpu-compute/fetch_stage.hh
@@ -51,9 +51,9 @@
 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);
diff --git a/src/gpu-compute/fetch_unit.cc b/src/gpu-compute/fetch_unit.cc
index 447ff12..e0127e8 100644
--- a/src/gpu-compute/fetch_unit.cc
+++ b/src/gpu-compute/fetch_unit.cc
@@ -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 @@
 }

 void
-FetchUnit::init(ComputeUnit *cu)
+FetchUnit::init()
 {
-    computeUnit = cu;
     timingSim = computeUnit->shader->timingSim;
     fetchQueue.clear();
     fetchStatusQueue.resize(computeUnit->shader->n_wf);
diff --git a/src/gpu-compute/fetch_unit.hh b/src/gpu-compute/fetch_unit.hh
index 798c264..1615d81 100644
--- a/src/gpu-compute/fetch_unit.hh
+++ b/src/gpu-compute/fetch_unit.hh
@@ -49,9 +49,9 @@
 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);
diff --git a/src/gpu-compute/global_memory_pipeline.cc b/src/gpu-compute/global_memory_pipeline.cc
index cfd7c3d..2619360 100644
--- a/src/gpu-compute/global_memory_pipeline.cc
+++ b/src/gpu-compute/global_memory_pipeline.cc
@@ -43,19 +43,19 @@
 #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
diff --git a/src/gpu-compute/global_memory_pipeline.hh b/src/gpu-compute/global_memory_pipeline.hh
index 6fb1db7..97c0e8d 100644
--- a/src/gpu-compute/global_memory_pipeline.hh
+++ b/src/gpu-compute/global_memory_pipeline.hh
@@ -56,8 +56,8 @@
 class GlobalMemPipeline
 {
   public:
-    GlobalMemPipeline(const ComputeUnitParams *params);
-    void init(ComputeUnit *cu);
+    GlobalMemPipeline(const ComputeUnitParams *p, ComputeUnit *cu);
+    void init();
     void exec();

     /**
diff --git a/src/gpu-compute/local_memory_pipeline.cc b/src/gpu-compute/local_memory_pipeline.cc
index b31ed6f..6644a0b 100644
--- a/src/gpu-compute/local_memory_pipeline.cc
+++ b/src/gpu-compute/local_memory_pipeline.cc
@@ -41,19 +41,13 @@
 #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()
 {
     // apply any returned shared (LDS) memory operations
diff --git a/src/gpu-compute/local_memory_pipeline.hh b/src/gpu-compute/local_memory_pipeline.hh
index d9ab485..7821785 100644
--- a/src/gpu-compute/local_memory_pipeline.hh
+++ b/src/gpu-compute/local_memory_pipeline.hh
@@ -55,8 +55,7 @@
 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; }

diff --git a/src/gpu-compute/scalar_memory_pipeline.cc b/src/gpu-compute/scalar_memory_pipeline.cc
index c8823b8..9ec354c 100644
--- a/src/gpu-compute/scalar_memory_pipeline.cc
+++ b/src/gpu-compute/scalar_memory_pipeline.cc
@@ -43,20 +43,15 @@
 #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()
 {
     // afind oldest scalar request whose data has arrived
diff --git a/src/gpu-compute/scalar_memory_pipeline.hh b/src/gpu-compute/scalar_memory_pipeline.hh
index 1944477..03211a2 100644
--- a/src/gpu-compute/scalar_memory_pipeline.hh
+++ b/src/gpu-compute/scalar_memory_pipeline.hh
@@ -59,8 +59,7 @@
 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; }
diff --git a/src/gpu-compute/schedule_stage.cc b/src/gpu-compute/schedule_stage.cc
index 949eed1..510d3f3 100644
--- a/src/gpu-compute/schedule_stage.cc
+++ b/src/gpu-compute/schedule_stage.cc
@@ -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 @@
 }

 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"); diff --git a/src/gpu-compute/schedule_stage.hh b/src/gpu-compute/schedule_stage.hh
index 9851970..be2691b 100644
--- a/src/gpu-compute/schedule_stage.hh
+++ b/src/gpu-compute/schedule_stage.hh
@@ -57,9 +57,9 @@
 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
diff --git a/src/gpu-compute/scoreboard_check_stage.cc b/src/gpu-compute/scoreboard_check_stage.cc
index 7b715ce..e14a2f2 100644
--- a/src/gpu-compute/scoreboard_check_stage.cc
+++ b/src/gpu-compute/scoreboard_check_stage.cc
@@ -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 @@
 }

 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]);
     }
diff --git a/src/gpu-compute/scoreboard_check_stage.hh b/src/gpu-compute/scoreboard_check_stage.hh
index 1e56951..3cdae27 100644
--- a/src/gpu-compute/scoreboard_check_stage.hh
+++ b/src/gpu-compute/scoreboard_check_stage.hh
@@ -70,9 +70,9 @@
         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

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/29945
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I0b3732ce7c03781ee15332dac7a21c097ad387a4
Gerrit-Change-Number: 29945
Gerrit-PatchSet: 1
Gerrit-Owner: Anthony Gutierrez <[email protected]>
Gerrit-Reviewer: Tony Gutierrez <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to