@@ -129,13 +129,10 @@ int main (int argc, char* argv[])
129129 try
130130 {
131131 const size_t nbProcs = MachineData::instance ( ).getProcessorsNum ( );
132+
133+ cout << " Computer " << NetworkData::getCurrentHostName ( ) << " has " << nbProcs << " processors." << endl;
132134
133- cout << " Computer " << NetworkData::getCurrentHostName ( ) << " has "
134- << nbProcs << " processors." << endl;
135-
136- const size_t nbWorkers = nbProcs >= 48 ? 16 : nbProcs / 3 ;
137- ThreadPool::initialize (nbWorkers / 3 );
138- // ThreadPool::initialize (nbProcs / 3);
135+ ThreadPool::initialize (nbProcs / 3 );
139136 srand (time (NULL ));
140137
141138 size_t i = 0 ;
@@ -153,8 +150,7 @@ ThreadPool::initialize (nbWorkers / 3);
153150 ThreadPool::instance ( ).addTask (*task, true );
154151 ThreadPool::instance ( ).stats (running, queued);
155152 message.clear ( );
156- message << " Progression : " << (max - running - queued) << " /"
157- << max << " \n " ;
153+ message << " Progression : " << (max - running - queued) << " /" << max << " \n " ;
158154 pwriter->write (message.ascii ( ));
159155 } // for (i = 0; i < max; i++)
160156 pwriter->write (" Joining tasks ...\n " );
@@ -166,8 +162,7 @@ ThreadPool::initialize (nbWorkers / 3);
166162 pwriter->write (" Joinable writing tasks with mutexes completed.\n\n " );
167163
168164 message.clear ( );
169- message << " Creation of " << (unsigned long )max
170- << " writing tasks with mutexes and concurrency flag ...\n " ;
165+ message << " Creation of " << (unsigned long )max << " writing tasks with mutexes and concurrency flag ...\n " ;
171166 pwriter->write (message.ascii ( ));
172167 for (i = 0 ; i < max; i++)
173168 {
@@ -177,20 +172,16 @@ ThreadPool::initialize (nbWorkers / 3);
177172 ThreadPool::instance ( ).addTask (*task, true );
178173 ThreadPool::instance ( ).stats (running, queued);
179174 message.clear ( );
180- message << " Progression : " << (max - running - queued) << " /"
181- << max << " \n " ;
175+ message << " Progression : " << (max - running - queued) << " /" << max << " \n " ;
182176 pwriter->write (message.ascii ( ));
183177 } // for (i = 0; i < max; i++)
184178 pwriter->write (" Joining tasks ...\n " );
185179 ThreadPool::instance ( ).barrier ( );
186180 ThreadPool::instance ( ).stats (running, queued);
187181 message.clear ( );
188- message << " Progression : " << (max - running - queued) << " /" << max
189- << " \n "
190- << " Joinable writing tasks with mutexes and concurrency flag "
191- << " completed.\n "
192- << " Creation of " << (unsigned long )max << " writing tasks with "
193- << " mutexes and concurrency flag and give them together ...\n " ;
182+ message << " Progression : " << (max - running - queued) << " /" << max << " \n "
183+ << " Joinable writing tasks with mutexes and concurrency flag completed.\n "
184+ << " Creation of " << (unsigned long )max << " writing tasks with mutexes and concurrency flag and give them together ...\n " ;
194185 pwriter->write (message.ascii ( ));
195186 vector<ThreadPool::TaskIfc*> tasks;
196187 for (i = 0 ; i < max; i++)
@@ -201,19 +192,16 @@ ThreadPool::initialize (nbWorkers / 3);
201192 tasks.push_back (task);
202193 ThreadPool::instance ( ).stats (running, queued);
203194 message.clear ( );
204- message << " Progression : " << (max - running - queued) << " /"
205- << max << " \n " ;
195+ message << " Progression : " << (max - running - queued) << " /" << max << " \n " ;
206196 pwriter->write (message.ascii ( ));
207197 } // for (i = 0; i < max; i++)
208198 ThreadPool::instance ( ).addTasks (tasks, true );
209199 pwriter->write (" Joining tasks ...\n " );
210200 ThreadPool::instance ( ).barrier ( );
211201 ThreadPool::instance ( ).stats (running, queued);
212202 message.clear ( );
213- message << " Progression : " << (max - running - queued) << " /" << max
214- << " \n "
215- << " Joinable writing tasks with mutexes and concurrency flag "
216- << " given together completed.\n " ;
203+ message << " Progression : " << (max - running - queued) << " /" << max << " \n "
204+ << " Joinable writing tasks with mutexes and concurrency flag given together completed.\n " ;
217205 pwriter->write (message.ascii ( ));
218206
219207 // On évalue les taches :
@@ -240,6 +228,11 @@ ThreadPool::initialize (nbWorkers / 3);
240228 cout << " Exception caught : " << exc.getFullMessage ( ) << endl;
241229 return -1 ;
242230 }
231+ catch (const exception& e)
232+ {
233+ cout << " Exception caught : " << e.what ( ) << endl;
234+ return -1 ;
235+ }
243236 catch (...)
244237 {
245238 cout << " Unexpected error caught." << endl;
0 commit comments