Mercurial > hg > Game > Cerium
view TaskManager/Cuda/CudaScheduler.h @ 2022:fac44ad2867d draft
make a sound
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 16 Jul 2014 02:50:32 +0900 |
parents | 6bf6450bd45a |
children |
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> #include <map> extern TaskObject cuda_task_list[MAX_TASK_OBJECT]; using namespace std; #define STAGE 8 class CudaScheduler : public MainScheduler { public: typedef struct cudabuffer { int allcate_size; int in_size; int out_size; CUdeviceptr* memin; CUdeviceptr* memout; CUstream stream; void** kernelParams; } CudaBuffer, *CudaBufferPtr; CudaScheduler(); virtual ~CudaScheduler(); void init_gpu(); void wait_for_event(CudaBufferPtr m, TaskListPtr taskList, int cur); void run(); // platform platform; // platform は OpenCL が複数のメーカーの GPU に対応してるから必要 // Cuda の場合、NVIDIA だけなので必要ない? CUdevice device; 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 に相当 CUfunction kernel[STAGE]; CudaBuffer cudabuffer[STAGE]; // record transmitted data. map<memaddr, CUdeviceptr*> transmitted; map<CUdeviceptr*, memaddr> reverse_map; HTask::htask_flag flag[STAGE]; private: int load_kernel(int cmd); void createBuffer(CudaBufferPtr cudabuffer, CUdeviceptr* mem, int i, size_t size); void initCudaBuffer(CudaBufferPtr m); void destroyCudaBuffer(CudaBufferPtr m); void CudaTaskError(CudaBufferPtr cudabuffer, int cur, TaskListPtr taskList, int ret); int read(TaskPtr nextTask, TaskListPtr tasklist); void exec(TaskListPtr tasklist, int cur); TaskPtr write(TaskPtr nextTask, TaskListPtr tasklist); }; #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);