Mercurial > hg > Game > Cerium
annotate TaskManager/kernel/ppe/TaskManagerImpl.h @ 1546:61164c687b29 draft
fix GpuScheduler flip
author | Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 05 Feb 2013 13:15:46 +0900 |
parents | 890cb39418ca |
children | e8c9a7099bcc |
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" |
619 | 11 class MemList; |
475
4e0308d2ba73
BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
12 |
955 | 13 extern QueueInfo<TaskQueue> *taskQueuePool ; |
14 extern QueueInfo<HTask> *htaskPool ; | |
1428
af2adce9752e
add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1424
diff
changeset
|
15 extern QueueInfo<TaskList> *taskListPool; |
af2adce9752e
add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1424
diff
changeset
|
16 extern QueueInfo<TaskLog> *taskLogQueue; |
955 | 17 |
18 | |
54 | 19 |
3 | 20 class TaskManagerImpl { |
21 public: | |
22 | |
23 /* variables */ | |
24 int machineNum; | |
955 | 25 QueueInfo<HTask> *activeTaskQueue; |
26 QueueInfo<HTask> *waitTaskQueue; | |
475
4e0308d2ba73
BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
27 |
955 | 28 QueueInfo<TaskQueue> *taskQueueImpl; |
29 QueueInfo<HTask> *htaskImpl; | |
619 | 30 |
546 | 31 SchedTask *schedTaskManager; |
637 | 32 Scheduler *scheduler; |
833
577bde5d0cec
poling (may recurse..)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
830
diff
changeset
|
33 TaskManagerImpl *others; |
1479
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1468
diff
changeset
|
34 int _export_task_log; |
3 | 35 |
480
75e4afa40da2
TaskQueueInfo initiaization...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
479
diff
changeset
|
36 /* constructor */ |
1149 | 37 TaskManagerImpl(int num = 0) ; |
480
75e4afa40da2
TaskQueueInfo initiaization...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
479
diff
changeset
|
38 |
75e4afa40da2
TaskQueueInfo initiaization...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
479
diff
changeset
|
39 virtual ~TaskManagerImpl() { } |
75e4afa40da2
TaskQueueInfo initiaization...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
479
diff
changeset
|
40 |
3 | 41 /* functions */ |
109 | 42 // system |
1479
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1468
diff
changeset
|
43 virtual void init(int,int,int) = 0; |
480
75e4afa40da2
TaskQueueInfo initiaization...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
479
diff
changeset
|
44 virtual void run() = 0; |
672 | 45 virtual void start_profile() = 0; |
46 virtual void show_profile() = 0; | |
1452 | 47 virtual void export_task_log(){} |
498
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
496
diff
changeset
|
48 virtual void append_activeTask(HTaskPtr); |
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
496
diff
changeset
|
49 virtual void append_waitTask(HTaskPtr); |
833
577bde5d0cec
poling (may recurse..)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
830
diff
changeset
|
50 virtual void polling() = 0; |
1067 | 51 virtual void print_arch() = 0; |
109 | 52 |
955 | 53 void check_task_finish(HTaskPtr task, QueueInfo<HTask> *wait_queue); |
54 void check_task_list_finish(SchedTask *s, TaskListPtr list, QueueInfo<HTask> *wait_queue); | |
109 | 55 |
480
75e4afa40da2
TaskQueueInfo initiaization...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
479
diff
changeset
|
56 void systask_init(); |
109 | 57 |
58 // user | |
897
6bd218d3f643
add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
59 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
|
60 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
|
61 virtual HTaskPtr create_task_array(int id, int num_task, int num_param, int num_inData, int num_outData,void *from); |
1465 | 62 virtual TaskListPtr createTaskList() = 0; |
1436
42057124fb44
change to Singleton Pattern
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
63 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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 const char *get_task_name(HTaskPtr htask, int index); |
637 | 69 virtual void set_task_depend(HTaskPtr master, HTaskPtr slave); |
70 virtual void spawn_task(HTaskPtr); | |
71 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
|
72 void set_taskList(HTaskPtr htask, QueueInfo<TaskList> * taskList); |
619 | 73 |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
74 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
|
75 #if !defined(__SPU__) |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
76 if (htask->self) { |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
77 htask->flag.no_auto_free = 0; |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
78 return; |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
79 } |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
80 htaskImpl->free_(htask); |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
81 #endif |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
82 } |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
899
diff
changeset
|
83 |
637 | 84 void* allocate(int size, int alignment) |
85 { | |
1169 | 86 |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
87 void *buff = 0; |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
88 if (size==0) return 0; |
666 | 89 #if defined(__SPU__) || ! defined(HAS_POSIX_MEMALIGN) |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
90 buff = malloc(size); |
666 | 91 #else |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
92 posix_memalign(&buff, alignment, size); |
666 | 93 #endif |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
94 if (buff==0) |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
95 get_scheduler()->printf("Can't allocate memory\n"); |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
96 return buff; |
637 | 97 } |
98 | |
99 void* allocate(int size) | |
100 { | |
1169 | 101 |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
102 void *buff = 0; |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
103 if (size==0) return 0; |
666 | 104 #if defined(__SPU__) || ! defined(HAS_POSIX_MEMALIGN) |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
105 buff = malloc(size); |
666 | 106 #else |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
107 posix_memalign(&buff, DEFAULT_ALIGNMENT, size); |
666 | 108 #endif |
736 | 109 if (buff==0) |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
110 get_scheduler()->printf("Can't allocate memory\n"); |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
111 return buff; |
637 | 112 } |
113 | |
114 Scheduler* get_scheduler() { return scheduler; } | |
115 void set_scheduler(Scheduler *s) { scheduler = s; } | |
895
b662e9dd26b0
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
835
diff
changeset
|
116 } __attribute__ ((aligned (DEFAULT_ALIGNMENT))); |
1543 | 117 extern void error(const char* error_message); |
3 | 118 #endif |