Mercurial > hg > Game > Cerium
view TaskManager/Gpu/GpuScheduler.h @ 1845:ad05aeed3a98 draft
fix multiply / gpu
author | kono |
---|---|
date | Fri, 20 Dec 2013 22:25:38 +0900 |
parents | 3a5825ad4f4e |
children | 5238ca826d6e |
line wrap: on
line source
#ifndef INCLUDED_GPU_SCHEDULER #define INCLUDED_GPU_SCHEDULER #include "Scheduler.h" #include "FifoDmaManager.h" #include "GpuThreads.h" #include "HTask.h" #include "TaskManager.h" #ifdef __APPLE__ #include <OpenCL/opencl.h> #else #include <CL/cl.h> #endif extern TaskObject gpu_task_list[MAX_TASK_OBJECT]; class GpuScheduler : public Scheduler { public: typedef struct gpubuffer { cl_int allocate_size; cl_int size; cl_mem *buf; // clCreateBuffer cl_event *event; } GpuBuffer, *GpuBufferPtr; GpuScheduler(); virtual ~GpuScheduler(); void init_impl(int useRefDma); void init_gpu(); void wait_for_event(cl_event* event,GpuBufferPtr m, TaskListPtr taskList,int cur); void run(); void mail_write_from_host(memaddr data) { fifoDmaManager->mail_write_from_host(data); } memaddr mail_read_from_host() { return fifoDmaManager->mail_read_from_host(); } int has_mail_from_host() { return fifoDmaManager->has_mail_from_host(); } cl_platform_id platform_id; cl_device_id device_id; cl_uint ret_num_platforms; cl_uint ret_num_devices; cl_context context; cl_command_queue command_queue; cl_int ret; memaddr reply; cl_kernel kernel[2]; cl_event kernel_event[2]; GpuBuffer memin[2]; GpuBuffer memout[2]; HTask::htask_flag flag[2]; private: FifoDmaManager *fifoDmaManager; int load_kernel(int cmd); cl_mem createBuffer(GpuBufferPtr m, int i, cl_context context, cl_mem_flags flags, size_t size, cl_int *error); void initGpuBuffer(GpuBufferPtr m); void destroyGpuBuffer(GpuBufferPtr m); void gpuTaskError(int cur, TaskListPtr tasklist, int ret); }; #define GpuSchedRegister(str, filename, functionname) \ gpu_register_task(str, filename, functionname); #endif extern void gpu_register_task(int cmd,const char* filename,const char* functionname);