mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 20:42:56 +01:00
fixed rpc interface
This commit is contained in:
31
repos/dde_uos-intel-gpgpu/src/gpgpu/kernel.h
Normal file
31
repos/dde_uos-intel-gpgpu/src/gpgpu/kernel.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef KERNEL_H
|
||||
#define KERNEL_H
|
||||
|
||||
#define GENODE
|
||||
#include "../uos-intel-gpgpu/driver/gpgpu_driver.h"
|
||||
#include <base/fixed_stdint.h>
|
||||
#include <util/list.h>
|
||||
|
||||
namespace gpgpu {
|
||||
|
||||
typedef Genode::uint8_t Kernel_image;
|
||||
|
||||
/**
|
||||
* @class This class represents a kernel
|
||||
*
|
||||
*/
|
||||
class Kernel : public Genode::List<gpgpu::Kernel>::Element
|
||||
{
|
||||
private:
|
||||
struct kernel_config* kconf;
|
||||
|
||||
Kernel(const Kernel ©) = delete;
|
||||
|
||||
public:
|
||||
Kernel(struct kernel_config* k) : kconf(k) {}
|
||||
|
||||
inline struct kernel_config* get_config() { return kconf; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // KERNEL_H
|
||||
@@ -24,14 +24,13 @@ void Component::construct(Genode::Env& e)
|
||||
// init globals
|
||||
static gpgpu_genode gg(e);
|
||||
_global_gpgpu_genode = ≫
|
||||
|
||||
static gpgpu::Main main(e);
|
||||
|
||||
|
||||
#ifdef TEST
|
||||
// test prink
|
||||
printk("Hello printk: %d", 42);
|
||||
|
||||
// test alloc
|
||||
uint8_t* dummy = (uint8_t*)uos_aligned_alloc(0, 42);
|
||||
uint8_t* test = (uint8_t*)uos_aligned_alloc(0x1000, 0x1000);
|
||||
uint64_t addr = (uint64_t)test;
|
||||
if((addr & 0xFFF) != 0)
|
||||
@@ -54,6 +53,7 @@ void Component::construct(Genode::Env& e)
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(dummy);
|
||||
free(test);
|
||||
Genode::log("Allocator test finished!");
|
||||
|
||||
@@ -79,13 +79,19 @@ void Component::construct(Genode::Env& e)
|
||||
Genode::log("Interrupt test finished!");
|
||||
#else
|
||||
// init driver
|
||||
Genode::log("Init GPGPU driver...");
|
||||
GPGPU_Driver& gpgpudriver = GPGPU_Driver::getInstance();
|
||||
gpgpudriver.init(0);
|
||||
Genode::log("Register int handler...");
|
||||
_global_gpgpu_genode->registerInterruptHandler();
|
||||
|
||||
// run the test and hope the best
|
||||
Genode::log("Run self test...");
|
||||
run_gpgpu_test();
|
||||
#endif // TEST
|
||||
|
||||
Genode::log("Register RPCs...");
|
||||
static gpgpu::Main main(e);
|
||||
|
||||
Genode::log("This is the UOS Intel GPGPU End!");
|
||||
}
|
||||
|
||||
@@ -19,11 +19,6 @@ namespace gpgpu {
|
||||
struct Main;
|
||||
}
|
||||
|
||||
void yeah()
|
||||
{
|
||||
Genode::log("yeah");
|
||||
}
|
||||
|
||||
int gpgpu::Session_component::say_hello(int& i)
|
||||
{
|
||||
Genode::log("Hello from uos-intel-gpgpu!");
|
||||
@@ -47,18 +42,21 @@ int gpgpu::Session_component::start_task(unsigned long kconf)
|
||||
kc->binary = (Genode::uint8_t*)((Genode::addr_t)kc->binary + mapped_base);
|
||||
// at this point all IO buffers should have phys addrs and all others have driver virt addrs
|
||||
|
||||
// this is just for testing
|
||||
kc->finish_callback = yeah;
|
||||
|
||||
// set maximum frequency
|
||||
//GPGPU_Driver& gpgpudriver = GPGPU_Driver::getInstance();
|
||||
//gpgpudriver.setMaxFreq();
|
||||
GPGPU_Driver& gpgpudriver = GPGPU_Driver::getInstance();
|
||||
gpgpudriver.setMaxFreq();
|
||||
|
||||
// start gpu task
|
||||
//gpgpudriver.enqueueRun(*kc);
|
||||
gpgpudriver.enqueueRun(*kc);
|
||||
|
||||
/*
|
||||
Kernel* kernel = (Kernel*)_global_gpgpu_genode->aligned_alloc(0, sizeof(Kernel));
|
||||
vgpu.add_kernel(kernel);
|
||||
|
||||
free this somewhere
|
||||
*/
|
||||
|
||||
static int id = 0;
|
||||
Genode::log("Started GPGPU-Task: ", id);
|
||||
return id++;
|
||||
}
|
||||
|
||||
@@ -75,7 +73,6 @@ gpgpu::Root_component::Root_component(Genode::Entrypoint &ep,
|
||||
|
||||
}
|
||||
|
||||
|
||||
gpgpu::Main::Main(Genode::Env &env) : env(env)
|
||||
{
|
||||
/*
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <root/component.h>
|
||||
#include <base/rpc_server.h>
|
||||
#include <gpgpu/session.h>
|
||||
#include "vgpu.h"
|
||||
|
||||
namespace gpgpu {
|
||||
struct Session_component;
|
||||
@@ -14,7 +15,10 @@ namespace gpgpu {
|
||||
|
||||
struct gpgpu::Session_component : Genode::Rpc_object<Session>
|
||||
{
|
||||
Genode::addr_t mapped_base = 0;
|
||||
VGpu vgpu;
|
||||
Genode::addr_t mapped_base;
|
||||
|
||||
Session_component() : vgpu(), mapped_base(0) {}
|
||||
|
||||
int say_hello(int& i) override;
|
||||
|
||||
|
||||
53
repos/dde_uos-intel-gpgpu/src/gpgpu/vgpu.h
Normal file
53
repos/dde_uos-intel-gpgpu/src/gpgpu/vgpu.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef VGPU_H
|
||||
#define VGPU_H
|
||||
|
||||
#define GENODE
|
||||
#include "../uos-intel-gpgpu/driver/gpgpu_driver.h"
|
||||
#include "../uos-intel-gpgpu/driver/ppgtt32.h"
|
||||
#include <util/list.h>
|
||||
#include "kernel.h"
|
||||
|
||||
namespace gpgpu {
|
||||
|
||||
class VGpu : public Chain
|
||||
{
|
||||
private:
|
||||
PPGTT32* ppgtt;
|
||||
Genode::List<Kernel> ready_list;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new VGpu object
|
||||
*/
|
||||
VGpu() : ppgtt(nullptr), ready_list() {}
|
||||
|
||||
/**
|
||||
* @brief Add a kernel to the vGPU's ready list
|
||||
*
|
||||
* @param kernel - the kernel object to enqueue
|
||||
*/
|
||||
void add_kernel(Kernel* kernel) {
|
||||
ready_list.insert(kernel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Dequeue a kernel from the ready list
|
||||
*
|
||||
* @return First kernel image in ready list
|
||||
*/
|
||||
Kernel* take_kernel() {
|
||||
Kernel* k = ready_list.first();
|
||||
ready_list.remove(k);
|
||||
return k;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the ppgtt object
|
||||
*
|
||||
* @return PPGTT
|
||||
*/
|
||||
PPGTT32* get_ppgtt() { return ppgtt; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // VGPU_H
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <base/log.h>
|
||||
#include <libc/component.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#define CL_TARGET_OPENCL_VERSION 100
|
||||
#include "CL/cl.h"
|
||||
#include "test.h"
|
||||
@@ -9,6 +11,11 @@ extern int main(int argc, char *argv[]);
|
||||
|
||||
void testvm_construct(Genode::Env& env)
|
||||
{
|
||||
// wait for gpgpu construction
|
||||
Libc::with_libc([&] {
|
||||
usleep(5000000);
|
||||
});
|
||||
|
||||
// init CL env
|
||||
Genode::log("===Init VM===");
|
||||
const unsigned long size = 0x10000 * 0x1000;
|
||||
@@ -30,10 +37,10 @@ void testvm_construct(Genode::Env& env)
|
||||
run_gpgpu_test(alloc);
|
||||
|
||||
// run 2mm
|
||||
/*Genode::log("===Run 2mm===");
|
||||
Genode::log("===Run 2mm===");
|
||||
Libc::with_libc([&] {
|
||||
main(0, 0);
|
||||
});*/
|
||||
});
|
||||
|
||||
Genode::log("===End===");
|
||||
Genode::log("hello gpgpu completed");
|
||||
|
||||
Reference in New Issue
Block a user