Mercurial > hg > Game > Cerium
view TaskManager/Cuda/CudaScheduler.h @ 1927:4eefec26e3e2 draft
add file
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 31 Jan 2014 07:15:07 +0900 |
parents | cd5bbd8ec5d6 |
children | 67e50779feb4 |
line wrap: on
line source
#ifndef INCLUDE_CUDA_SCHEDULER #define INCLUDE_CUDA_SCHEDULER #include "MainScheduler.h" #include "FifoDmaManager.h" #include "CudaThreads.h" #include "HTask.h" #include "TaskManager.h" #include <cuda.h> extern TaskObject cuda_task_list[MAX_TASK_OBJECT]; class CudaScheduler : public MainScheduler { public: typedef struct cudabuffer { int allcate_size; int in_size; int out_size; CUdeviceptr* memin; CUdeviceptr* memout; CUevent* event; CUstream stream; } CudaBuffer, *CudaBufferPtr; CudaScheduler(); virtual ~CudaScheduler(); void init_gpu(); void wait_for_event(CUevent* event, CudaBufferPtr m, TaskListPtr taskList, int cur); void run(); // platform platform; // platform は OpenCL が複数のメーカーの GPU に対応してるから必要 // Cuda の場合、NVIDIA だけなので必要ない? CUdevice device; unsigned int ret_num_platforms; // たぶん要らない int ret_num_devices; CUcontext context; // command_queue command_queue; // Cuda には command_queue に相当するものはない // Closest approximation would be the CUDA Stream mechanism. らしい... int ret; memaddr reply; // cl_kernel に相当 // 変数名は function にすべきか kernel にすべきか // とりあえず、kernel で CUfunction kernel[2]; CUevent kernel_event[2]; CudaBuffer* cudabuffer; HTask::htask_flag flag[2]; private: int load_kernel(int cmd); CUdeviceptr createBuffer(CudaBufferPtr cudabuffer, CUdeviceptr* mem, int i, size_t size, int* error); void initCudaBuffer(CudaBufferPtr m); void destroyCudaBuffer(CudaBufferPtr m); void CudaTaskError(CudaBufferPtr cudabuffer, int cur, TaskListPtr taskList, int ret); }; #define CudaSchedRegister(str, filename, functionname) \ cuda_register_task(str, filename, functionname); #endif extern void cuda_register_task(int cmd, const char* filename, const char* functionname);