109
|
1 #include <stdio.h>
|
|
2 #include <string.h>
|
|
3 #include <stdlib.h>
|
|
4 #include <sys/time.h>
|
|
5 #include "TaskManager.h"
|
|
6 #include "Func.h"
|
|
7
|
|
8 extern void task_init(void);
|
|
9
|
|
10 int data_size = 1200;
|
|
11
|
|
12 double getTime();
|
|
13
|
|
14 char *help_str = "Usage: ./sort [-cpu spe_num] [-length data_length]\n \
|
|
15 -cpu Number of SPE used (default 1) \n \
|
|
16 -length Sorted number of data (default 1200)";
|
|
17
|
|
18 int
|
|
19 init(int argc, char **argv)
|
|
20 {
|
|
21 for (int i = 1; argv[i]; ++i) {
|
|
22 if (strcmp(argv[i], "-length") == 0) {
|
|
23 data_size = atoi(argv[++i]);
|
|
24 }
|
|
25 if (strcmp(argv[i], "--help") == 0) {
|
|
26 printf("%s\n", help_str);
|
|
27 return -1;
|
|
28 }
|
|
29 }
|
|
30
|
|
31 return 0;
|
|
32 }
|
|
33
|
|
34 int
|
|
35 main(int argc, char *argv[])
|
|
36 {
|
|
37 // 計測用
|
|
38 double st_time, ed_time;
|
|
39 HTask *runLoop;
|
|
40
|
|
41 if (init(argc, argv) < 0) {
|
|
42 return -1;
|
|
43 }
|
|
44
|
|
45 task_init();
|
|
46
|
|
47 runLoop = manager->create_task(TASK_MAIN);
|
|
48 printf("main spenum: %d\n",spenum);
|
|
49 runLoop->add_param(spenum);
|
|
50 runLoop->add_param(data_size);
|
|
51
|
|
52 runLoop->spawn();
|
|
53 // Start
|
|
54 st_time = getTime();
|
|
55 manager->run();
|
|
56 ed_time = getTime();
|
|
57
|
|
58 printf("Time: %0.6f\n",ed_time-st_time);
|
|
59
|
|
60 delete manager;
|
|
61
|
|
62 FINISH:
|
|
63 return 0;
|
|
64 }
|
|
65
|
|
66 double getTime()
|
|
67 {
|
|
68 struct timeval tv;
|
|
69 gettimeofday(&tv, NULL);
|
|
70 return tv.tv_sec + (double)tv.tv_usec*1e-6;
|
|
71 }
|