annotate example/word_count/main.cc @ 1727:e99dc86d39e2 draft

minor fix
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Wed, 30 Oct 2013 19:05:38 +0900
parents 1755ae347fce
children 6bd9a57eb44d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1584
Masa <e085726@ie.u-ryukyu.ac.jp>
parents: 1579
diff changeset
1 #include <stdio.h>
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
2 #include <stdlib.h>
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
3 #include <string.h>
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
4 #include <sys/mman.h>
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
5 #include <sys/types.h>
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
6 #include <sys/stat.h>
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
7 #include <fcntl.h>
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
8 #include <unistd.h>
1544
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
9 #include <sys/time.h>
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
10 #include "TaskManager.h"
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
11 #include "SchedTask.h"
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
12 #include "Func.h"
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
13 #include "WordCount.h"
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
14
1268
f0808a329663 find bug
Daichi Toma <amothic@gmail.com>
parents: 1123
diff changeset
15 /* ;TODO
f0808a329663 find bug
Daichi Toma <amothic@gmail.com>
parents: 1123
diff changeset
16 * PS3でCPU数が2以上の時に、あまりが計算されてない
f0808a329663 find bug
Daichi Toma <amothic@gmail.com>
parents: 1123
diff changeset
17 */
f0808a329663 find bug
Daichi Toma <amothic@gmail.com>
parents: 1123
diff changeset
18
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
19 extern void task_init();
1544
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
20 void TMend(TaskManager *);
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
21 static double st_time;
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
22 static double ed_time;
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
23 int all = 0;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
24 int use_task_array = 1;
1039
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
25 int use_task_creater = 0;
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
26 int use_compat = 0;
967
daab1b74b32d add anum option in WordCount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 950
diff changeset
27 int array_task_num = 8;
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
28 int spe_num = 1;
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
29 CPU_TYPE spe_cpu = SPE_ANY;
1679
ff43dc274ec9 word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1678
diff changeset
30 const char *usr_help_str = "Usage: ./word_count [-a -c -s] [-cpu spe_num] [-g] [-file filename]\n";
1542
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
31
1544
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
32 static double
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
33 getTime() {
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
34 struct timeval tv;
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
35 gettimeofday(&tv, NULL);
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
36 return tv.tv_sec + (double)tv.tv_usec*1e-6;
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
37 }
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
38
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
39 typedef struct {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
40 caddr_t file_mmap;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
41 off_t size;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
42 } st_mmap_t;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
43
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
44 /*与えられたsizeをfix_byte_sizeの倍数にする(丸め込むっていうのかな?)*/
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
45 static int
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
46 fix_byte(int size,int fix_byte_size)
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
47 {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
48 size = (size/fix_byte_size)*fix_byte_size + ((size%fix_byte_size)!= 0)*fix_byte_size;
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
49
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
50 return size;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
51 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
52
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
53
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
54 static st_mmap_t
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
55 my_mmap(char *filename)
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
56 {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
57
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
58 /*マッピングだよ!*/
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
59 int fd = -1;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
60 int map = MAP_PRIVATE;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
61 st_mmap_t st_mmap;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
62 struct stat sb;
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
63
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
64 if ((fd=open(filename,O_RDONLY,0666))==0) {
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
65 fprintf(stderr,"can't open %s\n",filename);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
66 }
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
67
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
68 if (fstat(fd,&sb)) {
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
69 fprintf(stderr,"can't fstat %s\n",filename);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
70 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
71
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
72 printf("file size %d\n",(int)sb.st_size);
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
73
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
74 /*sizeをページングサイズの倍数にあわせる*/
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
75 st_mmap.size = fix_byte(sb.st_size,4096);
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
76
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
77 printf("fix 4096byte file size %d\n",(int)st_mmap.size);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
78
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
79 st_mmap.file_mmap = (char*)mmap(NULL,st_mmap.size,PROT_READ,map,fd,(off_t)0);
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
80 if (st_mmap.file_mmap == (caddr_t)-1) {
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
81 fprintf(stderr,"Can't mmap file\n");
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
82 perror(NULL);
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
83 exit(0);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
84 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
85
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
86 return st_mmap;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
87
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
88 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
89
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
90 static void
1688
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
91 run_tasks(SchedTask *manager, WordCount *w, int task_count, HTaskPtr t_next, int size)
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
92 {
1688
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
93
1542
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
94 if (task_count < array_task_num) {
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
95 array_task_num = task_count;
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
96 if (task_count<=0) return;
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
97 }
1688
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
98
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
99 for (int i = 0; i < task_count; i += array_task_num) {
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
100
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
101 HTask *task_array;
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
102 if (use_task_array) {
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
103 int task_num = (w->size+size-1)/size;
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
104 if (task_num>array_task_num) task_num = array_task_num;
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
105 task_array = manager->create_task_array(TASK_EXEC,task_num,0,1,1);
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
106 if (!all) {
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
107 t_next->wait_for(task_array);
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
108 } else {
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
109 w->t_print->wait_for(task_array);
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
110 }
1542
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
111 }
1688
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
112
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
113 Task *t_exec = 0;
1542
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
114 HTask *h_exec = 0;
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
115 for (int j = 0; j < array_task_num; j++) {
1688
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
116 int i = w->task_spwaned++;
1542
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
117 if (w->size < size) size = w->size;
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
118 int length = size/sizeof(char);
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
119 if (size==0) break;
1688
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
120 if (use_task_array) {
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
121 t_exec = task_array->next_task_array(TASK_EXEC,t_exec);
1727
e99dc86d39e2 minor fix
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 1694
diff changeset
122 t_exec->set_param(0,&length);
1688
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
123 t_exec->set_inData(0,w->file_mmap + i*w->division_size, size);
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
124 t_exec->set_outData(0,w->o_data + i*w->out_size, w->division_out_size);
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
125 } else if (use_compat) {
1542
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
126 h_exec = manager->create_task(TASK_EXEC);
1688
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
127 h_exec->set_inData(0,w->file_mmap + i*w->division_size, size);
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
128 h_exec->set_outData(0,w->o_data + i*w->out_size, w->division_out_size);
1021
47ca99c5cf84 use MailManager
yutaka@localhost.localdomain
parents: 1007
diff changeset
129
1688
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
130 t_next->wait_for(h_exec);
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
131
1688
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
132 h_exec->set_cpu(SPE_ANY);
1542
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
133 h_exec->spawn();
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
134 } else {
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
135 h_exec = manager->create_task(TASK_EXEC,
1688
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
136 (memaddr)(w->file_mmap + i*w->division_size), size,
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
137 (memaddr)(w->o_data + i*w->out_size), w->division_out_size);
1727
e99dc86d39e2 minor fix
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 1694
diff changeset
138 h_exec->set_param(0,&length);
1688
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
139 t_next->wait_for(h_exec);
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
140 h_exec->set_cpu(SPE_ANY);
1542
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
141 h_exec->spawn();
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
142 }
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
143 w->size -= size;
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
144 w->task_num--;
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
145 }
1688
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
146 if (use_task_array) {
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
147 task_array->spawn_task_array(t_exec->next());
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
148 task_array->set_cpu(SPE_ANY);
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
149 task_array->spawn();
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
150 } else {
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
151 //if (!all) t_next->wait_for(h_exec);
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
152 }
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
153 }
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
154 }
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
155
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
156 /**
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
157 * このTaskは、PPE上で実行されるので、並列に実行されることはない
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
158 * 二つ実行されていて、Task が足りなくなることがないようにしている。
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
159 */
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
160
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
161 SchedDefineTask1(RUN_TASK_BLOCKS,run16);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
162
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
163 static int
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
164 run16(SchedTask *manager, void *in, void *out)
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
165 {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
166 WordCount *w = *(WordCount **)in;
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
167
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
168 if (w->task_num < w->task_blocks) {
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
169 // last case
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
170 while (w->size >= w->division_size)
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
171 run_tasks(manager,w,w->task_num, w->t_print, w->division_size);
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
172 // remaining data
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
173 while (w->size>0)
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
174 run_tasks(manager,w,1, w->t_print, w->size);
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
175 // printf("run16 last %d\n",w->task_num);
949
5f0135ca75ee word count size fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 948
diff changeset
176 } else {
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
177 HTaskPtr t_next = manager->create_task(RUN_TASK_BLOCKS,
1542
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
178 (memaddr)&w->self,sizeof(memaddr),0,0);
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
179 w->t_print->wait_for(t_next);
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
180
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
181 run_tasks(manager,w, w->task_blocks, t_next, w->division_size);
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
182
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
183 t_next->spawn();
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
184 // printf("run16 next %d\n",w->task_num);
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
185 }
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
186 return 0;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
187 }
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
188
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
189
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
190 static int blocks = 48;
1123
2a63ba2c9506 bug fix.
yutaka@localhost.localdomain
parents: 1083
diff changeset
191 //static int blocks = 31 * 6 * 24;
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
192 static int division = 16; // in Kbyte
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
193
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
194 static void
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
195 run_start(TaskManager *manager, char *filename)
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
196 {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
197 HTaskPtr t_print;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
198
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
199 st_mmap_t st_mmap;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
200 st_mmap = my_mmap(filename);
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
201 WordCount *w = (WordCount*)manager->allocate(sizeof(WordCount));
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
202 // bzero(w,sizeof(WordCount));
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
203
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
204 //w->task_blocks = blocks;
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
205 w->self = w;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
206 w->task_spwaned = 0;
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
207
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
208 /*sizeはdivision_sizeの倍数にしている。*/
949
5f0135ca75ee word count size fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 948
diff changeset
209 w->size = w->file_size = st_mmap.size;
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
210 w->file_mmap = st_mmap.file_mmap;
949
5f0135ca75ee word count size fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 948
diff changeset
211 printf("w %lx\n",(long)w);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
212
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
213 /* 1task分のデータサイズ(byte) */
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
214 if (w->size >= 1024*division) {
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
215 w->division_size = 1024 * division;/*16kbyte*/
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
216 } else {
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
217 w->division_size = w->size;
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
218 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
219
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
220 printf("dvision_size %d\n",w->division_size);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
221
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
222 /* "word num" and "line num" */
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
223 w->status_num = 2;
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
224 /* taskの数 */
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
225 w->task_num = w->size / w->division_size;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
226 w->task_num = w->task_num + (w->division_size*w->task_num < w->size);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
227 int out_task_num = w->task_num;
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
228
968
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
229 if(!all) {
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
230 w->task_blocks = blocks;
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
231 } else {
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
232 w->task_blocks = w->task_num;
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
233 }
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
234
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
235 w->out_task_num = out_task_num;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
236 printf("task_num %d\n",w->task_num);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
237 printf("out_task_num %d\n",w->out_task_num);
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
238
1007
00c01f416e3a add mail_queue
yutaka@localhost.localdomain
parents: 972
diff changeset
239 /* out用のdivision_size. statusが2つなので、あわせて16byteになるように、long long(4byte)を使用 */
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
240
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
241 w->division_out_size = sizeof(unsigned long long)*4;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
242 int out_size = w->division_out_size*out_task_num;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
243 w->o_data = (unsigned long long *)manager->allocate(out_size);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
244 w->out_size = 4;
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
245 printf("out size %d\n",out_size);
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
246
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
247 /*各SPEの結果を合計して出力するタスク*/
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
248
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
249 t_print = manager->create_task(TASK_PRINT,
1542
9ccfdc408d51 fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1538
diff changeset
250 (memaddr)&w->self,sizeof(memaddr),0,0);
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
251 w->t_print = t_print;
783
76781837ff3a wordcount fix?
yutaka@localhost.localdomain
parents: 743
diff changeset
252
1694
1755ae347fce use iterate for multiply
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 1688
diff changeset
253 // for(int i = 0;i<4;i++) {
1755ae347fce use iterate for multiply
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 1688
diff changeset
254 // /* Task を task_blocks ずつ起動する Task */
1755ae347fce use iterate for multiply
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 1688
diff changeset
255 // /* serialize されていると仮定する... */
1755ae347fce use iterate for multiply
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 1688
diff changeset
256 HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS,
1755ae347fce use iterate for multiply
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 1688
diff changeset
257 (memaddr)&w->self,sizeof(memaddr),0,0);
1755ae347fce use iterate for multiply
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 1688
diff changeset
258 t_print->wait_for(t_exec);
1755ae347fce use iterate for multiply
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 1688
diff changeset
259 t_exec->iterate(4);
1755ae347fce use iterate for multiply
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 1688
diff changeset
260 // t_exec->spawn();
1755ae347fce use iterate for multiply
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 1688
diff changeset
261 // }
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
262 t_print->spawn();
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
263 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
264
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
265 static char*
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
266 init(int argc, char **argv)
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
267 {
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
268
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
269 char *filename = 0;
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
270
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
271 for (int i = 1; argv[i]; ++i) {
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
272 if (strcmp(argv[i], "-file") == 0) {
1679
ff43dc274ec9 word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1678
diff changeset
273 filename = argv[i+1]; i++;
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
274 } else if (strcmp(argv[i], "-division") == 0) {
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
275 division = atoi(argv[i+1]);
1679
ff43dc274ec9 word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1678
diff changeset
276 i++;
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
277 } else if (strcmp(argv[i], "-block") == 0) {
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
278 blocks = atoi(argv[i+1]);
1679
ff43dc274ec9 word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1678
diff changeset
279 i++;
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
280 } else if (strcmp(argv[i], "-a") == 0) {
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
281 // create task all at once
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
282 all = 1;
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
283 } else if (strcmp(argv[i], "-c") == 0) {
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
284 use_task_array = 0;
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
285 use_compat = 1;
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
286 } else if (strcmp(argv[i], "-s") == 0) {
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
287 use_task_array = 0;
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
288 use_compat = 0;
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
289 } else if (strcmp(argv[i], "-t") == 0) {
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
290 use_task_creater = 1;
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
291 use_task_array = 0;
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
292 use_compat = 0;
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
293 } else if (strcmp(argv[i], "-anum") == 0) {
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
294 array_task_num = atoi(argv[i+1]);
1679
ff43dc274ec9 word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1678
diff changeset
295 i++;
1688
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
296 } /*else if (strcmp(argv[i], "-g") == 0 ) {
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
297 spe_cpu = GPU_0;
1688
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
298 } else if (strcmp(argv[i], "-cpu") == 0) {
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
299 spe_num = atoi(argv[i+1]);
1679
ff43dc274ec9 word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1678
diff changeset
300 i++;
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
301 if (spe_num==0) spe_num = 1;
1688
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
302 } else {
1679
ff43dc274ec9 word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1678
diff changeset
303 fprintf(stderr,"%s\n",usr_help_str);
ff43dc274ec9 word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1678
diff changeset
304 exit (0);
1688
705f09f646ac remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1684
diff changeset
305 }*/
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
306 }
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
307 if (filename==0) {
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
308 puts(usr_help_str);
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
309 exit(1);
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
310 }
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
311
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
312 return filename;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
313 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
314
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
315
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
316 int
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
317 TMmain(TaskManager *manager, int argc, char *argv[])
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
318 {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
319
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
320 char *filename = 0;
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
321 filename = init(argc, argv);
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
322
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
323 if (filename < 0) {
1538
fac06524090b add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1351
diff changeset
324 return -1;
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
325 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
326
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
327 task_init();
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
328 run_start(manager, filename);
1544
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
329 st_time = getTime();
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
330 manager->set_TMend(TMend);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
331 return 0;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
332 }
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
333
1544
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
334 void
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
335 TMend(TaskManager *manager)
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
336 {
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
337 ed_time = getTime();
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
338 printf("Time: %0.6f\n",ed_time-st_time);
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
339 }
5c4e3f0d372a many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 1542
diff changeset
340
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
341 /* end */