Mercurial > hg > Game > Cerium
annotate TaskManager/Gpu/GpuScheduler.h @ 2029:c8e35ceae52b draft
couldn't run on linux without unistd.h
author | Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 16 Nov 2014 18:00:06 +0900 |
parents | 4cf85b48ab9e |
children |
rev | line source |
---|---|
1434 | 1 #ifndef INCLUDED_GPU_SCHEDULER |
2 #define INCLUDED_GPU_SCHEDULER | |
3 | |
1888 | 4 #include "MainScheduler.h" |
1447 | 5 #include "FifoDmaManager.h" |
1480
f2512fb94223
GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1478
diff
changeset
|
6 #include "GpuThreads.h" |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1486
diff
changeset
|
7 #include "HTask.h" |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1555
diff
changeset
|
8 #include "TaskManager.h" |
1434 | 9 |
10 #ifdef __APPLE__ | |
11 #include <OpenCL/opencl.h> | |
12 #else | |
2029
c8e35ceae52b
couldn't run on linux without unistd.h
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1975
diff
changeset
|
13 #include <unistd.h> |
1434 | 14 #include <CL/cl.h> |
15 #endif | |
16 | |
1631 | 17 extern TaskObject gpu_task_list[MAX_TASK_OBJECT]; |
18 | |
1975
4cf85b48ab9e
running fft with CudaScheduler, but wrong result
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1971
diff
changeset
|
19 #define STAGE 8 |
1960
273de551f726
use multiple command_queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1888
diff
changeset
|
20 |
1888 | 21 class GpuScheduler : public MainScheduler { |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1555
diff
changeset
|
22 public: |
1804 | 23 typedef struct gpubuffer { |
24 cl_int allocate_size; | |
25 cl_int size; | |
26 cl_mem *buf; // clCreateBuffer | |
27 cl_event *event; | |
28 } GpuBuffer, *GpuBufferPtr; | |
1471 | 29 GpuScheduler(); |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1486
diff
changeset
|
30 virtual ~GpuScheduler(); |
1480
f2512fb94223
GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1478
diff
changeset
|
31 void init_gpu(); |
1832
be9076dc8d49
1-cur in GpuScheduler
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1829
diff
changeset
|
32 void wait_for_event(cl_event* event,GpuBufferPtr m, TaskListPtr taskList,int cur); |
1447 | 33 void run(); |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1555
diff
changeset
|
34 |
1480
f2512fb94223
GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1478
diff
changeset
|
35 cl_platform_id platform_id; |
f2512fb94223
GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1478
diff
changeset
|
36 cl_device_id device_id; |
f2512fb94223
GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1478
diff
changeset
|
37 cl_uint ret_num_platforms; |
f2512fb94223
GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1478
diff
changeset
|
38 cl_uint ret_num_devices; |
f2512fb94223
GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1478
diff
changeset
|
39 cl_context context; |
1960
273de551f726
use multiple command_queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1888
diff
changeset
|
40 cl_command_queue command_queue[STAGE]; |
1480
f2512fb94223
GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1478
diff
changeset
|
41 cl_int ret; |
1829
45d4ed567cd7
fix GpuScheduler
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1812
diff
changeset
|
42 memaddr reply; |
1960
273de551f726
use multiple command_queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1888
diff
changeset
|
43 cl_kernel kernel[STAGE]; |
273de551f726
use multiple command_queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1888
diff
changeset
|
44 cl_event kernel_event[STAGE]; |
273de551f726
use multiple command_queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1888
diff
changeset
|
45 GpuBuffer memin[STAGE]; |
273de551f726
use multiple command_queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1888
diff
changeset
|
46 GpuBuffer memout[STAGE]; |
273de551f726
use multiple command_queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1888
diff
changeset
|
47 HTask::htask_flag flag[STAGE]; |
1434 | 48 private: |
1769 | 49 int load_kernel(int cmd); |
1812 | 50 cl_mem createBuffer(GpuBufferPtr m, int i, cl_context context, cl_mem_flags flags, size_t size, cl_int *error); |
51 void initGpuBuffer(GpuBufferPtr m); | |
52 void destroyGpuBuffer(GpuBufferPtr m); | |
1829
45d4ed567cd7
fix GpuScheduler
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1812
diff
changeset
|
53 void gpuTaskError(int cur, TaskListPtr tasklist, int ret); |
1434 | 54 }; |
55 | |
1513
18b63e697c61
many_task/quick_sort is changed recursive to loop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1508
diff
changeset
|
56 #define GpuSchedRegister(str, filename, functionname) \ |
18b63e697c61
many_task/quick_sort is changed recursive to loop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1508
diff
changeset
|
57 gpu_register_task(str, filename, functionname); |
1434 | 58 #endif |
1435
9f6ba00ca15c
add gpu_sched_register
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1434
diff
changeset
|
59 |
1513
18b63e697c61
many_task/quick_sort is changed recursive to loop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1508
diff
changeset
|
60 extern void gpu_register_task(int cmd,const char* filename,const char* functionname); |
1515
b3644b73d2cf
add flip flag test
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1513
diff
changeset
|
61 |