annotate example/mainMem/main.cc @ 1293:82dc8a041cfe draft

refactoring matrix_test.cc
author Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
date Fri, 02 Dec 2011 15:03:54 +0900
parents 94d82f2c842f
children f40558ec00a8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
312
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <stdio.h>
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <stdlib.h>
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include <string.h>
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "TaskManager.h"
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 #include "Func.h"
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 extern void task_init(void);
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 static int count = 1;
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 const char *usr_help_str = "Usage: ./hello [-cpu spe_num] [-count N]\n\
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 -cpu Number of SPE (default 1) \n\
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 -count Number of task is print \"Hello, World!!\"";
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 int
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 init(int argc, char **argv)
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 {
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 for (int i = 1; argv[i]; ++i) {
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 if (strcmp(argv[i], "-count") == 0) {
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 count = atoi(argv[++i]);
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 }
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 }
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 return 0;
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 }
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 void
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 312
diff changeset
29 hello_init(TaskManager *manager)
312
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 {
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 HTask *hello;
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 for (int i = 0; i < count; i++) {
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 /**
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 * Create Task
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 * create_task(Task ID);
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 */
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 hello = manager->create_task(HELLO_TASK);
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 /**
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 * Select CPU
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 * SPE_0, SPE_1, SPE_2, SPE_3, SPE_4, SPE_5, SPE_ANY
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 * if you do not call this, execute PPE.
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 */
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 hello->set_cpu(SPE_ANY);
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 /**
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 * Set 32bits parameter
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 * add_param(32bit parameter);
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 */
625
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
51 hello->add_param((memaddr)i);
312
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 hello->spawn();
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 }
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 }
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 int
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 312
diff changeset
58 TMmain(TaskManager *manager, int argc, char *argv[])
312
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 {
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 if (init(argc, argv) < 0) {
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 return -1;
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 }
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 // Task Register
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 // ppe/task_init.cc
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 task_init();
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 312
diff changeset
68 hello_init(manager);
312
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 return 0;
1db2b3dc6a5a memMain tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 }