summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gpu-compute/SConscript2
-rw-r--r--src/gpu-compute/of_scheduling_policy.cc76
-rw-r--r--src/gpu-compute/of_scheduling_policy.hh64
-rw-r--r--src/gpu-compute/rr_scheduling_policy.cc67
-rw-r--r--src/gpu-compute/rr_scheduling_policy.hh61
-rw-r--r--src/gpu-compute/schedule_stage.cc3
-rw-r--r--src/gpu-compute/scheduler.cc43
-rw-r--r--src/gpu-compute/scheduler.hh39
-rw-r--r--src/gpu-compute/scheduling_policy.hh50
9 files changed, 151 insertions, 254 deletions
diff --git a/src/gpu-compute/SConscript b/src/gpu-compute/SConscript
index 8cf1ed8cf..73d0a6654 100644
--- a/src/gpu-compute/SConscript
+++ b/src/gpu-compute/SConscript
@@ -65,9 +65,7 @@ Source('hsa_object.cc')
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 7f114706a..000000000
--- 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 94b5fdcd7..34d46867f 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()
+ {
+ }
+
+ 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;
+
+ 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;
+ }
+ }
- Wavefront* chooseWave();
- void bindList(std::vector<Wavefront*> *list);
+ // 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);
- private:
- // List of waves which are participating in scheduling.
- // This scheduler selects the oldest wave from this list
- std::vector<Wavefront*> *scheduleList;
+ 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 5d3591901..000000000
--- 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 3e83748da..a6ee383a5 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"
-
-class Wavefront;
+#include "gpu-compute/scheduling_policy.hh"
+#include "gpu-compute/wavefront.hh"
-// 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()
+ {
+ }
+
+ 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);
- Wavefront* chooseWave();
- void bindList(std::vector<Wavefront*> *list);
+ /**
+ * 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());
- 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;
+ 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 068136026..9f41a5ee5 100644
--- a/src/gpu-compute/schedule_stage.cc
+++ b/src/gpu-compute/schedule_stage.cc
@@ -45,8 +45,7 @@ ScheduleStage::ScheduleStage(const ComputeUnitParams *p)
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 1cd0bfe55..58a62034d 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 148ec9425..467c5bc02 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 <vector>
-#include "gpu-compute/of_scheduling_policy.hh"
-#include "gpu-compute/rr_scheduling_policy.hh"
#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 b5e923c62..62fad7ebc 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(); }
+ SchedulingPolicy() { }
+ virtual Wavefront *chooseWave(std::vector<Wavefront*> *sched_list) = 0;
+};
+
+/**
+ * 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() { }
- void
- bindList(std::vector<Wavefront*> *list)
+ Wavefront*
+ chooseWave(std::vector<Wavefront*> *sched_list) override
{
- return policyImpl.bindList(list);
+ return Policy::__chooseWave(sched_list);
}
-
- private:
- Impl policyImpl;
};
-#endif // __SCHEDULING_POLICY_HH__
+#endif // __GPU_COMPUTE_SCHEDULING_POLICY_HH__