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"
|
220
|
7 #include "sort.h"
|
109
|
8
|
|
9 extern void task_init(void);
|
|
10
|
220
|
11 // sort.cc
|
|
12 extern int data_length;
|
|
13 extern DataPtr data;
|
|
14
|
|
15 // 計測用
|
|
16 static double st_time;
|
|
17 static double ed_time;
|
|
18
|
|
19 static int length = 1200;
|
|
20
|
|
21 // prototype
|
|
22 void TMend(void);
|
|
23
|
|
24 static double
|
|
25 getTime(void)
|
|
26 {
|
|
27 struct timeval tv;
|
|
28 gettimeofday(&tv, NULL);
|
|
29 return tv.tv_sec + (double)tv.tv_usec*1e-6;
|
|
30 }
|
256
|
31 /*
|
220
|
32 static void
|
|
33 show_data(void)
|
|
34 {
|
|
35 puts("-----------------------------------------------");
|
|
36 for(int i = 0; i < data_length; i++) {
|
|
37 printf("data[%02d].index = %d\n", i, data[i].index);
|
|
38 }
|
|
39 puts("-----------------------------------------------");
|
|
40 }
|
256
|
41 */
|
109
|
42
|
256
|
43 const char *usr_help_str = "Usage: ./sort [option]\n \
|
217
|
44 options\n\
|
|
45 -cpu Number of SPE used (default 1)\n\
|
|
46 -l, --length Sorted number of data (default 1200)\n\
|
|
47 -h, --help Print this message";
|
109
|
48
|
|
49 int
|
|
50 init(int argc, char **argv)
|
|
51 {
|
|
52 for (int i = 1; argv[i]; ++i) {
|
217
|
53 if (strcmp(argv[i], "--length") == 0 || strcmp(argv[i], "-l") == 0) {
|
220
|
54 length = atoi(argv[++i]);
|
109
|
55 }
|
256
|
56
|
109
|
57 }
|
|
58
|
|
59 return 0;
|
|
60 }
|
|
61
|
220
|
62 extern void sort_init(int, int);
|
|
63
|
|
64 unsigned int ts, te;
|
|
65
|
109
|
66 int
|
220
|
67 TMmain(int argc, char *argv[])
|
109
|
68 {
|
|
69 if (init(argc, argv) < 0) {
|
|
70 return -1;
|
|
71 }
|
|
72
|
|
73 task_init();
|
|
74
|
220
|
75 sort_init(manager->get_cpuNum(), length);
|
109
|
76
|
|
77 st_time = getTime();
|
|
78
|
227
|
79 // 全ての Task が終了した後に実行する関数をセット
|
220
|
80 manager->set_TMend(TMend);
|
109
|
81
|
|
82 return 0;
|
|
83 }
|
|
84
|
220
|
85 void
|
|
86 TMend(void)
|
109
|
87 {
|
220
|
88 ed_time = getTime();
|
230
|
89 //show_data();
|
220
|
90 printf("Time: %0.6f\n",ed_time-st_time);
|
109
|
91 }
|