global driver config

This commit is contained in:
Marcel Lütke Dreimann
2025-01-30 10:54:41 +01:00
parent b1b557e6b9
commit 292b8765e3
6 changed files with 39 additions and 16 deletions

View File

@@ -1,6 +1,11 @@
#ifndef CONFIG_H
#define CONFIG_H
#define QEMU_TEST
//#define VERBOSE
#define SCHED_CFS
//#define SCHED_RR // default
#endif // CONFIG_H

View File

@@ -1,5 +1,6 @@
#include <base/component.h>
#include "../config.h"
#include "../virt/rpc.h"
#include "../virt/scheduler.h"
@@ -7,12 +8,11 @@
#include <driver/gpgpu_driver.h>
#include "gpgpu_genode.h"
//#define TEST // test stubs only (works with qemu)
#ifdef TEST
#ifdef QEMU_TEST
#include <stubs.h>
#else
#else // QEMU_TEST
#include "test.h"
#endif // TEST
#endif // QEMU_TEST
gpgpu::gpgpu_genode* _global_gpgpu_genode;
gpgpu_virt::GPGPUScheduler* _global_sched;
@@ -28,7 +28,7 @@ void Component::construct(Genode::Env& e)
static gpgpu_virt::GPGPUScheduler sched;
_global_sched = &sched;
#ifdef TEST
#ifdef QEMU_TEST
// test prink
printk("Hello printk: %d", 42);
@@ -80,7 +80,7 @@ void Component::construct(Genode::Env& e)
// test interrupts
_global_gpgpu_genode->registerInterruptHandler();
Genode::log("Interrupt test finished!");
#else
#else // QEMU_TEST
// init driver
Genode::log("Init GPGPU driver...");
GPGPU_Driver& gpgpudriver = GPGPU_Driver::getInstance();
@@ -91,7 +91,7 @@ void Component::construct(Genode::Env& e)
// run the test and hope the best
Genode::log("Run self test...");
gpgpu::run_gpgpu_test();
#endif // TEST
#endif // QEMU_TEST
Genode::log("Register RPCs...");
static gpgpu_virt::Main main(e);

View File

@@ -9,7 +9,7 @@ SRC_CC = main.cc gpgpu_genode.cc stubs.cc test.cc ../virt/rpc.cc ../virt/strateg
LIBS = base
INC_DIR += $(GPGPU_DRIVER_PATH)
$(TARGET): $(UOS_INTEL_GPGPU) $(SRC_CC) ../virt/strategies/config.h
$(TARGET): $(UOS_INTEL_GPGPU) $(SRC_CC) ../config.h
$(UOS_INTEL_GPGPU):
$(MSG_BUILD) "Building uos-intel-gpgpu..."

View File

@@ -30,7 +30,9 @@ void Session_component::register_vm(Genode::size_t size, Genode::Ram_dataspace_c
ram_cap_vm = ram_cap;
// create vgpu context and add it to scheduler
#ifndef QEMU_TEST
vgpu.allocContext();
#endif // QEMU_TEST
_global_sched->add_vgpu(&vgpu);
}
@@ -67,7 +69,8 @@ void Session_component::start_task(unsigned long kconf)
// trigger sched
_global_sched->trigger();
/*static int id = 0;
#ifdef VERBOSE
static int id = 0;
Genode::log("Kernel ", id);
for(int i = 0; i < 3; i++)
{
@@ -81,19 +84,20 @@ void Session_component::start_task(unsigned long kconf)
{
Genode::log("\t\tvaddr: ", (void*)kc->buffConfigs[i].buffer);
Genode::log("\t\tval: ", *((uint32_t*)(kc->buffConfigs[i].buffer)));
Genode::log("\t\tgpuaddr: ", (void*)((addr_t)kc->buffConfigs[i].ga)); // to print this, temporary make the var public
Genode::log("\t\tpos: ", (uint32_t)kc->buffConfigs[i].pos); // to print this, temporary make the var public
//Genode::log("\t\tgpuaddr: ", (void*)((addr_t)kc->buffConfigs[i].ga)); // to print this, temporary make the var public
//Genode::log("\t\tpos: ", (uint32_t)kc->buffConfigs[i].pos); // to print this, temporary make the var public
}
else
{
Genode::log("\t\tvaddr: ", (void*)((Genode::addr_t)kc->buffConfigs[i].buffer - base + mapped_base));
Genode::log("\t\tpaddr: ", (void*)kc->buffConfigs[i].buffer);
Genode::log("\t\tgpuaddr: ", (void*)((addr_t)kc->buffConfigs[i].ga)); // to print this, temporary make the var public
Genode::log("\t\tpos: ", (uint32_t)kc->buffConfigs[i].pos); // to print this, temporary make the var public
//Genode::log("\t\tgpuaddr: ", (void*)((addr_t)kc->buffConfigs[i].ga)); // to print this, temporary make the var public
//Genode::log("\t\tpos: ", (uint32_t)kc->buffConfigs[i].pos); // to print this, temporary make the var public
}
Genode::log("\t\tsize: ", (int)kc->buffConfigs[i].buffer_size);
}
id++;*/
id++;
#endif // VERBOSE
}
Session_component::~Session_component()

View File

@@ -1,7 +1,7 @@
#ifndef SCHEDULER_H
#define SCHEDULER_H
#include "strategies/config.h"
#include "../config.h"
#include "vgpu.h"
#include "kernel.h"
@@ -57,9 +57,11 @@ namespace gpgpu_virt {
*/
void handle_gpu_event()
{
#ifndef QEMU_TEST
// reduce frequency
GPGPU_Driver& gpgpudriver = GPGPU_Driver::getInstance();
gpgpudriver.setMinFreq();
#endif // QEMU_TEST
/* Switch to next vGPU in the run list */
_curr_vgpu = strat.nextVGPU();
@@ -78,11 +80,23 @@ namespace gpgpu_virt {
// switch context
dispatch(*_curr_vgpu);
#ifdef QEMU_TEST
// sim interupt
handle_gpu_event();
// set finished and call callback
next->get_config()->finished = true;
if(next->get_config()->finish_callback)
{
next->get_config()->finish_callback();
}
#else
// set frequency
gpgpudriver.setMaxFreq();
// run gpgpu task
gpgpudriver.enqueueRun(*next->get_config());
#endif // QEMU_TEST
// free kernel object
// kernel_config will not be freed, just the Queue object!

View File

@@ -2,7 +2,7 @@
#define VGPU_H
#include <base/log.h>
#include "strategies/config.h"
#include "../config.h"
#include "kernel.h"
#ifdef SCHED_CFS