Mercurial > hg > Game > Cerium
annotate example/dependency_task/main.cc @ 839:1001c4bea1a0 draft
if unnecessary
author | Yutaka_Kinjyo |
---|---|
date | Fri, 28 May 2010 03:24:52 +0900 |
parents | 94d82f2c842f |
children | f40558ec00a8 |
rev | line source |
---|---|
109 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include "TaskManager.h" | |
5 #include "Func.h" | |
6 | |
7 extern void task_init(void); | |
8 | |
9 int *idata; | |
10 int length = DATA_NUM; | |
11 int depend_flg = 1; | |
12 | |
258 | 13 const char *usr_help_str = "Usage: ./dependency [-cpu spe_num] [-nodepend]\n\ |
109 | 14 -nodepend No Depenendcy"; |
15 | |
16 void | |
400 | 17 run_start(TaskManager *manager) |
109 | 18 { |
481
f9ffcffb6d09
Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
19 HTaskPtr t_exec[2]; |
109 | 20 HTaskPtr t_print; |
21 | |
258 | 22 idata = (int*)manager->allocate(sizeof(int)*length*2); |
109 | 23 for (int i = 0; i < length*2; i++) { |
24 idata[i] = 0; | |
25 } | |
26 | |
298 | 27 // exec1,2 が計算した配列を見る |
109 | 28 t_print = manager->create_task(TASK_PRINT); |
29 t_print->add_inData(idata, sizeof(int)*length*2); | |
625
94d82f2c842f
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
481
diff
changeset
|
30 t_print->add_param((memaddr)(length*2)); |
109 | 31 |
298 | 32 // idata を二つに分けて計算する |
109 | 33 for (int i = 0; i < 2; i++) { |
481
f9ffcffb6d09
Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
34 t_exec[i] = manager->create_task(TASK_EXEC); |
f9ffcffb6d09
Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
35 t_exec[i]->add_inData(&idata[length*i], sizeof(int)*length); |
f9ffcffb6d09
Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
36 t_exec[i]->add_outData(&idata[length*i], sizeof(int)*length); |
625
94d82f2c842f
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
481
diff
changeset
|
37 t_exec[i]->add_param((memaddr)length); |
94d82f2c842f
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
481
diff
changeset
|
38 t_exec[i]->add_param((memaddr)(13*(i+1))); |
481
f9ffcffb6d09
Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
39 t_exec[i]->set_cpu(SPE_ANY); |
109 | 40 |
41 if (depend_flg) | |
481
f9ffcffb6d09
Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
42 t_print->wait_for(t_exec[i]); |
109 | 43 } |
44 | |
45 // add Active Queue | |
46 t_print->spawn(); | |
481
f9ffcffb6d09
Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
47 |
f9ffcffb6d09
Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
48 for (int i = 0; i < 2; i++) { |
f9ffcffb6d09
Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
49 t_exec[i]->spawn(); |
f9ffcffb6d09
Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
50 } |
109 | 51 } |
52 | |
53 int | |
54 init(int argc, char **argv) | |
55 { | |
56 for (int i = 1; argv[i]; ++i) { | |
57 if (strcmp(argv[i], "-nodepend") == 0) { | |
58 depend_flg = 0; | |
59 } | |
60 } | |
61 | |
62 return 0; | |
63 } | |
64 | |
65 int | |
400 | 66 TMmain(TaskManager *manager, int argc, char *argv[]) |
109 | 67 { |
68 if (init(argc, argv) < 0) { | |
69 return -1; | |
70 } | |
71 | |
72 task_init(); | |
400 | 73 run_start(manager); |
109 | 74 |
75 return 0; | |
76 } |