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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1434
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #ifndef INCLUDED_GPU_SCHEDULER
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #define INCLUDED_GPU_SCHEDULER
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
1888
5238ca826d6e clean up DMA
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1841
diff changeset
4 #include "MainScheduler.h"
1447
e8ff87511f46 debug GpuThreads
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1438
diff changeset
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
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #ifdef __APPLE__
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 #include <OpenCL/opencl.h>
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 #include <CL/cl.h>
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 #endif
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
1631
39a381fec1e7 cpu, gpu coexistence
shohei kokubo
parents: 1615
diff changeset
17 extern TaskObject gpu_task_list[MAX_TASK_OBJECT];
39a381fec1e7 cpu, gpu coexistence
shohei kokubo
parents: 1615
diff changeset
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
5238ca826d6e clean up DMA
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1841
diff changeset
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
1febe61a935a create GpuBuffer
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1803
diff changeset
23 typedef struct gpubuffer {
1febe61a935a create GpuBuffer
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1803
diff changeset
24 cl_int allocate_size;
1febe61a935a create GpuBuffer
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1803
diff changeset
25 cl_int size;
1febe61a935a create GpuBuffer
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1803
diff changeset
26 cl_mem *buf; // clCreateBuffer
1febe61a935a create GpuBuffer
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1803
diff changeset
27 cl_event *event;
1febe61a935a create GpuBuffer
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1803
diff changeset
28 } GpuBuffer, *GpuBufferPtr;
1471
e8db2e2d426c fix not working yet.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1447
diff changeset
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
e8ff87511f46 debug GpuThreads
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1438
diff changeset
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
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 private:
1769
4baed436fc58 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1633
diff changeset
49 int load_kernel(int cmd);
1812
df5fc3a6d318 Release mem object in GPU
YuhiTOMARI
parents: 1811
diff changeset
50 cl_mem createBuffer(GpuBufferPtr m, int i, cl_context context, cl_mem_flags flags, size_t size, cl_int *error);
df5fc3a6d318 Release mem object in GPU
YuhiTOMARI
parents: 1811
diff changeset
51 void initGpuBuffer(GpuBufferPtr m);
df5fc3a6d318 Release mem object in GPU
YuhiTOMARI
parents: 1811
diff changeset
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
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 };
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
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