Anthony Gutierrez has submitted this change and it was merged. ( https://gem5-review.googlesource.com/10222 )

Change subject: gpu-compute: Cleanup the scheduler a bit
......................................................................

gpu-compute: Cleanup the scheduler a bit

Change-Id: If2c626544f208e15c91be975dee9253126862ced
Reviewed-on: https://gem5-review.googlesource.com/10222
Reviewed-by: Alexandru Duțu <alexandru.d...@amd.com>
Maintainer: Anthony Gutierrez <anthony.gutier...@amd.com>
---
M src/gpu-compute/SConscript
D src/gpu-compute/of_scheduling_policy.cc
M src/gpu-compute/of_scheduling_policy.hh
D src/gpu-compute/rr_scheduling_policy.cc
M src/gpu-compute/rr_scheduling_policy.hh
M src/gpu-compute/schedule_stage.cc
M src/gpu-compute/scheduler.cc
M src/gpu-compute/scheduler.hh
M src/gpu-compute/scheduling_policy.hh
9 files changed, 154 insertions(+), 257 deletions(-)

Approvals:
  Alexandru Duțu: Looks good to me, approved
  Anthony Gutierrez: Looks good to me, approved



diff --git a/src/gpu-compute/SConscript b/src/gpu-compute/SConscript
index 8cf1ed8..73d0a66 100644
--- a/src/gpu-compute/SConscript
+++ b/src/gpu-compute/SConscript
@@ -65,9 +65,7 @@
 Source('kernel_cfg.cc')
 Source('lds_state.cc')
 Source('local_memory_pipeline.cc')
-Source('of_scheduling_policy.cc')
 Source('pool_manager.cc')
-Source('rr_scheduling_policy.cc')
 Source('schedule_stage.cc')
 Source('scheduler.cc')
 Source('scoreboard_check_stage.cc')
diff --git a/src/gpu-compute/of_scheduling_policy.cc b/src/gpu-compute/of_scheduling_policy.cc
deleted file mode 100644
index 7f11470..0000000
--- a/src/gpu-compute/of_scheduling_policy.cc
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2014-2015 Advanced Micro Devices, Inc.
- * All rights reserved.
- *
- * For use for simulation and test purposes only
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * Author: Sooraj Puthoor
- */
-
-#include "gpu-compute/of_scheduling_policy.hh"
-
-#include "gpu-compute/wavefront.hh"
-
-Wavefront*
-OFSchedulingPolicy::chooseWave()
-{
-    // Set when policy choose a wave to schedule
-    bool waveChosen = false;
-    Wavefront *selectedWave = nullptr;
-    int selectedWaveID = -1;
-    uint32_t selectedPosition = 0;
-
-    for (int position = 0; position < scheduleList->size(); ++position) {
-        Wavefront *curWave = scheduleList->at(position);
-        uint32_t curWaveID = curWave->wfDynId;
-
-        // Choosed wave with the lowest wave ID
-        if (selectedWaveID == -1 || curWaveID < selectedWaveID) {
-            waveChosen = true;
-            selectedWaveID = curWaveID;
-            selectedWave = curWave;
-            selectedPosition = position;
-        }
-    }
-
-    // Check to make sure ready list had atleast one schedulable wave
-    if (waveChosen) {
-        scheduleList->erase(scheduleList->begin() + selectedPosition);
-    } else {
-        panic("Empty ready list");
-    }
-
-    return selectedWave;
-}
-
-void
-OFSchedulingPolicy::bindList(std::vector<Wavefront*> *list)
-{
-    scheduleList = list;
-}
diff --git a/src/gpu-compute/of_scheduling_policy.hh b/src/gpu-compute/of_scheduling_policy.hh
index 94b5fdc..34d4686 100644
--- a/src/gpu-compute/of_scheduling_policy.hh
+++ b/src/gpu-compute/of_scheduling_policy.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2015 Advanced Micro Devices, Inc.
+ * Copyright (c) 2014-2017 Advanced Micro Devices, Inc.
  * All rights reserved.
  *
  * For use for simulation and test purposes only
@@ -14,9 +14,9 @@
* this list of conditions and the following disclaimer in the documentation
  * and/or other materials provided with the distribution.
  *
- * 3. Neither the name of the copyright holder nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
  *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -30,32 +30,54 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * Author: Sooraj Puthoor
+ * Authors: Sooraj Puthoor,
+ *          Anthony Gutierrez
  */

-#ifndef __OF_SCHEDULING_POLICY_HH__
-#define __OF_SCHEDULING_POLICY_HH__
+#ifndef __GPU_COMPUTE_OF_SCHEDULING_POLICY_HH__
+#define __GPU_COMPUTE_OF_SCHEDULING_POLICY_HH__

-#include <cstddef>
 #include <vector>

-#include "base/logging.hh"
+#include "gpu-compute/scheduling_policy.hh"
+#include "gpu-compute/wavefront.hh"

-class Wavefront;
-
-// Oldest First where age is marked by the wave id
-class OFSchedulingPolicy
+// oldest first where age is marked by the wave id
+class OFSchedulingPolicy final : public __SchedulingPolicy<OFSchedulingPolicy>
 {
   public:
-    OFSchedulingPolicy() : scheduleList(nullptr) { }
+    OFSchedulingPolicy()
+    {
+    }

-    Wavefront* chooseWave();
-    void bindList(std::vector<Wavefront*> *list);
+    static Wavefront*
+    __chooseWave(std::vector<Wavefront*> *sched_list)
+    {
+        panic_if(!sched_list->size(), "OF scheduling policy sched list is "
+            "empty.\n");
+        // set when policy choose a wave to schedule
+        Wavefront *selected_wave(nullptr);
+        int selected_wave_id = -1;
+        int selected_position = 0;

-  private:
-    // List of waves which are participating in scheduling.
-    // This scheduler selects the oldest wave from this list
-    std::vector<Wavefront*> *scheduleList;
+        for (int position = 0; position < sched_list->size(); ++position) {
+            Wavefront *cur_wave = sched_list->at(position);
+            int cur_wave_id = cur_wave->wfDynId;
+
+            // Choosed wave with the lowest wave ID
+            if (selected_wave_id == -1 || cur_wave_id < selected_wave_id) {
+                selected_wave_id = cur_wave_id;
+                selected_wave = cur_wave;
+                selected_position = position;
+            }
+        }
+
+        // Check to make sure ready list had at least one schedulable wave
+ panic_if(!selected_wave, "No wave found by OF scheduling policy.\n");
+        sched_list->erase(sched_list->begin() + selected_position);
+
+        return selected_wave;
+    }
 };

-#endif // __OF_SCHEDULING_POLICY_HH__
+#endif // __GPU_COMPUTE_OF_SCHEDULING_POLICY_HH__
diff --git a/src/gpu-compute/rr_scheduling_policy.cc b/src/gpu-compute/rr_scheduling_policy.cc
deleted file mode 100644
index 5d35919..0000000
--- a/src/gpu-compute/rr_scheduling_policy.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2014-2015 Advanced Micro Devices, Inc.
- * All rights reserved.
- *
- * For use for simulation and test purposes only
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * Author: Sooraj Puthoor
- */
-
-#include "gpu-compute/rr_scheduling_policy.hh"
-
-#include "gpu-compute/wavefront.hh"
-
-Wavefront*
-RRSchedulingPolicy::chooseWave()
-{
-    Wavefront *selectedWave = nullptr;
-
-    // Check to make sure ready list had atleast one schedulable wave
-    if (scheduleList->size()) {
-        // For RR policy, select the wave which is at the
-        // front of the list. The selected wave is popped
-        // out from the schedule list immediately after selection
-        // to avoid starvation. It is the responsibility of the
-        // module invoking the RR scheduler to make surei scheduling
-        // eligible waves are added to the back of the schedule
-        // list
-        selectedWave = scheduleList->front();
-        scheduleList->erase(scheduleList->begin() + 0);
-    } else {
-        panic("Empty ready list");
-    }
-
-    return selectedWave;
-}
-
-void
-RRSchedulingPolicy::bindList(std::vector<Wavefront*> *list)
-{
-    scheduleList = list;
-}
diff --git a/src/gpu-compute/rr_scheduling_policy.hh b/src/gpu-compute/rr_scheduling_policy.hh
index 3e83748..a6ee383 100644
--- a/src/gpu-compute/rr_scheduling_policy.hh
+++ b/src/gpu-compute/rr_scheduling_policy.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2015 Advanced Micro Devices, Inc.
+ * Copyright (c) 2014-2017 Advanced Micro Devices, Inc.
  * All rights reserved.
  *
  * For use for simulation and test purposes only
@@ -14,9 +14,9 @@
* this list of conditions and the following disclaimer in the documentation
  * and/or other materials provided with the distribution.
  *
- * 3. Neither the name of the copyright holder nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
  *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -30,36 +30,47 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * Author: Sooraj Puthoor
+ * Authors: Sooraj Puthoor,
+ *          Anthony Gutierrez
  */

-#ifndef __RR_SCHEDULING_POLICY_HH__
-#define __RR_SCHEDULING_POLICY_HH__
+#ifndef __GPU_COMPUTE_RR_SCHEDULING_POLICY_HH__
+#define __GPU_COMPUTE_RR_SCHEDULING_POLICY_HH__

-#include <inttypes.h>
-
-#include <cstddef>
-#include <utility>
 #include <vector>

-#include "base/logging.hh"
+#include "gpu-compute/scheduling_policy.hh"
+#include "gpu-compute/wavefront.hh"

-class Wavefront;
-
-// Round-Robin pick among the list of ready waves
-class RRSchedulingPolicy
+// round-robin pick among the list of ready waves
+class RRSchedulingPolicy final : public __SchedulingPolicy<RRSchedulingPolicy>
 {
   public:
-    RRSchedulingPolicy() : scheduleList(nullptr) { }
+    RRSchedulingPolicy()
+    {
+    }

-    Wavefront* chooseWave();
-    void bindList(std::vector<Wavefront*> *list);
+    static Wavefront*
+    __chooseWave(std::vector<Wavefront*> *sched_list)
+    {
+        panic_if(!sched_list->size(), "RR scheduling policy sched list is "
+            "empty.\n");
+        Wavefront *selected_wave(nullptr);

-  private:
-    // List of waves which are participating in scheduling.
-    // This scheduler selects one wave from this list based on
-    // round robin policy
-    std::vector<Wavefront*> *scheduleList;
+        /**
+         * For RR policy, select the wave that is at the front of
+         * the list. The selected wave is popped out from the schedule
+         * list immediately after selection to avoid starvation. It
+         * is the responsibility of the module invoking the RR scheduler
+         * to make sure it is scheduling eligible waves are added to the
+         * back of the schedule list.
+         */
+        selected_wave = sched_list->front();
+ panic_if(!selected_wave, "No wave found by RR scheduling policy.\n");
+        sched_list->erase(sched_list->begin());
+
+        return selected_wave;
+    }
 };

-#endif // __RR_SCHEDULING_POLICY_HH__
+#endif // __GPU_COMPUTE_RR_SCHEDULING_POLICY_HH__
diff --git a/src/gpu-compute/schedule_stage.cc b/src/gpu-compute/schedule_stage.cc
index 0681360..9f41a5e 100644
--- a/src/gpu-compute/schedule_stage.cc
+++ b/src/gpu-compute/schedule_stage.cc
@@ -45,8 +45,7 @@
       numMemUnits(p->num_global_mem_pipes + p->num_shared_mem_pipes)
 {
     for (int j = 0; j < numSIMDs + numMemUnits; ++j) {
-        Scheduler newScheduler(p);
-        scheduler.push_back(newScheduler);
+        scheduler.emplace_back(p);
     }
 }

diff --git a/src/gpu-compute/scheduler.cc b/src/gpu-compute/scheduler.cc
index 1cd0bfe..58a6203 100644
--- a/src/gpu-compute/scheduler.cc
+++ b/src/gpu-compute/scheduler.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2015 Advanced Micro Devices, Inc.
+ * Copyright (c) 2014-2017 Advanced Micro Devices, Inc.
  * All rights reserved.
  *
  * For use for simulation and test purposes only
@@ -14,9 +14,9 @@
* this list of conditions and the following disclaimer in the documentation
  * and/or other materials provided with the distribution.
  *
- * 3. Neither the name of the copyright holder nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
  *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -30,42 +30,35 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * Author: Sooraj Puthoor
+ * Authors: Sooraj Puthoor,
+ *          Anthony Gutierrez
  */

 #include "gpu-compute/scheduler.hh"

+#include "gpu-compute/of_scheduling_policy.hh"
+#include "gpu-compute/rr_scheduling_policy.hh"
+#include "params/ComputeUnit.hh"
+
 Scheduler::Scheduler(const ComputeUnitParams *p)
 {
-    if (p->execPolicy  == "OLDEST-FIRST") {
-        schedPolicy = SCHED_POLICY::OF_POLICY;
-    } else if (p->execPolicy  == "ROUND-ROBIN") {
-        schedPolicy = SCHED_POLICY::RR_POLICY;
+    if (p->execPolicy == "OLDEST-FIRST") {
+        schedPolicy = new OFSchedulingPolicy();
+    } else if (p->execPolicy == "ROUND-ROBIN") {
+        schedPolicy = new RRSchedulingPolicy();
     } else {
-        fatal("Unimplemented scheduling policy");
+        fatal("Unimplemented scheduling policy.\n");
     }
 }

 Wavefront*
 Scheduler::chooseWave()
 {
-    if (schedPolicy == SCHED_POLICY::OF_POLICY) {
-        return OFSchedPolicy.chooseWave();
-    } else if (schedPolicy == SCHED_POLICY::RR_POLICY) {
-        return RRSchedPolicy.chooseWave();
-    } else {
-        fatal("Unimplemented scheduling policy");
-    }
+    return schedPolicy->chooseWave(scheduleList);
 }

 void
-Scheduler::bindList(std::vector<Wavefront*> *list)
+Scheduler::bindList(std::vector<Wavefront*> *sched_list)
 {
-    if (schedPolicy == SCHED_POLICY::OF_POLICY) {
-        OFSchedPolicy.bindList(list);
-    } else if (schedPolicy == SCHED_POLICY::RR_POLICY) {
-        RRSchedPolicy.bindList(list);
-    } else {
-        fatal("Unimplemented scheduling policy");
-    }
+    scheduleList = sched_list;
 }
diff --git a/src/gpu-compute/scheduler.hh b/src/gpu-compute/scheduler.hh
index 148ec94..467c5bc 100644
--- a/src/gpu-compute/scheduler.hh
+++ b/src/gpu-compute/scheduler.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2015 Advanced Micro Devices, Inc.
+ * Copyright (c) 2014-2017 Advanced Micro Devices, Inc.
  * All rights reserved.
  *
  * For use for simulation and test purposes only
@@ -14,9 +14,9 @@
* this list of conditions and the following disclaimer in the documentation
  * and/or other materials provided with the distribution.
  *
- * 3. Neither the name of the copyright holder nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
  *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -30,34 +30,33 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * Author: Sooraj Puthoor
+ * Authors: Sooraj Puthoor,
+ *          Anthony Gutierrez
  */

-#ifndef __SCHEDULER_HH__
-#define __SCHEDULER_HH__
+#ifndef __GPU_COMPUTE_SCHEDULER_HH__
+#define __GPU_COMPUTE_SCHEDULER_HH__

-#include "gpu-compute/of_scheduling_policy.hh"
-#include "gpu-compute/rr_scheduling_policy.hh"
+#include <vector>
+
 #include "gpu-compute/scheduling_policy.hh"
-#include "params/ComputeUnit.hh"

-enum SCHED_POLICY
-{
-    OF_POLICY = 0,
-    RR_POLICY
-};
+class ComputeUnitParams;

 class Scheduler
 {
   public:
     Scheduler(const ComputeUnitParams *params);
     Wavefront *chooseWave();
-    void bindList(std::vector<Wavefront*> *list);
+    void bindList(std::vector<Wavefront*> *sched_list);

   private:
-    SCHED_POLICY schedPolicy;
-    SchedulingPolicy<RRSchedulingPolicy> RRSchedPolicy;
-    SchedulingPolicy<OFSchedulingPolicy> OFSchedPolicy;
+    /**
+     * Scheduling policy. Currently the model can support oldest-first
+     * or round-robin scheduling.
+     */
+    SchedulingPolicy *schedPolicy;
+    std::vector<Wavefront*> *scheduleList;
 };

-#endif // __SCHEDULER_HH__
+#endif // __GPU_COMPUTE_SCHEDULER_HH__
diff --git a/src/gpu-compute/scheduling_policy.hh b/src/gpu-compute/scheduling_policy.hh
index b5e923c..62fad7e 100644
--- a/src/gpu-compute/scheduling_policy.hh
+++ b/src/gpu-compute/scheduling_policy.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2015 Advanced Micro Devices, Inc.
+ * Copyright (c) 2014-2017 Advanced Micro Devices, Inc.
  * All rights reserved.
  *
  * For use for simulation and test purposes only
@@ -14,9 +14,9 @@
* this list of conditions and the following disclaimer in the documentation
  * and/or other materials provided with the distribution.
  *
- * 3. Neither the name of the copyright holder nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
  *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -30,28 +30,46 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * Author: Sooraj Puthoor
+ * Authors: Sooraj Puthoor,
+ *          Anthony Gutierrez
  */

-#ifndef __SCHEDULING_POLICY_HH__
-#define __SCHEDULING_POLICY_HH__
+#ifndef __GPU_COMPUTE_SCHEDULING_POLICY_HH__
+#define __GPU_COMPUTE_SCHEDULING_POLICY_HH__

 #include <vector>

-template<typename Impl>
+class Wavefront;
+
+/**
+ * Interface class for the wave scheduling policy.
+ */
 class SchedulingPolicy
 {
   public:
-    Wavefront* chooseWave() { return policyImpl.chooseWave(); }
-
-    void
-    bindList(std::vector<Wavefront*> *list)
-    {
-        return policyImpl.bindList(list);
-    }
-
-  private:
-    Impl policyImpl;
+    SchedulingPolicy() { }
+    virtual Wavefront *chooseWave(std::vector<Wavefront*> *sched_list) = 0;
 };

-#endif // __SCHEDULING_POLICY_HH__
+/**
+ * Intermediate class that derives from the i-face class, and implements
+ * its API. It uses the CRTP to take in the actual scheduling policy
+ * implementation as a template parameter. This allows us to use a pointer
+ * to SchedulingPolicy and instantiate whichever policy we want. The
+ * derived policies implement the scheduler arbitration logic using
+ * the static member method called __chooseWave();
+ */
+template<typename Policy>
+class __SchedulingPolicy : public SchedulingPolicy
+{
+  public:
+    __SchedulingPolicy() { }
+
+    Wavefront*
+    chooseWave(std::vector<Wavefront*> *sched_list) override
+    {
+        return Policy::__chooseWave(sched_list);
+    }
+};
+
+#endif // __GPU_COMPUTE_SCHEDULING_POLICY_HH__

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

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: If2c626544f208e15c91be975dee9253126862ced
Gerrit-Change-Number: 10222
Gerrit-PatchSet: 6
Gerrit-Owner: Anthony Gutierrez <anthony.gutier...@amd.com>
Gerrit-Reviewer: Alexandru Duțu <alexandru.d...@amd.com>
Gerrit-Reviewer: Anthony Gutierrez <anthony.gutier...@amd.com>
Gerrit-Reviewer: Bradford Beckmann <brad.beckm...@amd.com>
Gerrit-Reviewer: Brandon Potter <brandon.pot...@amd.com>
Gerrit-Reviewer: Michael LeBeane <michael.lebe...@amd.com>
Gerrit-Reviewer: Sooraj Puthoor <puthoorsoo...@gmail.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to