annotate example/hello_array/main.cc @ 1002:c79651141045

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