By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,603 Members | 1,422 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,603 IT Pros & Developers. It's quick & easy.

No proformance improvement using boost::thread on a Duo Core PC

P: n/a
I used a boost multi thread in VS 2005 on a Duo Core PC, and made a two
thread process.

The code is something like this:

#include <boost/thread/thread.hpp>

void fun1()
{
//do something
}

void fun2()
{
//do something
}
int _tmain(int argc, _TCHAR* argv[])
{

boost::thread thrd(&fun1);
boost::thread thrd2(&fun2);
thrd.join();
thrd2.join();
return 0;
}

It can run, but run on only one of the two cores. The CPU usage is 50%.
Isn't that multi-thread can improve proformance on multi-core CPU?

Any help would be appreciated.

Nov 16 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
li********@gmail.com wrote:
Isn't that multi-thread can improve proformance on multi-core CPU?
Multi-core CPUs improve multithreading performance, not the other way
around.

Nov 16 '06 #2

P: n/a

li********@gmail.com skrev:
I used a boost multi thread in VS 2005 on a Duo Core PC, and made a two
thread process.

The code is something like this:

#include <boost/thread/thread.hpp>

void fun1()
{
//do something
}

void fun2()
{
//do something
}
int _tmain(int argc, _TCHAR* argv[])
{

boost::thread thrd(&fun1);
boost::thread thrd2(&fun2);
thrd.join();
thrd2.join();
return 0;
}

It can run, but run on only one of the two cores. The CPU usage is 50%.
Isn't that multi-thread can improve proformance on multi-core CPU?
If only one cpu is used and both fun1 and fun2 are doing something
measurable (that is the operations are "substantial"), there is
something wrong somewhere. One thing that could go wrong is that the
two functions depend on each other, so that when fun1 runs fun2 can not
possibly run.
My suggestion would be that you tried to perform some dummy
calculations in the functions (e.g. calculating some million
trigonometric results on local values). If only cpu is used in this
case, you should ask further in a some group related to boost
(comp.boost.users?) or one related to the operating system you use.

/Peter

Nov 16 '06 #3

P: n/a
Thank you very much!! Peter.

I found that if I used

cout<<

in these two threads, then these two threads can only run on same core.

I kick out cout, then two cores were both used.
It can run, but run on only one of the two cores. The CPU usage is 50%.
Isn't that multi-thread can improve proformance on multi-core CPU?

If only one cpu is used and both fun1 and fun2 are doing something
measurable (that is the operations are "substantial"), there is
something wrong somewhere. One thing that could go wrong is that the
two functions depend on each other, so that when fun1 runs fun2 can not
possibly run.
My suggestion would be that you tried to perform some dummy
calculations in the functions (e.g. calculating some million
trigonometric results on local values). If only cpu is used in this
case, you should ask further in a some group related to boost
(comp.boost.users?) or one related to the operating system you use.

/Peter
Nov 16 '06 #4

P: n/a
Sorry, I made a big mistake.

Finally I found that even I use "cout<<" in both thread, I still can
use two cores at the same time.

But if I do so, the proformance will become so low that made me fell I
use only one core.

li********@gmail.com gDG
Thank you very much!! Peter.

I found that if I used

cout<<

in these two threads, then these two threads can only run on same core.

I kick out cout, then two cores were both used.
Nov 17 '06 #5

P: n/a
Sorry, I made a big mistake.
>
Finally I found that even I use "cout<<" in both thread, I still can
use two cores at the same time.

But if I do so, the proformance will become so low that made me fell I
use only one core.

of course, you can't measure performance by io operations.
do some calculations in both threads, and you will see the benefit of
duo core cpu.

Nov 17 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.