annotate TaskManager/Gpu/GpuScheduler.h @ 1555:096412ad80fb draft

add opencl example
author Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
date Mon, 04 Mar 2013 20:20:58 +0900
parents 68200bc3ab6b
children e8c9a7099bcc
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
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "Scheduler.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"
1434
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #ifdef __APPLE__
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #include <OpenCL/opencl.h>
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 #else
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 #include <CL/cl.h>
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 #endif
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
1555
096412ad80fb add opencl example
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1549
diff changeset
15 typedef struct nd_range {
096412ad80fb add opencl example
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1549
diff changeset
16 cl_uint dimension;
096412ad80fb add opencl example
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1549
diff changeset
17 size_t gws[3];
096412ad80fb add opencl example
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1549
diff changeset
18 size_t lws[3];
096412ad80fb add opencl example
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1549
diff changeset
19 } ND_RANGE_T, *ND_RANGE_T_PTR;
096412ad80fb add opencl example
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1549
diff changeset
20
1434
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 class GpuScheduler : public Scheduler {
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 public:
1471
e8db2e2d426c fix not working yet.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1447
diff changeset
23 GpuScheduler();
1506
a7895ab4d0e3 add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1486
diff changeset
24 virtual ~GpuScheduler();
1434
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 void init_impl(int useRefDma);
1480
f2512fb94223 GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1478
diff changeset
26 void init_gpu();
1447
e8ff87511f46 debug GpuThreads
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1438
diff changeset
27 void run();
1508
0e1318e7caed create sort test
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1506
diff changeset
28
1447
e8ff87511f46 debug GpuThreads
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1438
diff changeset
29 void mail_write_from_host(memaddr data) {
1482
85a848d7f181 fix CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1480
diff changeset
30 fifoDmaManager->mail_write_from_host(data);
1447
e8ff87511f46 debug GpuThreads
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1438
diff changeset
31 }
e8ff87511f46 debug GpuThreads
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1438
diff changeset
32
e8ff87511f46 debug GpuThreads
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1438
diff changeset
33 memaddr mail_read_from_host() {
1508
0e1318e7caed create sort test
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1506
diff changeset
34 return fifoDmaManager->mail_read_from_host();
1447
e8ff87511f46 debug GpuThreads
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1438
diff changeset
35 }
e8ff87511f46 debug GpuThreads
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1438
diff changeset
36
e8ff87511f46 debug GpuThreads
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1438
diff changeset
37 int has_mail_from_host() {
1508
0e1318e7caed create sort test
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1506
diff changeset
38 return fifoDmaManager->has_mail_from_host();
1447
e8ff87511f46 debug GpuThreads
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1438
diff changeset
39 }
1434
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
1480
f2512fb94223 GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1478
diff changeset
41 cl_platform_id platform_id;
f2512fb94223 GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1478
diff changeset
42 cl_device_id device_id;
f2512fb94223 GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1478
diff changeset
43 cl_uint ret_num_platforms;
f2512fb94223 GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1478
diff changeset
44 cl_uint ret_num_devices;
f2512fb94223 GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1478
diff changeset
45 cl_context context;
1549
68200bc3ab6b change clfinish to wait for event
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1530
diff changeset
46 cl_command_queue command_queue;
1480
f2512fb94223 GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1478
diff changeset
47 cl_int ret;
1434
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 private:
1447
e8ff87511f46 debug GpuThreads
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1438
diff changeset
49 FifoDmaManager *fifoDmaManager;
1486
756aa0f08814 gpu task loader
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1485
diff changeset
50 void load_kernel(int cmd);
1480
f2512fb94223 GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1478
diff changeset
51
1434
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 };
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53
1513
18b63e697c61 many_task/quick_sort is changed recursive to loop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1508
diff changeset
54 #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
55 gpu_register_task(str, filename, functionname);
1434
05d480ab70ba add GpuScheduler
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 #endif
1435
9f6ba00ca15c add gpu_sched_register
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1434
diff changeset
57
1513
18b63e697c61 many_task/quick_sort is changed recursive to loop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1508
diff changeset
58 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
59