mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 20:42:56 +01:00
gpgpu_virt namespace
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
#ifndef HELLO_GPGPU_CLIENT_H
|
||||
#define HELLO_GPGPU_CLIENT_H
|
||||
|
||||
#include <gpgpu/session.h>
|
||||
#include <gpgpu_virt/session.h>
|
||||
#include <base/rpc_client.h>
|
||||
#include <base/log.h>
|
||||
|
||||
namespace gpgpu { struct Session_client; }
|
||||
|
||||
struct gpgpu::Session_client : Genode::Rpc_client<gpgpu::Session>
|
||||
namespace gpgpu_virt
|
||||
{
|
||||
Session_client(Genode::Capability<gpgpu::Session> cap)
|
||||
: Genode::Rpc_client<gpgpu::Session>(cap) { }
|
||||
|
||||
struct Session_client : Genode::Rpc_client<Session>
|
||||
{
|
||||
Session_client(Genode::Capability<Session> cap)
|
||||
: Genode::Rpc_client<Session>(cap) { }
|
||||
|
||||
int start_task(unsigned long kconf) override
|
||||
{
|
||||
@@ -28,4 +29,6 @@ struct gpgpu::Session_client : Genode::Rpc_client<gpgpu::Session>
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // HELLO_GPGPU_CLIENT_H
|
||||
@@ -1,21 +1,24 @@
|
||||
#ifndef HELLO_GPGPU_CONNECTION_H
|
||||
#define HELLO_GPGPU_CONNECTION_H
|
||||
|
||||
#include <hello_gpgpu_session/client.h>
|
||||
#include <gpgpu_virt/client.h>
|
||||
#include <base/connection.h>
|
||||
|
||||
namespace gpgpu { struct Connection; }
|
||||
namespace gpgpu_virt
|
||||
{
|
||||
|
||||
struct gpgpu::Connection : Genode::Connection<gpgpu::Session>, Session_client
|
||||
struct Connection : Genode::Connection<Session>, Session_client
|
||||
{
|
||||
Connection(Genode::Env &env)
|
||||
:
|
||||
/* create session */
|
||||
Genode::Connection<gpgpu::Session>(env, session(env.parent(),
|
||||
Genode::Connection<Session>(env, session(env.parent(),
|
||||
"ram_quota=6K, cap_quota=4")),
|
||||
|
||||
/* initialize RPC interface */
|
||||
Session_client(cap()) { }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // HELLO_GPGPU_CONNECTION_H
|
||||
@@ -4,11 +4,9 @@
|
||||
#include <session/session.h>
|
||||
#include <base/rpc.h>
|
||||
|
||||
namespace gpgpu {
|
||||
struct Session;
|
||||
}
|
||||
namespace gpgpu_virt {
|
||||
|
||||
struct gpgpu::Session : Genode::Session
|
||||
struct Session : Genode::Session
|
||||
{
|
||||
static const char *service_name() { return "gpgpu"; }
|
||||
|
||||
@@ -29,4 +27,6 @@ struct gpgpu::Session : Genode::Session
|
||||
GENODE_RPC_INTERFACE(Rpc_say_hello, Rpc_register_vm, Rpc_start_task);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // GPGPU_SESSION
|
||||
@@ -15,7 +15,7 @@
|
||||
#endif // TEST
|
||||
|
||||
gpgpu_genode* _global_gpgpu_genode;
|
||||
gpgpu::Scheduler* _global_sched;
|
||||
gpgpu_virt::Scheduler* _global_sched;
|
||||
|
||||
void Component::construct(Genode::Env& e)
|
||||
{
|
||||
@@ -25,7 +25,7 @@ void Component::construct(Genode::Env& e)
|
||||
// init globals
|
||||
static gpgpu_genode gg(e);
|
||||
_global_gpgpu_genode = ≫
|
||||
static gpgpu::Scheduler sched;
|
||||
static gpgpu_virt::Scheduler sched;
|
||||
_global_sched = &sched;
|
||||
|
||||
#ifdef TEST
|
||||
@@ -94,7 +94,7 @@ void Component::construct(Genode::Env& e)
|
||||
#endif // TEST
|
||||
|
||||
Genode::log("Register RPCs...");
|
||||
static gpgpu::Main main(e);
|
||||
static gpgpu_virt::Main main(e);
|
||||
|
||||
Genode::log("This is the UOS Intel GPGPU End!");
|
||||
}
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
#ifndef KERNEL_H
|
||||
#define KERNEL_H
|
||||
|
||||
#include <util/list.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;
|
||||
namespace gpgpu_virt {
|
||||
|
||||
/**
|
||||
* @class This class represents a kernel
|
||||
*
|
||||
*/
|
||||
class Kernel : public Genode::List<gpgpu::Kernel>::Element
|
||||
class Kernel : public Genode::List<Kernel>::Element
|
||||
{
|
||||
private:
|
||||
struct kernel_config* kconf;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <base/heap.h>
|
||||
#include <root/component.h>
|
||||
#include <base/rpc_server.h>
|
||||
#include <gpgpu/session.h>
|
||||
#include <gpgpu_virt/session.h>
|
||||
|
||||
#include "rpc.h"
|
||||
#include "scheduler.h"
|
||||
@@ -10,19 +10,15 @@
|
||||
// genode instance
|
||||
#include "../gpgpu/gpgpu_genode.h"
|
||||
extern gpgpu_genode* _global_gpgpu_genode;
|
||||
extern gpgpu::Scheduler* _global_sched;
|
||||
extern gpgpu_virt::Scheduler* _global_sched;
|
||||
|
||||
// driver
|
||||
#define GENODE // use genodes stdint header
|
||||
#include "../uos-intel-gpgpu/driver/gpgpu_driver.h"
|
||||
|
||||
namespace gpgpu {
|
||||
struct Session_component;
|
||||
struct Root_component;
|
||||
struct Main;
|
||||
}
|
||||
namespace gpgpu_virt {
|
||||
|
||||
int gpgpu::Session_component::say_hello(int& i)
|
||||
int Session_component::say_hello(int& i)
|
||||
{
|
||||
Genode::log("Hello from uos-intel-gpgpu!");
|
||||
Genode::log("Here is your number: ", i);
|
||||
@@ -31,14 +27,14 @@ int gpgpu::Session_component::say_hello(int& i)
|
||||
return 42;
|
||||
}
|
||||
|
||||
void gpgpu::Session_component::register_vm(Genode::size_t size, Genode::Ram_dataspace_capability& ram_cap_vm)
|
||||
void Session_component::register_vm(Genode::size_t size, Genode::Ram_dataspace_capability& ram_cap_vm)
|
||||
{
|
||||
ram_cap = _global_gpgpu_genode->allocRamCap(size, mapped_base, base);
|
||||
ram_cap_vm = ram_cap;
|
||||
_global_sched->add_vgpu(&vgpu);
|
||||
}
|
||||
|
||||
int gpgpu::Session_component::start_task(unsigned long kconf)
|
||||
int Session_component::start_task(unsigned long kconf)
|
||||
{
|
||||
// convert offset to driver virt addr
|
||||
struct kernel_config* kc = (struct kernel_config*)(kconf + mapped_base);
|
||||
@@ -83,26 +79,26 @@ int gpgpu::Session_component::start_task(unsigned long kconf)
|
||||
return id++;
|
||||
}
|
||||
|
||||
gpgpu::Session_component::~Session_component()
|
||||
Session_component::~Session_component()
|
||||
{
|
||||
_global_sched->remove_vgpu(&vgpu);
|
||||
_global_gpgpu_genode->freeRamCap(ram_cap);
|
||||
}
|
||||
|
||||
gpgpu::Session_component* gpgpu::Root_component::_create_session(const char *)
|
||||
Session_component* Root_component::_create_session(const char *)
|
||||
{
|
||||
return new (md_alloc()) gpgpu::Session_component();
|
||||
return new (md_alloc()) Session_component();
|
||||
}
|
||||
|
||||
gpgpu::Root_component::Root_component(Genode::Entrypoint &ep,
|
||||
Root_component::Root_component(Genode::Entrypoint &ep,
|
||||
Genode::Allocator &alloc)
|
||||
:
|
||||
Genode::Root_component<gpgpu::Session_component>(ep, alloc)
|
||||
Genode::Root_component<Session_component>(ep, alloc)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
gpgpu::Main::Main(Genode::Env &env) : env(env)
|
||||
Main::Main(Genode::Env &env) : env(env)
|
||||
{
|
||||
/*
|
||||
* Create a RPC object capability for the root interface and
|
||||
@@ -110,3 +106,5 @@ gpgpu::Main::Main(Genode::Env &env) : env(env)
|
||||
*/
|
||||
env.parent().announce(env.ep().manage(root));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,16 +4,13 @@
|
||||
#include <base/heap.h>
|
||||
#include <root/component.h>
|
||||
#include <base/rpc_server.h>
|
||||
#include <gpgpu/session.h>
|
||||
#include <gpgpu_virt/session.h>
|
||||
#include "vgpu.h"
|
||||
|
||||
namespace gpgpu {
|
||||
struct Session_component;
|
||||
struct Root_component;
|
||||
struct Main;
|
||||
}
|
||||
namespace gpgpu_virt
|
||||
{
|
||||
|
||||
struct gpgpu::Session_component : Genode::Rpc_object<Session>
|
||||
struct Session_component : Genode::Rpc_object<Session>
|
||||
{
|
||||
VGpu vgpu;
|
||||
Genode::Ram_dataspace_capability ram_cap;
|
||||
@@ -31,7 +28,7 @@ struct gpgpu::Session_component : Genode::Rpc_object<Session>
|
||||
int start_task(unsigned long kconf) override;
|
||||
};
|
||||
|
||||
class gpgpu::Root_component
|
||||
class Root_component
|
||||
:
|
||||
public Genode::Root_component<Session_component>
|
||||
{
|
||||
@@ -45,7 +42,7 @@ class gpgpu::Root_component
|
||||
};
|
||||
|
||||
|
||||
struct gpgpu::Main
|
||||
struct Main
|
||||
{
|
||||
Genode::Env &env;
|
||||
|
||||
@@ -55,9 +52,11 @@ struct gpgpu::Main
|
||||
*/
|
||||
Genode::Sliced_heap sliced_heap { env.ram(), env.rm() };
|
||||
|
||||
gpgpu::Root_component root { env.ep(), sliced_heap };
|
||||
Root_component root { env.ep(), sliced_heap };
|
||||
|
||||
Main(Genode::Env &env);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // RPC_H
|
||||
|
||||
@@ -10,7 +10,10 @@ extern gpgpu_genode* _global_gpgpu_genode;
|
||||
#include "../uos-intel-gpgpu/driver/gpgpu_driver.h"
|
||||
#include "../uos-intel-gpgpu/driver/ppgtt32.h"
|
||||
|
||||
void gpgpu::Scheduler::schedule_next()
|
||||
namespace gpgpu_virt
|
||||
{
|
||||
|
||||
void Scheduler::schedule_next()
|
||||
{
|
||||
VGpu* first = nullptr;
|
||||
do
|
||||
@@ -46,7 +49,7 @@ void gpgpu::Scheduler::schedule_next()
|
||||
while(_curr_vgpu != nullptr && !_curr_vgpu->has_kernel()); // continue search if we picked a vgpu without kernel
|
||||
}
|
||||
|
||||
void gpgpu::Scheduler::handle_gpu_event()
|
||||
void Scheduler::handle_gpu_event()
|
||||
{
|
||||
// reduce frequency
|
||||
GPGPU_Driver& gpgpudriver = GPGPU_Driver::getInstance();
|
||||
@@ -81,3 +84,5 @@ void gpgpu::Scheduler::handle_gpu_event()
|
||||
// kernel_config will not be freed, just the Queue object!
|
||||
_global_gpgpu_genode->free(next);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <util/list.h>
|
||||
#include "vgpu.h"
|
||||
|
||||
namespace gpgpu {
|
||||
namespace gpgpu_virt {
|
||||
|
||||
class Scheduler
|
||||
{
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include "../uos-intel-gpgpu/driver/gpgpu_driver.h"
|
||||
#include "../uos-intel-gpgpu/driver/ppgtt32.h"
|
||||
|
||||
namespace gpgpu {
|
||||
namespace gpgpu_virt {
|
||||
|
||||
class VGpu : public Genode::List<gpgpu::VGpu>::Element
|
||||
class VGpu : public Genode::List<VGpu>::Element
|
||||
{
|
||||
private:
|
||||
PPGTT32* ppgtt;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <legacy/x86/platform_session/connection.h>
|
||||
|
||||
// rpc
|
||||
#include <hello_gpgpu_session/connection.h>
|
||||
#include <gpgpu_virt/connection.h>
|
||||
|
||||
// driver
|
||||
#include <gpgpu/gpgpu.h>
|
||||
@@ -30,7 +30,7 @@ private:
|
||||
Genode::addr_t mapped_base;
|
||||
|
||||
// rpc
|
||||
gpgpu::Connection backend_driver;
|
||||
gpgpu_virt::Connection backend_driver;
|
||||
|
||||
// do not allow copies
|
||||
cl_genode(const cl_genode& copy) = delete;
|
||||
|
||||
Reference in New Issue
Block a user