annotate TaskManager/Cell/CellTaskManagerImpl.cc @ 1624:c0482a63d811 draft

fix
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Tue, 28 May 2013 17:57:33 +0900
parents 93569219173e
children 4fed76f4d101
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
1 #define DEBUG
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
2 #include "error.h"
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
3 #include <stdio.h>
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
4 #include <stdlib.h>
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
5 #include <string.h>
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
6 #include "CellTaskManagerImpl.h"
956
197b7e19a345 unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 940
diff changeset
7 #include "HTask.h"
197b7e19a345 unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 940
diff changeset
8 #include "QueueInfo.h"
1428
af2adce9752e add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1362
diff changeset
9 #include "ExportTaskLog.h"
621
64e05530e333 Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 620
diff changeset
10 #include "SchedTask.h"
635
c56f6847fb87 SimpleTask worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 631
diff changeset
11 #include "MainScheduler.h"
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
12 #include "types.h"
672
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
13 #include "SysFunc.h"
1490
5517f93e2706 CellTaskManager call CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1482
diff changeset
14 #ifdef __CERIUM_GPU__
5517f93e2706 CellTaskManager call CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1482
diff changeset
15 #include "GpuThreads.h"
5517f93e2706 CellTaskManager call CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1482
diff changeset
16 #endif
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
17 static void send_alloc_reply(CellTaskManagerImpl *tm, int id,
1606
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1605
diff changeset
18 Threads *speThreads);
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
19
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
20 CellTaskManagerImpl::~CellTaskManagerImpl() {
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
21 delete speThreads;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
22 delete[] speTaskList;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
23 delete ppeManager;
67
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
24 }
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
25
1479
163220e54cc0 remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1477
diff changeset
26 void CellTaskManagerImpl::init(int spuIdle_,int useRefDma,int export_task_log) {
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
27 spe_running = 0;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
28 spuIdle = spuIdle_;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
29
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
30 // 実行される Task 用の パイプライン用のダブルバッファ
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
31 speTaskList = new QueueInfo<TaskList>*[machineNum]; // spe上の走っている Task の配列
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
32 taskListInfo = new QueueInfo<TaskList>*[machineNum]; // 次に走る Task の配列
476
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
33
1077
325b6c6d7d65 use one activeTaskQueue
yutaka@localhost.localdomain
parents: 1070
diff changeset
34
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
35 for (int i = 0; i < machineNum; i++) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
36 taskListInfo[i] = new QueueInfo<TaskList> (taskListPool);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
37 speTaskList[i] = new QueueInfo<TaskList> (taskListPool);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
38 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
39
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
40 // PPE 側の管理をする Manager
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
41 ppeManager = new FifoTaskManagerImpl(machineNum);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
42 // 大半のTaskQueueInfoは、共有される
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
43 MainScheduler *mscheduler = new MainScheduler;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
44 set_scheduler(mscheduler);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
45 ppeManager->init(mscheduler, this, useRefDma); // ここで HTaskInfo が共有される。
1077
325b6c6d7d65 use one activeTaskQueue
yutaka@localhost.localdomain
parents: 1070
diff changeset
46
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
47 speThreads->init();
1362
6b4a0846afcb Spe Threads Init moved
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1229
diff changeset
48
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
49 // 実行可能な HTask のリスト。 FifoTaskManager と共有される
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
50 activeTaskQueue = ppeManager->activeTaskQueue;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
51 // HTask の factory。 HTaskInfo ならなんでもいい。
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
52 htaskImpl = activeTaskQueue; // any HTaskInfo
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
53
1077
325b6c6d7d65 use one activeTaskQueue
yutaka@localhost.localdomain
parents: 1070
diff changeset
54
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
55 ppeManager->get_scheduler()->set_manager(this);
637
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
56
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
57 // Task 内からManager->task_create() とかするときに必要なTaskManager。
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
58 // 現状では ppe 側からしか動かない
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
59 // spe 側から Task create できない
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
60 schedTaskManager = new SchedTask();
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
61 schedTaskManager->init(0, 0, ppeManager->get_scheduler(), 0);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
62 ppeManager->schedTaskManager = schedTaskManager;
1479
163220e54cc0 remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1477
diff changeset
63
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
64 _export_task_log = export_task_log;
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
65 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
66
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
67 void CellTaskManagerImpl::append_activeTask(HTaskPtr task) {
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
68 if (task->cpu_type == CPU_PPE) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
69 ppeManager->append_activeTask(task);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
70 } else {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
71 activeTaskQueue->addLast(task);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
72 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
73 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
74
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
75 // SPE_ANY が指定されていた時に
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
76 // これをインクリメントしつつ呼ぶことにする。
940
e01b551f25d6 unknown dead lock still...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 939
diff changeset
77 unsigned int cur_anySpeid = 0;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
78
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
79 /**
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
80 * ActiveTaskQueue から Task を
938
20beb83a5a22 dead lock still remains. zombi problem?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 937
diff changeset
81 * 各 SPE に渡す (backgound) TaskList に入れる
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
82 *
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
83 * ここの activeTaskQueue は FifoTaskManagerImpl のと意味が違い、
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
84 * spe に渡される Task だけ入っている
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
85 */
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
86 void CellTaskManagerImpl::set_runTaskList(QueueInfo<HTask> *activeTaskQueue) {
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
87 int speid;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
88 HTaskPtr htask = activeTaskQueue->getFirst();
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
89 while (htask != NULL) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
90 if (htask->cpu_type == CPU_PPE) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
91 htask = activeTaskQueue->getNext(htask);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
92 } else {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
93 if (htask->cpu_type == SPE_ANY) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
94 speid = cur_anySpeid++;
1494
289e427bd49f fix set param kernelArg
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1492
diff changeset
95 #ifdef __CERIUM_GPU__
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
96 } else if (htask->cpu_type == GPU_0) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
97 speid = htask->cpu_type - 1;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
98 #endif
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
99 } else {
1492
73f4bfaeaf99 fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1491
diff changeset
100 // -1 してるのは
73f4bfaeaf99 fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1491
diff changeset
101 // htask->cpu_type - CPU_SPE で
73f4bfaeaf99 fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1491
diff changeset
102 // SPE0 = 1, SPE1 = 2, ... SPE5 = 6 ってなってるので
73f4bfaeaf99 fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1491
diff changeset
103 // 配列的 (SPE0 = arr[0], SPE1 = arr[1]) にするため
73f4bfaeaf99 fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1491
diff changeset
104 speid = htask->cpu_type - CPU_SPE - 1;
73f4bfaeaf99 fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1491
diff changeset
105 }
73f4bfaeaf99 fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1491
diff changeset
106 speid %= machineNum;
73f4bfaeaf99 fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1491
diff changeset
107
73f4bfaeaf99 fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1491
diff changeset
108 set_taskList(htask, taskListInfo[speid]);
73f4bfaeaf99 fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1491
diff changeset
109
73f4bfaeaf99 fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1491
diff changeset
110 HTaskPtr next = activeTaskQueue->getNext(htask);
73f4bfaeaf99 fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1491
diff changeset
111 activeTaskQueue->remove(htask);
73f4bfaeaf99 fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1491
diff changeset
112 htask = next;
73f4bfaeaf99 fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1491
diff changeset
113
73f4bfaeaf99 fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1491
diff changeset
114 }
73f4bfaeaf99 fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1491
diff changeset
115 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
116 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
117
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
118 void CellTaskManagerImpl::sendTaskList() {
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
119 for (int id = 0; id < machineNum; id++) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
120 mail_check(id);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
121 if (!speTaskList[id]->empty()) {
1606
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1605
diff changeset
122 continue; // まだ、走ってる
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
123 }
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
124 if (!taskListInfo[id]->empty()) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
125 // SPE に送る TaskList の準備
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
126 send_taskList(id);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
127 spe_running++;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
128 }
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
129 }
721
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
130 }
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
131
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
132 void CellTaskManagerImpl::poll() {
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
133 set_runTaskList(activeTaskQueue);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
134 // TaskList 待ちの SPE に TaskList を送る
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
135 sendTaskList();
808
3c404a32719c TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 806
diff changeset
136 }
3c404a32719c TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 806
diff changeset
137
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
138 void CellTaskManagerImpl::debug_check_spe_idle(
1606
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1605
diff changeset
139 QueueInfo<HTask> * activeTaskQueue, int spe_running_) {
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
140 printf("spu_idle! spe_running = %d : activeTaskQueue->length = %d \n",
1606
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1605
diff changeset
141 spe_running_, activeTaskQueue->length());
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
142 HTaskPtr task = activeTaskQueue->getFirst();
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
143 int tmp_i = 0;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
144 do {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
145 printf("task_name = %s ,", ppeManager->get_task_name(task));
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
146 printf("cpu = [%d], count = %d", task->cpu_type, tmp_i);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
147 tmp_i++;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
148 } while ((task = activeTaskQueue->getNext(task)) != 0);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
149 printf("\n");
1057
8cd123d2f3ca debug_check_spu_idle add. commandline option [-spuidle].
tkaito@henri
parents: 972
diff changeset
150 }
8cd123d2f3ca debug_check_spu_idle add. commandline option [-spuidle].
tkaito@henri
parents: 972
diff changeset
151
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
152 void CellTaskManagerImpl::run() {
1437
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
153 int spu_limit = spuIdle;
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
154 if (machineNum == 0) {
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
155 ppeManager->run();
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
156 return;
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
157 }
1125
b733c7903d07 remove old code
yutaka@localhost.localdomain
parents: 1123
diff changeset
158
1437
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
159 do {
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
160 // PPE side
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
161 ppeManager->poll();
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
162 // SPE side
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
163 do {
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
164 poll();
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
165 } while (ppeManager->activeTaskQueue->empty() && spe_running > 0);
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
166
1437
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
167 if (spe_running < spu_limit) {
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
168 debug_check_spe_idle(ppeManager->activeTaskQueue, spe_running);
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
169 }
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
170
1437
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
171 } while (!ppeManager->activeTaskQueue->empty() || !activeTaskQueue->empty() || spe_running > 0);
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
172 if (!waitTaskQueue->empty()) {
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
173 show_dead_lock_info();
fa6723e7d329 fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1429
diff changeset
174 }
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
175
937
ecafd19a1d83 Sort working on spu cpu == 1 or -a case
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 936
diff changeset
176 }
ecafd19a1d83 Sort working on spu cpu == 1 or -a case
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 936
diff changeset
177
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
178 static void loop_check(HTask *p, HTask *me, int depth) {
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
179 if (p == me)
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
180 printf("*%lx ", (long) p); // loop
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
181 if (depth == 0)
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
182 return;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
183 QueueInfo<TaskQueue> *w = p->wait_i;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
184 if (w) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
185 for (TaskQueue *q = w->getFirst(); q; q = w->getNext(q)) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
186 loop_check(q->task, me, depth - 1);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
187 }
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
188 }
939
aafa99c856a3 loop detection.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 938
diff changeset
189 }
aafa99c856a3 loop detection.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 938
diff changeset
190
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
191 void CellTaskManagerImpl::show_dead_lock_info() {
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
192 get_scheduler()-> printf("Dead lock detected\n ppe queue %d\n",
1606
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1605
diff changeset
193 ppeManager->activeTaskQueue->length());
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
194 // 確か waitQueue は共通...
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
195 // get_scheduler()-> printf(" wait queue %d\n",ppeManager->waitTaskQueue->length());
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
196 get_scheduler()-> printf(" wait queue %d\n", waitTaskQueue->length());
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
197 for (HTask *p = waitTaskQueue->getFirst(); p; p = waitTaskQueue->getNext(p)) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
198 printf(" Waiting task%d %lx", p->command, (long) p);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
199 QueueInfo<TaskQueue> *w = p->wait_i;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
200 if (w) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
201 for (TaskQueue *q = w->getFirst(); q; q = w->getNext(q)) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
202 printf(" waiting task%d %lx", q->task->command,
1606
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1605
diff changeset
203 (long) q->task);
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
204 if (!waitTaskQueue->find(q->task)) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
205 printf("!"); // stray task
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
206 }
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
207 loop_check(q->task, p, 10);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
208 }
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
209 }
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
210 printf("\n");
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
211 }
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
212 get_scheduler()-> printf(" spe queue %d\n", activeTaskQueue->length());
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
213 for (int i = 0; i < machineNum; i++) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
214 get_scheduler()-> printf(" spe %d send %d wait %d\n", i,
1606
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1605
diff changeset
215 speTaskList[i]->length(), taskListInfo[i]->length());
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
216 }
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
217 }
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
218
65
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
219 /**
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
220 * SPE からのメールをチェックする
640
ecf056ddd21a SimpeTask on Cell worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 638
diff changeset
221 */
ecf056ddd21a SimpeTask on Cell worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 638
diff changeset
222
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
223 void CellTaskManagerImpl::mail_check(int id) {
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
224 memaddr data;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
225
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
226 // SPE Scheduler からの mail check
1608
8841d97c37e5 debug CpuThreads::spawn_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1606
diff changeset
227 while (speThreads->has_mail(id,1,&data)) {
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
228 if (data == (memaddr) MY_SPE_STATUS_READY) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
229 // MY_SPE_STATUS_READY: SPE が持ってた Task 全て終了
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
230 // freeAll する前に循環リストに戻す
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
231 speTaskList[id]->getLast()->next = speTaskList[id];
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
232 speTaskList[id]->freeAll();
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
233 spe_running--;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
234 // printf("SPE %d status ready, %d running\n",id, spe_running);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
235 } else if (data == (memaddr) MY_SPE_COMMAND_MALLOC) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
236 // MY_SPE_COMMAND_MALLOC SPE からのmain memory request
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
237 send_alloc_reply(this, id, speThreads);
1605
5b99bcc6bdb0 fix mail_check and init dim_count and init _export_task_log.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1585
diff changeset
238 } else if (data == (memaddr) MY_SPE_NOP) {
5b99bcc6bdb0 fix mail_check and init dim_count and init _export_task_log.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1585
diff changeset
239 continue;
5b99bcc6bdb0 fix mail_check and init dim_count and init _export_task_log.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1585
diff changeset
240 } else {
830
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 812
diff changeset
241 #ifdef TASK_LIST_MAIL
1606
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1605
diff changeset
242 // multi dimensionだったらカウントする
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
243 TaskListPtr list = (TaskListPtr)data;
1624
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 1614
diff changeset
244 if (--list->self->flag.dim_count == 0)
1606
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1605
diff changeset
245 check_task_list_finish(schedTaskManager, list, waitTaskQueue);
830
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 812
diff changeset
246 #else
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
247 // 終了したタスク(PPEにあるのでアドレス)
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
248 HTaskPtr task = (HTaskPtr) data;
1151
kaito@dolphins
parents: 1150
diff changeset
249 #if 0
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
250 if (task->cpu_type != CPU_SPE) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
251 const char *name = get_task_name(task);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
252 if (name != NULL) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
253 printf("[SPE] ");
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
254 printf("Task id : %d, ", task->command);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
255 printf("Task name : %s\n", name);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
256 }
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
257 }
1150
d014639cbdc7 add test code.
kaito@dolphins
parents: 1147
diff changeset
258 #endif
1147
279b41354753 add check code.
Yutaka_Kinjyo
parents: 1125
diff changeset
259 #ifndef NOT_CHECK
279b41354753 add check code.
Yutaka_Kinjyo
parents: 1125
diff changeset
260
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
261 if (task != NULL) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
262 //SPE で処理された Task が返ってくるはず。それがもし、type PPE なら・・・
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
263 if (task->cpu_type == CPU_PPE) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
264 printf("attention : PPE task run on SPE\n");
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
265 printf("Task id : %d\n", task->command);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
266 const char *name = get_task_name(task);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
267 if (name != NULL) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
268 printf("Task name : %s\n", name);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
269 }
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
270 }
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
271 }
1147
279b41354753 add check code.
Yutaka_Kinjyo
parents: 1125
diff changeset
272
279b41354753 add check code.
Yutaka_Kinjyo
parents: 1125
diff changeset
273 #endif
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
274
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
275 task->post_func(schedTaskManager, task->post_arg1, task->post_arg2);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
276 check_task_finish(task, waitTaskQueue);
830
af2fb2e641eb return TaskList->self
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 812
diff changeset
277 #endif
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
278 }
1606
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1605
diff changeset
279 // MY_SPE_NOP: 特に意味のないコマンド
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
280 }
719
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
281 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
282
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
283 void CellTaskManagerImpl::polling() {
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
284 // may call recursively check_task_list_finish()
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
285 // we need fifo here
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
286 for (int i = 0; i < machineNum; i++) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
287 mail_check(i);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
288 }
833
577bde5d0cec poling (may recurse..)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 830
diff changeset
289 }
577bde5d0cec poling (may recurse..)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 830
diff changeset
290
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
291 static void send_alloc_reply(CellTaskManagerImpl *tm, int id,
1606
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1605
diff changeset
292 Threads *speThreads) {
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
293
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
294 /**
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
295 * info[0] = alloc_id; (CellScheduler::mainMem_alloc 参照)
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
296 * info[1] = alloc_addr;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
297 */
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
298 memaddr alloc_info[2];
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
299 long alloc_size;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
300 long command;
275
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 273
diff changeset
301
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
302 speThreads->get_mail(id, 2, alloc_info);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
303 command = (long) alloc_info[0];
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
304 alloc_size = (long) alloc_info[1];
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
305
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
306 alloc_info[1] = (memaddr) tm->allocate(alloc_size);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
307 //__debug_ppe("[PPE] MALLOCED 0x%lx from [SPE %d]\n", alloc_info[1],id);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
308 // 今のところ何もしてない。どうも、この allocate を free
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
309 // するのは、SPE task が返した値を見て行うらしい。それは、
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
310 // 忘れやすいのではないか?
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
311 speThreads->add_output_tasklist(command, alloc_info[1], alloc_size);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
312
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
313 speThreads->send_mail(id, 2, alloc_info);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
314 }
66
1034077dd217 *** empty log message ***
gongo
parents: 65
diff changeset
315
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
316 /**
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
317 * 条件を満たしたら SPE に TaskList を送信する
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
318 * 条件1. SPE が持ってた TaskList を終了して、次の TaskList を待ってる
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
319 * 条件2. SPE に送る TaskList に Task がある
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
320 *
808
3c404a32719c TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 806
diff changeset
321 * SPE で実行終了した speTaskList と
3c404a32719c TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 806
diff changeset
322 * これから実行する taskListInfo のバッファを入れ替える
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
323 */
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
324 void CellTaskManagerImpl::send_taskList(int id) {
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
325 // speTaskList は走り終わった ppe の Task の List.
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
326 // taskListInfo はこれから走る Task の List.
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
327 // 交換して実行する
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
328 QueueInfo<TaskList> *tmp = taskListInfo[id];
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
329 taskListInfo[id] = speTaskList[id];
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
330 speTaskList[id] = tmp;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
331
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
332 // speTaskList は本来は循環リストなのだけど、実行中は線形リストである。
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
333 // spe の Task が終了した時点でなおす。
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
334 tmp->getLast()->next = 0;
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
335 TaskListPtr p = tmp->getFirst();
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
336 // printf("SPE %d task list sending\n",id);
1608
8841d97c37e5 debug CpuThreads::spawn_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1606
diff changeset
337
8841d97c37e5 debug CpuThreads::spawn_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1606
diff changeset
338 // speThreads->send_mail(id, 1, p);
1580
806b4658ced6 add multi dimension
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1561
diff changeset
339 speThreads->spawn_task(id, p);
1608
8841d97c37e5 debug CpuThreads::spawn_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1606
diff changeset
340
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
341 // printf("SPE %d task list sent\n",id);
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
342 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
343
672
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
344 void CellTaskManagerImpl::show_profile() {
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
345 for (int id = 0; id < machineNum; id++) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
346 HTaskPtr t = schedTaskManager->create_task(ShowTime, 0, 0, 0, 0);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
347 t->set_cpu((CPU_TYPE) (id + SPE_0));
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
348 t->spawn();
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
349 }
672
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
350 }
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
351
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
352 void CellTaskManagerImpl::start_profile() {
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
353 for (int id = 0; id < machineNum; id++) {
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
354 HTaskPtr t = schedTaskManager->create_task(StartProfile, 0, 0, 0, 0);
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
355 t->set_cpu((CPU_TYPE) (id + SPE_0));
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
356 t->spawn();
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
357 }
672
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
358 }
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
359
1428
af2adce9752e add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1362
diff changeset
360 void CellTaskManagerImpl::export_task_log() {
af2adce9752e add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1362
diff changeset
361 ExportTaskLog _export(taskLogQueue);
af2adce9752e add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1362
diff changeset
362 _export.printOut();
af2adce9752e add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1362
diff changeset
363 }
af2adce9752e add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1362
diff changeset
364
1179
5393bebe0956 CpuThreads update
Daichi TOMA
parents: 1151
diff changeset
365 void CellTaskManagerImpl::print_arch() {
1606
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1605
diff changeset
366 printf("CellTaskManager\n");
1067
5ad8fb1dc70f print_arch add.
tkaito
parents: 1066
diff changeset
367 }
5ad8fb1dc70f print_arch add.
tkaito
parents: 1066
diff changeset
368
1427
db5c022d871c task array uses TaskList. (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1362
diff changeset
369 TaskListPtr CellTaskManagerImpl::createTaskList()
db5c022d871c task array uses TaskList. (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1362
diff changeset
370 {
1480
f2512fb94223 GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1479
diff changeset
371 TaskListPtr tl = taskListInfo[0]->create();
f2512fb94223 GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1479
diff changeset
372 bzero(tl->tasks,sizeof(Task)*TASK_MAX_SIZE);
1561
e8c9a7099bcc add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1501
diff changeset
373 return tl;
e8c9a7099bcc add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1501
diff changeset
374 }
e8c9a7099bcc add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1501
diff changeset
375
1481
a9da5c6bea91 fix GpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1480
diff changeset
376 #if defined (__CERIUM_CELL__)||defined (__CERIUM_GPU__)
1480
f2512fb94223 GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1479
diff changeset
377 TaskManagerImpl *create_impl(int num, int useRefDma)
f2512fb94223 GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1479
diff changeset
378 {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
379 #ifdef __CERIUM_CELL__
1480
f2512fb94223 GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1479
diff changeset
380 Threads *cpus = new SpeThreads(num);
1585
90c0ad32655f init dim
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1581
diff changeset
381
1481
a9da5c6bea91 fix GpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1480
diff changeset
382 #elif __CERIUM_GPU__
1501
8d6fee66ff65 it looks like working...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1499
diff changeset
383 int num_gpu = 1;
8d6fee66ff65 it looks like working...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1499
diff changeset
384 Threads *cpus = new CpuThreads(num, useRefDma,num_gpu);
8d6fee66ff65 it looks like working...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1499
diff changeset
385 num += num_gpu; // for GPU
1481
a9da5c6bea91 fix GpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1480
diff changeset
386 #else
1480
f2512fb94223 GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1479
diff changeset
387 Threads *cpus = new CpuThreads(num, useRefDma);
f2512fb94223 GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1479
diff changeset
388 #endif
1499
622a7d053537 cpu id etc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1494
diff changeset
389 return new CellTaskManagerImpl(num, cpus);
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
390 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
391 #endif // __CERIUM_CELL