From 1c8e560cbeae514881bc5bdf0407c421455064e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20L=C3=BCtke=20Dreimann?= Date: Tue, 23 Aug 2022 16:50:48 +0200 Subject: [PATCH] WIP: scheduler --- repos/dde_uos-intel-gpgpu/src/gpgpu/rpc.cc | 1 - .../src/gpgpu/scheduler.cc | 42 +++++++++++-------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/repos/dde_uos-intel-gpgpu/src/gpgpu/rpc.cc b/repos/dde_uos-intel-gpgpu/src/gpgpu/rpc.cc index d26706d8ed..1320e56bdd 100644 --- a/repos/dde_uos-intel-gpgpu/src/gpgpu/rpc.cc +++ b/repos/dde_uos-intel-gpgpu/src/gpgpu/rpc.cc @@ -66,7 +66,6 @@ int gpgpu::Session_component::start_task(unsigned long kconf) Kernel* kernel = (Kernel*)_global_gpgpu_genode->aligned_alloc(0, sizeof(Kernel)); vgpu.add_kernel(kernel); - TODO: free this somewhere TODO: start scheduler if its idling */ diff --git a/repos/dde_uos-intel-gpgpu/src/gpgpu/scheduler.cc b/repos/dde_uos-intel-gpgpu/src/gpgpu/scheduler.cc index ad45ed7226..d861354623 100644 --- a/repos/dde_uos-intel-gpgpu/src/gpgpu/scheduler.cc +++ b/repos/dde_uos-intel-gpgpu/src/gpgpu/scheduler.cc @@ -4,18 +4,29 @@ #include "../uos-intel-gpgpu/driver/gpgpu_driver.h" #include "../uos-intel-gpgpu/driver/ppgtt32.h" +// genode instance +#include "gpgpu_genode.h" +extern gpgpu_genode* _global_gpgpu_genode; + void gpgpu::Scheduler::schedule_next() { - VGpu *next; - if ((next = static_cast(_run_list.first()))) { - this->dispatch(*next); - _curr_vgpu = next; + // TODO: fix endless loop, if all vgpus have no kernel + do + { + VGpu* next; + if ((next = static_cast(_run_list.first()))) { + + // set vgpu and change to its context + this->dispatch(*next); + _curr_vgpu = next; - // move vgpu to end of list - _run_list.remove(next); - _run_list.insert(next); - } else - _curr_vgpu = nullptr; + // move vgpu to end of list + _run_list.remove(next); + _run_list.insert(next); + } else + _curr_vgpu = nullptr; + } + while(_curr_vgpu != nullptr && !_curr_vgpu->has_kernel()); // continue search if we picked a vgpu without kernel } void gpgpu::Scheduler::handle_gpu_event() @@ -27,22 +38,19 @@ void gpgpu::Scheduler::handle_gpu_event() /* Switch to next vGPU in the run list */ schedule_next(); - /* If no vGPU to schedule, this means that we don't have any clients anymore. - * Thus, there are also no kernels anymore to run. */ + // If no vGPU to schedule, this means that we don't have any clients with kernels anymore. if (_curr_vgpu == nullptr) return; Kernel *next = _curr_vgpu->take_kernel(); - if (!next) /* If there is no kernel for the vGPU left */ - { - // TODO: search for kernels in vgpu list - return; - } - // set frequency gpgpudriver.setMaxFreq(); // run gpgpu task gpgpudriver.enqueueRun(*next->get_config()); + + // free kernel object + // kernel_config will not be freed, just the Queue object! + _global_gpgpu_genode->free(next); }