Mercurial > hg > Game > Cerium
comparison example/word_count/main.cc @ 783:76781837ff3a draft
wordcount fix?
author | yutaka@localhost.localdomain |
---|---|
date | Tue, 20 Apr 2010 15:37:42 +0900 |
parents | 55ccf5f6d9af |
children | 083c4a270809 |
comparison
equal
deleted
inserted
replaced
781:836ca3419f9d | 783:76781837ff3a |
---|---|
80 int size = st_mmap.size; | 80 int size = st_mmap.size; |
81 char *file_mmap = st_mmap.file_mmap; | 81 char *file_mmap = st_mmap.file_mmap; |
82 | 82 |
83 /* 1task分のデータサイズ(byte) */ | 83 /* 1task分のデータサイズ(byte) */ |
84 int division_size; | 84 int division_size; |
85 if (size >= 4096*4) { | 85 if (size >= 1024*16) { |
86 division_size = 4096 * 4;/*16kbyte*/ | 86 division_size = 1024 * 16;/*16kbyte*/ |
87 } | 87 } |
88 else { | 88 else { |
89 division_size = size; | 89 division_size = size; |
90 } | 90 } |
91 | 91 |
117 | 117 |
118 /*各SPEに処理するデータを割り振る。*/ | 118 /*各SPEに処理するデータを割り振る。*/ |
119 | 119 |
120 /*渡すデータの最後が文字かどうか。(スペース、改行以外)*/ | 120 /*渡すデータの最後が文字かどうか。(スペース、改行以外)*/ |
121 int word_flag = 0; | 121 int word_flag = 0; |
122 int i; | 122 int index = 1; |
123 int task_size = 32; | 123 int array_task_num = 1; |
124 for (i = 0; i < task_num; i+=task_size) { | 124 for (int i = 0; i < task_num; i += array_task_num) { |
125 HTask *task_main = manager->create_task_array(TASK_EXEC,task_size,2,1,1); | 125 HTask *task_main = manager->create_task_array(TASK_EXEC,array_task_num,2,1,1); |
126 int j ; | 126 int j ; |
127 Task *t_exec = 0; | 127 Task *t_exec = 0; |
128 for(j = 0; j < task_size; j++) { | 128 for(j = 0; j < array_task_num; j++) { |
129 t_exec = task_main->next_task_array(TASK_EXEC,t_exec); | 129 t_exec = task_main->next_task_array(TASK_EXEC,t_exec); |
130 task_main->set_cpu(SPE_ANY); | |
131 t_print->wait_for(task_main); | 130 t_print->wait_for(task_main); |
132 | 131 |
133 // t_exec = manager->create_task(TASK_EXEC); | 132 // t_exec = manager->create_task(TASK_EXEC); |
134 t_exec->set_param(0,division_size); | 133 t_exec->set_param(0,division_size); |
135 t_exec->set_param(1,word_flag); | 134 t_exec->set_param(1,word_flag); |
136 t_exec->set_inData(0,file_mmap + i*division_size, division_size); | 135 |
137 t_exec->set_outData(0,o_data + i*status_num, division_out_size); | 136 //t_exec->set_inData(0,file_mmap + index*division_size, division_size); |
138 | 137 //t_exec->set_outData(0,o_data + index*status_num, division_out_size); |
139 word_flag = ((file_mmap[(i+1)*division_size-1] != 0x20) && (file_mmap[(i+1)*division_size-1] != 0x0A)); | 138 |
139 printf("%c",file_mmap[index*division_size]); | |
140 | |
141 t_exec->set_inData(0,&file_mmap[index*division_size], division_size); | |
142 t_exec->set_outData(0,&o_data[index*status_num], division_out_size); | |
143 | |
144 word_flag = ((file_mmap[(index+1)*division_size-1] != 0x20) && (file_mmap[(index+1)*division_size-1] != 0x0A)); | |
140 | 145 |
141 size -= division_size; | 146 size -= division_size; |
147 index++; | |
148 | |
142 } | 149 } |
150 | |
143 task_main->spawn_task_array(t_exec->next()); | 151 task_main->spawn_task_array(t_exec->next()); |
144 | 152 task_main->set_cpu(SPE_ANY); |
145 } | 153 task_main->spawn(); |
146 | 154 |
155 } | |
156 | |
157 | |
158 | |
147 while (size>0) { | 159 while (size>0) { |
148 | 160 |
149 t_exec = manager->create_task(TASK_EXEC); | 161 t_exec = manager->create_task(TASK_EXEC); |
150 t_exec->set_param(0,size); | 162 t_exec->set_param(0,size); |
151 t_exec->set_param(1,word_flag); | 163 t_exec->set_param(1,word_flag); |
152 t_exec->set_inData(0,file_mmap + i*division_size, size); | 164 t_exec->set_inData(0,file_mmap + index*division_size, size); |
153 t_exec->set_outData(0,o_data + i*status_num, division_out_size); | 165 t_exec->set_outData(0,o_data + index*status_num, division_out_size); |
154 t_exec->set_cpu(SPE_ANY); | 166 t_exec->set_cpu(SPE_ANY); |
155 t_print->wait_for(t_exec); | 167 t_print->wait_for(t_exec); |
156 t_exec->spawn(); | 168 t_exec->spawn(); |
157 i++; | 169 index++; |
158 size -= division_size; | 170 size -= division_size; |
159 } | 171 } |
160 | |
161 | 172 |
162 t_print->spawn(); | 173 t_print->spawn(); |
163 } | 174 } |
164 | 175 |
165 char* | 176 char* |