Mercurial > hg > Game > Cerium
annotate example/word_count/main.cc @ 1963:6988e5478a8c draft
fix CudaScheduler
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 12 Feb 2014 17:56:40 +0900 |
parents | fdffcf8feeab |
children | a68dbdf9b429 |
rev | line source |
---|---|
1584 | 1 #include <stdio.h> |
393 | 2 #include <stdlib.h> |
3 #include <string.h> | |
4 #include <sys/mman.h> | |
5 #include <sys/types.h> | |
6 #include <sys/stat.h> | |
7 #include <fcntl.h> | |
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 | 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 | 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 | 14 |
1268 | 15 /* ;TODO |
16 * PS3でCPU数が2以上の時に、あまりが計算されてない | |
17 */ | |
18 | |
400 | 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; |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
27 int use_iterate = 0; |
1897
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
28 int use_iterate_all = 0; |
1963
6988e5478a8c
fix CudaScheduler
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1962
diff
changeset
|
29 int array_task_num = 11; |
970
1a4849b2acad
change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
968
diff
changeset
|
30 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
|
31 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
|
32 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
|
33 |
1544
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
34 static double |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
35 getTime() { |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
36 struct timeval tv; |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
37 gettimeofday(&tv, NULL); |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
38 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
|
39 } |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
40 |
393 | 41 typedef struct { |
42 caddr_t file_mmap; | |
43 off_t size; | |
44 } st_mmap_t; | |
45 | |
46 /*与えられたsizeをfix_byte_sizeの倍数にする(丸め込むっていうのかな?)*/ | |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
47 static int |
393 | 48 fix_byte(int size,int fix_byte_size) |
49 { | |
50 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
|
51 |
393 | 52 return size; |
53 } | |
54 | |
55 | |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
56 static st_mmap_t |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
57 my_mmap(char *filename) |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
58 { |
393 | 59 |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
60 /*マッピングだよ!*/ |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
61 int fd = -1; |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
62 int map = MAP_PRIVATE; |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
63 st_mmap_t st_mmap; |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
64 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
|
65 |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
66 if ((fd=open(filename,O_RDONLY,0666))==0) { |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
67 fprintf(stderr,"can't open %s\n",filename); |
393 | 68 } |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
69 |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
70 if (fstat(fd,&sb)) { |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
71 fprintf(stderr,"can't fstat %s\n",filename); |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
72 } |
1910
b7b528e9ec5e
Implement divide read in word_count ( but cannot running )
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1897
diff
changeset
|
73 |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
74 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
|
75 |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
76 /*sizeをページングサイズの倍数にあわせる*/ |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
77 st_mmap.size = fix_byte(sb.st_size,4096); |
393 | 78 |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
79 printf("fix 4096byte file size %d\n",(int)st_mmap.size); |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
80 |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
81 st_mmap.file_mmap = (char*)mmap(NULL,st_mmap.size,PROT_READ,map,fd,(off_t)0); |
393 | 82 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
|
83 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
|
84 perror(NULL); |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
85 exit(0); |
393 | 86 } |
87 | |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
88 return st_mmap; |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
89 |
1910
b7b528e9ec5e
Implement divide read in word_count ( but cannot running )
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1897
diff
changeset
|
90 } |
393 | 91 |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
92 static void |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
93 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
|
94 { |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
95 |
1542
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 < 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
|
97 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
|
98 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
|
99 } |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
100 |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
101 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
|
102 HTask *task_array; |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
103 if (use_task_array) { |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
104 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
|
105 if (task_num>array_task_num) task_num = array_task_num; |
1836
56692133c5fb
success run wordcount with gpu, but result is wrong
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1835
diff
changeset
|
106 task_array = manager->create_task_array(TASK_EXEC,task_num,1,1,1); |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
107 if (!all) { |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
108 t_next->wait_for(task_array); |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
109 } else { |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
110 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
|
111 } |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
112 } |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
113 |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
114 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
|
115 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
|
116 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
|
117 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
|
118 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
|
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); |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
122 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
|
123 t_exec->set_outData(0,w->o_data + i*w->out_size, w->division_out_size); |
1836
56692133c5fb
success run wordcount with gpu, but result is wrong
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1835
diff
changeset
|
124 t_exec->set_param(0,(long)size); |
1688
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); |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
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 |
1737 | 132 h_exec->set_cpu(spe_cpu); |
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(); |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
134 } else if (use_iterate) { |
1897
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
135 if(use_iterate_all) |
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
136 array_task_num = w->task_num; |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
137 w->size -= size*array_task_num; |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
138 if(w->size < 0) array_task_num -= 1; |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
139 h_exec = manager->create_task(TASK_EXEC_DATA_PARALLEL); |
1897
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
140 h_exec->flip(); |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
141 h_exec->set_inData(0,w->file_mmap,w->file_size); |
1897
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
142 h_exec->set_inData(1,w->o_data,w->out_size_); |
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
143 h_exec->set_outData(0,w->file_mmap,w->file_size); |
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
144 h_exec->set_outData(1,w->o_data,w->out_size_); |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
145 h_exec->set_param(0,(long)i); |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
146 h_exec->set_param(1,(long)w->division_size); |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
147 h_exec->set_param(2,(long)size); |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
148 h_exec->set_param(3,(long)w->out_size); |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
149 |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
150 t_next->wait_for(h_exec); |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
151 h_exec->set_cpu(spe_cpu); |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
152 h_exec->iterate(array_task_num); |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
153 |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
154 w->task_num -= array_task_num; |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
155 w->task_spwaned += array_task_num-1; |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
156 |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
157 if(w->size < 0) { |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
158 h_exec = manager->create_task(TASK_EXEC_DATA_PARALLEL); |
1897
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
159 h_exec->flip(); |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
160 h_exec->set_inData(0,w->file_mmap,w->file_size); |
1897
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
161 h_exec->set_inData(1,w->o_data,w->out_size_); |
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
162 h_exec->set_outData(0,w->file_mmap,w->file_size); |
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
163 h_exec->set_outData(1,w->o_data,w->out_size_); |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
164 h_exec->set_param(0,(long)w->task_spwaned); |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
165 h_exec->set_param(1,(long)w->division_size); |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
166 h_exec->set_param(2,(long)(size+w->size)); |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
167 h_exec->set_param(3,(long)w->out_size); |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
168 |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
169 t_next->wait_for(h_exec); |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
170 h_exec->set_cpu(spe_cpu); |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
171 h_exec->iterate(1); |
1870
44fa0f1320a9
run wordcount with iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1837
diff
changeset
|
172 |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
173 w->task_num -= 1; |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
174 w->task_spwaned += 1; |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
175 array_task_num += 1; |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
176 } |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
177 break; |
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 } else { |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
179 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
|
180 (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
|
181 (memaddr)(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
|
182 t_next->wait_for(h_exec); |
1737 | 183 h_exec->set_cpu(spe_cpu); |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
184 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
|
185 } |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
186 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
|
187 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
|
188 } |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
189 if (use_task_array) { |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
190 task_array->spawn_task_array(t_exec->next()); |
1737 | 191 task_array->set_cpu(spe_cpu); |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
192 task_array->spawn(); |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
193 } else { |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
194 //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
|
195 } |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
196 } |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
197 } |
393 | 198 |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
199 /** |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
200 * このTaskは、PPE上で実行されるので、並列に実行されることはない |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
201 * 二つ実行されていて、Task が足りなくなることがないようにしている。 |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
202 */ |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
203 |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
204 SchedDefineTask1(RUN_TASK_BLOCKS,run16); |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
205 |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
206 static int |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
207 run16(SchedTask *manager, void *in, void *out) |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
208 { |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
209 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
|
210 |
1897
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
211 if(use_iterate_all) { |
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
212 run_tasks(manager, w, w->task_num, w->t_print, w->division_size); |
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
213 } else 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
|
214 // last case |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
215 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
|
216 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
|
217 // remaining data |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
218 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
|
219 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
|
220 // printf("run16 last %d\n",w->task_num); |
949 | 221 } else { |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
222 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
|
223 (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
|
224 w->t_print->wait_for(t_next); |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
225 |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
226 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
|
227 |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
228 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
|
229 // 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
|
230 } |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
231 return 0; |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
232 } |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
233 |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
234 static int blocks = 48; |
1123 | 235 //static int blocks = 31 * 6 * 24; |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
236 static int division = 16; // in Kbyte |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
237 |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
238 static void |
400 | 239 run_start(TaskManager *manager, char *filename) |
393 | 240 { |
241 HTaskPtr t_print; | |
242 | |
243 st_mmap_t st_mmap; | |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
244 st_mmap = my_mmap(filename); |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
245 WordCount *w = (WordCount*)manager->allocate(sizeof(WordCount)); |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
246 // bzero(w,sizeof(WordCount)); |
393 | 247 |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
248 //w->task_blocks = blocks; |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
249 w->self = w; |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
250 w->task_spwaned = 0; |
393 | 251 |
252 /*sizeはdivision_sizeの倍数にしている。*/ | |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
253 w->size = w->file_size = st_mmap.size; |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
254 w->file_mmap = st_mmap.file_mmap; |
949 | 255 printf("w %lx\n",(long)w); |
1960
273de551f726
use multiple command_queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1941
diff
changeset
|
256 |
393 | 257 /* 1task分のデータサイズ(byte) */ |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
258 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
|
259 w->division_size = 1024 * division;/*16kbyte*/ |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
260 } else { |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
261 w->division_size = w->size; |
393 | 262 } |
263 | |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
264 printf("dvision_size %d\n",w->division_size); |
393 | 265 |
266 /* "word num" and "line num" */ | |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
267 w->status_num = 2; |
393 | 268 /* taskの数 */ |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
269 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
|
270 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
|
271 int out_task_num = w->task_num; |
394 | 272 |
968 | 273 if(!all) { |
274 w->task_blocks = blocks; | |
275 } else { | |
276 w->task_blocks = w->task_num; | |
277 } | |
278 | |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
279 w->out_task_num = out_task_num; |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
280 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
|
281 printf("out_task_num %d\n",w->out_task_num); |
394 | 282 |
1007 | 283 /* out用のdivision_size. statusが2つなので、あわせて16byteになるように、long long(4byte)を使用 */ |
393 | 284 |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
285 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
|
286 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
|
287 w->o_data = (unsigned long long *)manager->allocate(out_size); |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
288 w->out_size_ = out_size; |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
289 w->out_size = 4; |
393 | 290 printf("out size %d\n",out_size); |
291 | |
292 /*各SPEの結果を合計して出力するタスク*/ | |
293 | |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
294 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
|
295 (memaddr)&w->self,sizeof(memaddr),0,0); |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
296 w->t_print = t_print; |
1837 | 297 for(int i=0;i<1;i++) { |
1783 | 298 /* Task を task_blocks ずつ起動する Task */ |
299 /* serialize されていると仮定する... */ | |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
300 HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS, |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
301 (memaddr)&w->self,sizeof(memaddr),0,0); |
1783 | 302 t_print->wait_for(t_exec); |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
303 // t_exec->iterate(4); |
1783 | 304 t_exec->spawn(); |
305 } | |
393 | 306 t_print->spawn(); |
307 } | |
308 | |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
309 static char* |
393 | 310 init(int argc, char **argv) |
311 { | |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
312 |
394 | 313 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
|
314 |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
315 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
|
316 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
|
317 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
|
318 } 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
|
319 division = atoi(argv[i+1]); |
1679
ff43dc274ec9
word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1678
diff
changeset
|
320 i++; |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
321 } 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
|
322 blocks = atoi(argv[i+1]); |
1679
ff43dc274ec9
word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1678
diff
changeset
|
323 i++; |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
324 } 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
|
325 // 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
|
326 all = 1; |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
327 } 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
|
328 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
|
329 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
|
330 } 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
|
331 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
|
332 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
|
333 } 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
|
334 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
|
335 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
|
336 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
|
337 } 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
|
338 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
|
339 i++; |
1894
b37dfbf3380d
fix GpuTaskManagerFactory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1870
diff
changeset
|
340 } else if (strcmp(argv[i], "-g") == 0) { |
1941
f19885ea776d
add wordcount for cuda. fix CudaScheduler. add makefile
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1913
diff
changeset
|
341 spe_cpu = GPU_0; |
1894
b37dfbf3380d
fix GpuTaskManagerFactory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1870
diff
changeset
|
342 } else if (strcmp(argv[i], "-any") == 0) { |
b37dfbf3380d
fix GpuTaskManagerFactory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1870
diff
changeset
|
343 spe_cpu = ANY_ANY; |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
344 } else if (strcmp(argv[i], "-i") == 0) { |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
345 use_iterate = 1; |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
346 use_task_array = 0; |
1897
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
347 } else if (strcmp(argv[i], "-ia") == 0) { |
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
348 use_iterate_all = 1; |
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
349 use_iterate = 1; |
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
350 use_task_array = 0; |
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
351 } /* 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
|
352 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
|
353 i++; |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
354 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
|
355 } else { |
1679
ff43dc274ec9
word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1678
diff
changeset
|
356 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
|
357 exit (0); |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
358 }*/ |
393 | 359 } |
400 | 360 if (filename==0) { |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
361 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
|
362 exit(1); |
400 | 363 } |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
364 |
393 | 365 return filename; |
366 } | |
367 | |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
368 |
393 | 369 int |
400 | 370 TMmain(TaskManager *manager, int argc, char *argv[]) |
393 | 371 { |
372 | |
394 | 373 char *filename = 0; |
374 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
|
375 |
393 | 376 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
|
377 return -1; |
393 | 378 } |
379 | |
380 task_init(); | |
400 | 381 run_start(manager, filename); |
1544
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
382 st_time = getTime(); |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
383 manager->set_TMend(TMend); |
393 | 384 return 0; |
385 } | |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
386 |
1544
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
387 void |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
388 TMend(TaskManager *manager) |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
389 { |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
390 ed_time = getTime(); |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
391 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
|
392 } |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
393 |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
394 /* end */ |