Mercurial > hg > Game > Cerium
annotate TaskManager/kernel/ppe/TaskManagerImpl.h @ 2054:2e7a6f40672f draft
add param(4) in FileMapReduce.cc
author | masa |
---|---|
date | Fri, 29 Jan 2016 15:56:28 +0900 |
parents | dae9dc8d1d8f |
children |
rev | line source |
---|---|
3 | 1 #ifndef INCLUDED_TASK_MANAGER_IMPL |
2 #define INCLUDED_TASK_MANAGER_IMPL | |
3 | |
307 | 4 #include "MailManager.h" |
5 #include "ListData.h" | |
955 | 6 #include "QueueInfo.h" |
7 #include "TaskQueue.h" | |
8 #include "HTask.h" | |
736 | 9 #include "Scheduler.h" |
1423
515a0f15b5d2
add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1229
diff
changeset
|
10 #include "TaskLog.h" |
2032
dae9dc8d1d8f
Fix Makefile in linux
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1989
diff
changeset
|
11 #ifdef __APPLE__ |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
12 #include <OpenCL/opencl.h> |
2032
dae9dc8d1d8f
Fix Makefile in linux
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1989
diff
changeset
|
13 #endif |
619 | 14 class MemList; |
475
4e0308d2ba73
BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
15 |
955 | 16 extern QueueInfo<TaskQueue> *taskQueuePool ; |
17 extern QueueInfo<HTask> *htaskPool ; | |
1428
af2adce9752e
add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1424
diff
changeset
|
18 extern QueueInfo<TaskList> *taskListPool; |
af2adce9752e
add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1424
diff
changeset
|
19 extern QueueInfo<TaskLog> *taskLogQueue; |
955 | 20 |
3 | 21 class TaskManagerImpl { |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
22 public: |
3 | 23 |
24 /* variables */ | |
25 int machineNum; | |
955 | 26 QueueInfo<HTask> *activeTaskQueue; |
27 QueueInfo<HTask> *waitTaskQueue; | |
475
4e0308d2ba73
BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
28 |
955 | 29 QueueInfo<TaskQueue> *taskQueueImpl; |
30 QueueInfo<HTask> *htaskImpl; | |
619 | 31 |
546 | 32 SchedTask *schedTaskManager; |
637 | 33 Scheduler *scheduler; |
833
577bde5d0cec
poling (may recurse..)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
830
diff
changeset
|
34 TaskManagerImpl *others; |
1989 | 35 TaskLog* tasklog; |
1479
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1468
diff
changeset
|
36 int _export_task_log; |
1605
5b99bcc6bdb0
fix mail_check and init dim_count and init _export_task_log.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1588
diff
changeset
|
37 |
1989 | 38 |
480
75e4afa40da2
TaskQueueInfo initiaization...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
479
diff
changeset
|
39 /* constructor */ |
1605
5b99bcc6bdb0
fix mail_check and init dim_count and init _export_task_log.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1588
diff
changeset
|
40 TaskManagerImpl(int num = 0); |
5b99bcc6bdb0
fix mail_check and init dim_count and init _export_task_log.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1588
diff
changeset
|
41 |
480
75e4afa40da2
TaskQueueInfo initiaization...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
479
diff
changeset
|
42 virtual ~TaskManagerImpl() { } |
1605
5b99bcc6bdb0
fix mail_check and init dim_count and init _export_task_log.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1588
diff
changeset
|
43 |
3 | 44 /* functions */ |
109 | 45 // system |
1479
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1468
diff
changeset
|
46 virtual void init(int,int,int) = 0; |
480
75e4afa40da2
TaskQueueInfo initiaization...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
479
diff
changeset
|
47 virtual void run() = 0; |
672 | 48 virtual void start_profile() = 0; |
49 virtual void show_profile() = 0; | |
1452 | 50 virtual void export_task_log(){} |
498
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
496
diff
changeset
|
51 virtual void append_activeTask(HTaskPtr); |
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
496
diff
changeset
|
52 virtual void append_waitTask(HTaskPtr); |
833
577bde5d0cec
poling (may recurse..)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
830
diff
changeset
|
53 virtual void polling() = 0; |
1067 | 54 virtual void print_arch() = 0; |
1614
93569219173e
remove set_NDRange
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1605
diff
changeset
|
55 |
955 | 56 void check_task_finish(HTaskPtr task, QueueInfo<HTask> *wait_queue); |
57 void check_task_list_finish(SchedTask *s, TaskListPtr list, QueueInfo<HTask> *wait_queue); | |
109 | 58 |
480
75e4afa40da2
TaskQueueInfo initiaization...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
479
diff
changeset
|
59 void systask_init(); |
109 | 60 |
61 // user | |
897
6bd218d3f643
add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
62 virtual HTaskPtr create_task(int cmd,void *from); |
6bd218d3f643
add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
63 virtual HTaskPtr create_task(int cmd, memaddr rbuf, long r_size, memaddr wbuf, long w_size,void *from); |
6bd218d3f643
add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
64 virtual HTaskPtr create_task_array(int id, int num_task, int num_param, int num_inData, int num_outData,void *from); |
1465 | 65 virtual TaskListPtr createTaskList() = 0; |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
66 |
1436
42057124fb44
change to Singleton Pattern
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
67 const char *get_task_name(int cmd); |
42057124fb44
change to Singleton Pattern
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
68 const char *get_task_name(TaskPtr task); |
42057124fb44
change to Singleton Pattern
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
69 const char *get_task_name(SimpleTaskPtr simpletask); |
42057124fb44
change to Singleton Pattern
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
70 const char *get_task_name(SchedTaskBase *schedtask); |
42057124fb44
change to Singleton Pattern
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
71 const char *get_task_name(HTaskPtr htask); |
42057124fb44
change to Singleton Pattern
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
72 const char *get_task_name(HTaskPtr htask, int index); |
637 | 73 virtual void set_task_depend(HTaskPtr master, HTaskPtr slave); |
74 virtual void spawn_task(HTaskPtr); | |
75 virtual void set_task_cpu(HTaskPtr, CPU_TYPE); | |
1062
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
1057
diff
changeset
|
76 void set_taskList(HTaskPtr htask, QueueInfo<TaskList> * taskList); |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
77 |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
78 void free_htask(HTaskPtr htask) { |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
79 #if !defined(__SPU__) |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
80 if (htask->self) { |
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
81 htask->flag.no_auto_free = 0; |
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
82 return; |
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
83 } |
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
84 htaskImpl->free_(htask); |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
85 #endif |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
86 } |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
87 |
1940
0f6d0ae5c3f3
change manager->allocate size long long to long
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1937
diff
changeset
|
88 void* allocate(long size, int alignment) |
637 | 89 { |
1169 | 90 |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
91 void *buff = 0; |
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
92 if (size==0) return 0; |
666 | 93 #if defined(__SPU__) || ! defined(HAS_POSIX_MEMALIGN) |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
94 buff = malloc(size); |
666 | 95 #else |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
96 posix_memalign(&buff, alignment, size); |
666 | 97 #endif |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
98 if (buff==0) |
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
99 get_scheduler()->printf("Can't allocate memory\n"); |
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
100 return buff; |
637 | 101 } |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
102 |
1940
0f6d0ae5c3f3
change manager->allocate size long long to long
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1937
diff
changeset
|
103 void* allocate(long size) |
637 | 104 { |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
105 |
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
106 void *buff = 0; |
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
107 if (size==0) return 0; |
666 | 108 #if defined(__SPU__) || ! defined(HAS_POSIX_MEMALIGN) |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
109 buff = malloc(size); |
666 | 110 #else |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
111 posix_memalign(&buff, DEFAULT_ALIGNMENT, size); |
666 | 112 #endif |
736 | 113 if (buff==0) |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
114 get_scheduler()->printf("Can't allocate memory\n"); |
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
115 return buff; |
637 | 116 } |
117 | |
118 Scheduler* get_scheduler() { return scheduler; } | |
119 void set_scheduler(Scheduler *s) { scheduler = s; } | |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
120 |
895
b662e9dd26b0
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
835
diff
changeset
|
121 } __attribute__ ((aligned (DEFAULT_ALIGNMENT))); |
1543 | 122 extern void error(const char* error_message); |
3 | 123 #endif |