boost thread slow with only one thread

hi! here is my problem i am multithreading my program with boost but i don't get what i expect, and i can't understand why! i just run one thread and wait for it, and the fps are divide by 3. basically with no thread i have 30fps, and with 1 thread i have 10fps. here is the code: Code: boost::thread_group forces_threads; forces_threads.create_thread(boost::bind(&ElasticRods::computeBendingForces,this,edges,kb,edges_initial)); forces_threads.join_all(); i use thread_group because i want to run 7 thread but it is already too slow! do you have an idea of why this is so slow? thank you for your help!

----- Original Message ----- From: "Natacha Fort" <natachafrt@gmail.com> To: <boost@lists.boost.org> Sent: Thursday, May 20, 2010 12:36 PM Subject: [boost] boost thread slow with only one thread
hi! here is my problem i am multithreading my program with boost but i don't get what i expect, and i can't understand why! i just run one thread and wait for it, and the fps are divide by 3. basically with no thread i have 30fps, and with 1 thread i have 10fps. here is the code:
Code:
boost::thread_group forces_threads; forces_threads.create_thread(boost::bind(&ElasticRods::computeBendingForces,this,edges,kb,edges_initial)); forces_threads.join_all();
i use thread_group because i want to run 7 thread but it is already too slow! do you have an idea of why this is so slow? thank you for your help!
I suppose that the time spend by your computation not significant to need the creation of a thread on a group and join it. How much time takes your function computeBendingForces? Can you try without thread_group, directly with thread? Can you try with as many threads as cores do you have on independent calls (free of race conditions) to computeBendingForces? Can you find a configuration for which computeBendingForces takes much more time? Best, Vicente
participants (3)
-
Natacha Fort
-
Sohail Somani
-
vicente.botet