WIP: scheduler

This commit is contained in:
Marcel Lütke Dreimann
2022-08-22 17:21:21 +02:00
parent d43291f0ea
commit fd8757b19b
4 changed files with 46 additions and 5 deletions

View File

@@ -32,6 +32,7 @@ void gpgpu::Session_component::register_vm(Genode::size_t size, Genode::Ram_data
{
ram_cap = _global_gpgpu_genode->allocRamCap(size, mapped_base, base);
ram_cap_vm = ram_cap;
// TODO: register vgpu to scheduler
}
int gpgpu::Session_component::start_task(unsigned long kconf)
@@ -65,7 +66,8 @@ int gpgpu::Session_component::start_task(unsigned long kconf)
Kernel* kernel = (Kernel*)_global_gpgpu_genode->aligned_alloc(0, sizeof(Kernel));
vgpu.add_kernel(kernel);
free this somewhere
TODO: free this somewhere
TODO: start scheduler if its idling
*/
static int id = 0;

View File

@@ -4,7 +4,8 @@
#include "../uos-intel-gpgpu/driver/gpgpu_driver.h"
#include "../uos-intel-gpgpu/driver/ppgtt32.h"
void gpgpu::Scheduler::schedule_next() {
void gpgpu::Scheduler::schedule_next()
{
VGpu *next;
if ((next = static_cast<VGpu*>(_run_list.first()))) {
this->dispatch(*next);
@@ -17,7 +18,12 @@ void gpgpu::Scheduler::schedule_next() {
_curr_vgpu = nullptr;
}
void gpgpu::Scheduler::handle_gpu_event() {
void gpgpu::Scheduler::handle_gpu_event()
{
// reduce frequency
GPGPU_Driver& gpgpudriver = GPGPU_Driver::getInstance();
gpgpudriver.setMinFreq();
/* Switch to next vGPU in the run list */
schedule_next();
@@ -29,10 +35,12 @@ void gpgpu::Scheduler::handle_gpu_event() {
Kernel *next = _curr_vgpu->take_kernel();
if (!next) /* If there is no kernel for the vGPU left */
schedule_next(); /* pick the next vGPU, maybe it has got some kernels for us. */
{
// TODO: search for kernels in vgpu list
return;
}
// set frequency
GPGPU_Driver& gpgpudriver = GPGPU_Driver::getInstance();
gpgpudriver.setMaxFreq();
// run gpgpu task

View File

@@ -41,6 +41,26 @@ namespace gpgpu {
* a kernel has finished its execution.
*/
void handle_gpu_event();
/**
* @brief
*
* @param vgpu
*/
void add_vgpu(VGpu* vgpu)
{
_run_list.insert(vgpu);
}
/**
* @brief
*
* @param vgpu
*/
void remove_vgpu(VGpu* vgpu)
{
_run_list.remove(vgpu);
}
};
}

View File

@@ -31,6 +31,17 @@ namespace gpgpu {
ready_list.insert(kernel);
}
/**
* @brief
*
* @return true
* @return false
*/
bool has_kernel() const
{
return ready_list.first() == nullptr;
}
/**
* @brief Dequeue a kernel from the ready list
*