Mercurial > hg > Game > Cerium
view TaskManager/Gpu/GpuScheduler.h @ 2069:26aa08c9a1de draft default tip
cuda example fix
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 12 Feb 2017 10:04:55 +0900 |
parents | c8e35ceae52b |
children |
line wrap: on
line source
#ifndef INCLUDED_GPU_SCHEDULER #define INCLUDED_GPU_SCHEDULER #include "MainScheduler.h" #include "FifoDmaManager.h" #include "GpuThreads.h" #include "HTask.h" #include "TaskManager.h" #ifdef __APPLE__ #include <OpenCL/opencl.h> #else #include <unistd.h> #include <CL/cl.h> #endif extern TaskObject gpu_task_list[MAX_TASK_OBJECT]; #define STAGE 8 class GpuScheduler : public MainScheduler { 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_gpu(); void wait_for_event(cl_event* event,GpuBufferPtr m, TaskListPtr taskList,int cur); void run(); 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[STAGE]; cl_int ret; memaddr reply; cl_kernel kernel[STAGE]; cl_event kernel_event[STAGE]; GpuBuffer memin[STAGE]; GpuBuffer memout[STAGE]; HTask::htask_flag flag[STAGE]; private: 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);