How to get optimum number of threads

How to get optimum number of threads

Imagen de smallb

Guys, I have a tbb::concurrent_unsorted_set loaded with path's to files (100.000+ files), and I'd like to set a optimum no of threads to create via tbb::task_scheduler_init, so there isn't oversubscription present while processing those files. Do I have to do it anyway? Will tbb do it better for me? In any case I'd like to know the optimum no of threads to spawnby me or by tbb (I need to display this info in a window) . Is there a way to do it?
Thank you.

publicaciones de 5 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.
Imagen de ahelwer
Best Reply

If you do it right, the optimum number of threads should be set automatically - that is, one thread for every core on the system. The key is to use the TBB task scheduler in the way it was designed, and just spawn a TBB task for processing any given file. The scheduler will map those tasks dynamically onto available threads, resulting in zero oversubscription - if no thread is available to run the task, it is put onto a work queue. The tutorial makes for a good introduction to the inner workings of the task scheduler.

Imagen de Raf Schietekat

That depends on the program design. Normally you shouldn't be doing any I/O inside TBB code, but if you want to do that anyway, and need to deploy more threads than normal to counter undersubscription, your penalty is to tune the program yourself (because the outcome is unpredictable).

Imagen de smallb

Hi,

Thank you for your answer. You mention some tutorial, could you please give me a link to it so that I could download it?

Thanks

Imagen de Sergey Kostrov

Please take a look at a very good article regarding oversubscription of threads:

http://blogs.msdn.com/b/visualizeparallel/archive/2009/12/01/oversubscription-a-classic-parallel-performance-problem.aspx

Best regards,
Sergey

Inicie sesión para dejar un comentario.