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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
1 #ifndef INCLUDED_TASK_MANAGER_IMPL
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
2 #define INCLUDED_TASK_MANAGER_IMPL
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
3
307
3fc86ddf5d1c clean up include
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
4 #include "MailManager.h"
3fc86ddf5d1c clean up include
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
5 #include "ListData.h"
955
6ffeb543e8d4 unify all QueueInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 941
diff changeset
6 #include "QueueInfo.h"
6ffeb543e8d4 unify all QueueInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 941
diff changeset
7 #include "TaskQueue.h"
6ffeb543e8d4 unify all QueueInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 941
diff changeset
8 #include "HTask.h"
736
1b225972ae88 cut printf
hiroki@localhost.localdomain
parents: 719
diff changeset
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
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
11 class MemList;
475
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
12
955
6ffeb543e8d4 unify all QueueInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 941
diff changeset
13 extern QueueInfo<TaskQueue> *taskQueuePool ;
6ffeb543e8d4 unify all QueueInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 941
diff changeset
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
6ffeb543e8d4 unify all QueueInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 941
diff changeset
17
6ffeb543e8d4 unify all QueueInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 941
diff changeset
18
54
90523ccc4dff *** empty log message ***
gongo
parents: 50
diff changeset
19
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
20 class TaskManagerImpl {
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
21 public:
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
22
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
23 /* variables */
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
24 int machineNum;
955
6ffeb543e8d4 unify all QueueInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 941
diff changeset
25 QueueInfo<HTask> *activeTaskQueue;
6ffeb543e8d4 unify all QueueInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 941
diff changeset
26 QueueInfo<HTask> *waitTaskQueue;
475
4e0308d2ba73 BufferManager removed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 373
diff changeset
27
955
6ffeb543e8d4 unify all QueueInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 941
diff changeset
28 QueueInfo<TaskQueue> *taskQueueImpl;
6ffeb543e8d4 unify all QueueInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 941
diff changeset
29 QueueInfo<HTask> *htaskImpl;
619
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
30
546
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
31 SchedTask *schedTaskManager;
637
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 636
diff changeset
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
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
35
480
75e4afa40da2 TaskQueueInfo initiaization...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 479
diff changeset
36 /* constructor */
1149
bccd192a43b2 Cell fix
yutaka@localhost.localdomain
parents: 1147
diff changeset
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
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
41 /* functions */
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
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
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 666
diff changeset
45 virtual void start_profile() = 0;
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 666
diff changeset
46 virtual void show_profile() = 0;
1452
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1451
diff changeset
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
5ad8fb1dc70f print_arch add.
tkaito
parents: 1063
diff changeset
51 virtual void print_arch() = 0;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
52
955
6ffeb543e8d4 unify all QueueInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 941
diff changeset
53 void check_task_finish(HTaskPtr task, QueueInfo<HTask> *wait_queue);
6ffeb543e8d4 unify all QueueInfo
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 941
diff changeset
54 void check_task_list_finish(SchedTask *s, TaskListPtr list, QueueInfo<HTask> *wait_queue);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
55
480
75e4afa40da2 TaskQueueInfo initiaization...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 479
diff changeset
56 void systask_init();
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
57
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
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
fc5b23108608 TaskList on going...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1427
diff changeset
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
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 636
diff changeset
69 virtual void set_task_depend(HTaskPtr master, HTaskPtr slave);
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 636
diff changeset
70 virtual void spawn_task(HTaskPtr);
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 636
diff changeset
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
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
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
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 636
diff changeset
84 void* allocate(int size, int alignment)
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 636
diff changeset
85 {
1169
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1149
diff changeset
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
f02b3338b91b simplify word_count
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 647
diff changeset
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
f02b3338b91b simplify word_count
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 647
diff changeset
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
f02b3338b91b simplify word_count
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 647
diff changeset
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
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 636
diff changeset
97 }
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 636
diff changeset
98
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 636
diff changeset
99 void* allocate(int size)
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 636
diff changeset
100 {
1169
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1149
diff changeset
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
f02b3338b91b simplify word_count
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 647
diff changeset
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
f02b3338b91b simplify word_count
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 647
diff changeset
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
f02b3338b91b simplify word_count
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 647
diff changeset
108 #endif
736
1b225972ae88 cut printf
hiroki@localhost.localdomain
parents: 719
diff changeset
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
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 636
diff changeset
112 }
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 636
diff changeset
113
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 636
diff changeset
114 Scheduler* get_scheduler() { return scheduler; }
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 636
diff changeset
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
890cb39418ca add error routine
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
117 extern void error(const char* error_message);
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
118 #endif