Mercurial > hg > Game > Cerium
annotate TaskManager/Cuda/CudaScheduler.h @ 1935:67e50779feb4 draft
CudaScheduler is runnig.
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 02 Feb 2014 18:33:54 +0900 |
parents | 4eefec26e3e2 |
children | 6988e5478a8c |
rev | line source |
---|---|
1908 | 1 #ifndef INCLUDE_CUDA_SCHEDULER |
2 #define INCLUDE_CUDA_SCHEDULER | |
3 | |
4 #include "MainScheduler.h" | |
5 #include "FifoDmaManager.h" | |
6 #include "CudaThreads.h" | |
7 #include "HTask.h" | |
8 #include "TaskManager.h" | |
1915
effb5653fd5c
update cuda, yet running
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1908
diff
changeset
|
9 #include <cuda.h> |
1908 | 10 |
11 extern TaskObject cuda_task_list[MAX_TASK_OBJECT]; | |
12 | |
1935
67e50779feb4
CudaScheduler is runnig.
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1927
diff
changeset
|
13 #define STAGE 8 |
67e50779feb4
CudaScheduler is runnig.
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1927
diff
changeset
|
14 |
1908 | 15 class CudaScheduler : public MainScheduler { |
16 public: | |
17 typedef struct cudabuffer { | |
18 int allcate_size; | |
1924 | 19 int in_size; |
20 int out_size; | |
21 CUdeviceptr* memin; | |
22 CUdeviceptr* memout; | |
1908 | 23 CUevent* event; |
1924 | 24 CUstream stream; |
25 } CudaBuffer, *CudaBufferPtr; | |
1908 | 26 CudaScheduler(); |
27 virtual ~CudaScheduler(); | |
28 void init_gpu(); | |
29 void wait_for_event(CUevent* event, CudaBufferPtr m, TaskListPtr taskList, int cur); | |
30 void run(); | |
1924 | 31 |
1908 | 32 // platform platform; |
33 // platform は OpenCL が複数のメーカーの GPU に対応してるから必要 | |
34 // Cuda の場合、NVIDIA だけなので必要ない? | |
35 CUdevice device; | |
36 unsigned int ret_num_platforms; // たぶん要らない | |
1925
cd5bbd8ec5d6
fix CudaScheduler
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1924
diff
changeset
|
37 int ret_num_devices; |
1908 | 38 CUcontext context; |
39 // command_queue command_queue; | |
40 // Cuda には command_queue に相当するものはない | |
41 // Closest approximation would be the CUDA Stream mechanism. らしい... | |
42 int ret; | |
43 memaddr reply; | |
44 // cl_kernel に相当 | |
45 // 変数名は function にすべきか kernel にすべきか | |
46 // とりあえず、kernel で | |
1935
67e50779feb4
CudaScheduler is runnig.
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1927
diff
changeset
|
47 CUfunction kernel[STAGE]; |
67e50779feb4
CudaScheduler is runnig.
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1927
diff
changeset
|
48 CUevent kernel_event[STAGE]; |
67e50779feb4
CudaScheduler is runnig.
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1927
diff
changeset
|
49 CudaBuffer cudabuffer[STAGE]; |
67e50779feb4
CudaScheduler is runnig.
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1927
diff
changeset
|
50 |
67e50779feb4
CudaScheduler is runnig.
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1927
diff
changeset
|
51 HTask::htask_flag flag[STAGE]; |
1908 | 52 |
1925
cd5bbd8ec5d6
fix CudaScheduler
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1924
diff
changeset
|
53 private: |
1908 | 54 int load_kernel(int cmd); |
1935
67e50779feb4
CudaScheduler is runnig.
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1927
diff
changeset
|
55 void createBuffer(CudaBufferPtr cudabuffer, CUdeviceptr* mem, int i, size_t size); |
1908 | 56 void initCudaBuffer(CudaBufferPtr m); |
57 void destroyCudaBuffer(CudaBufferPtr m); | |
1925
cd5bbd8ec5d6
fix CudaScheduler
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1924
diff
changeset
|
58 void CudaTaskError(CudaBufferPtr cudabuffer, int cur, TaskListPtr taskList, int ret); |
1908 | 59 }; |
60 | |
61 #define CudaSchedRegister(str, filename, functionname) \ | |
62 cuda_register_task(str, filename, functionname); | |
63 #endif | |
1927 | 64 |
65 extern void cuda_register_task(int cmd, const char* filename, const char* functionname); |