annotate example/hello_array/main.cc @ 1254:34944900f266 draft

minor fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 18 Nov 2011 16:56:11 +0900
parents ceca625af064
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
733
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
1 #include <stdio.h>
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
2 #include <stdlib.h>
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
3 #include <string.h>
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
4 #include "TaskManager.h"
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
5 #include "Task.h"
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
6 #include "ListData.h"
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
7 #include "Func.h"
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
8
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
9 extern void task_init(void);
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
10
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
11 static int task_num = 1;
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
12 /*0 だと task_num が4つ以上の時に止まる。*/
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
13 static int data_count = 1;
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
14
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
15 const char *usr_help_str = "Usage: ./hello [-task task_num]\n\
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
16 -task Number of task (default 1)\n";
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
17
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
18 static int
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
19 init(int argc, char **argv)
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
20 {
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
21 for (int i = 1; argv[i]; ++i) {
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
22
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
23 if (strcmp(argv[i], "-task") == 0) {
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
24 task_num = atoi(argv[++i]);
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
25 }
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
26 }
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
27
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
28 return 0;
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
29 }
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
30
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
31
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
32 void
734
01e3c74fd5b1 name change
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 733
diff changeset
33 hello_init(TaskManager *manager)
733
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
34 {
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
35 /**
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
36 * Create Task
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
37 * create_task(Task ID);
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
38 */
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
39
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
40 /*うしろ3つ param/inData/outData の数を指定する*/
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
41 HTask *twice_main = manager->create_task_array(Hello,task_num,data_count,data_count,data_count);
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
42 Task *t = 0;
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
43
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
44 for(int i = 0;i<task_num;i++) {
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
45 t = twice_main->next_task_array(Hello, t);
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
46 }
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
47 twice_main->spawn_task_array(t->next());
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
48 twice_main->set_cpu(SPE_ANY);
1002
ceca625af064 many changes.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 787
diff changeset
49 twice_main->spawn();
733
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
50 }
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
51
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
52 int
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
53 TMmain(TaskManager *manager,int argc, char *argv[])
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
54 {
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
55
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
56 if (init(argc, argv) < 0) {
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
57 return -1;
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
58 }
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
59
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
60 // Task Register
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
61 // ppe/task_init.cc
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
62 task_init();
734
01e3c74fd5b1 name change
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 733
diff changeset
63 hello_init(manager);
733
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
64
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
65
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
66 return 0;
f0b7eeb72918 add array sample helloworld
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
67 }