473,466 Members | 1,430 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

multi-cores & multi-processors how does that effect threaded programming?

I am designing a process which will spawn a good number of threads and some
of them will execute a c++ process which is quite memory intensive (although
not multithreaded). This will run on a 2 cpu (both dual core) server. What
do I need to do if anything in order to spread the workload across the cpu's
/ cores in order to tune it properly?

I googled it and found this post but its somewhat dated and didn't know if
it applied to 2.0
http://groups.google.com/group/micro...af8e569498ee9b

the posting makes reference to this guide by MS but it only speaks of .Net
1.0 so I'm not sure how accurate it still is in 2.0

http://www.microsoft.com/downloads/d...displaylang=en
any thoughts or references?

thanks alot

Apr 19 '07 #1
5 1935
On Apr 19, 6:30 am, "Coaster" <Coas...@Coaster.netwrote:
I am designing a process which will spawn a good number of threads and some
of them will execute a c++ process which is quite memory intensive (although
not multithreaded). This will run on a 2 cpu (both dual core) server. What
do I need to do if anything in order to spread the workload across the cpu's
/ cores in order to tune it properly?

I googled it and found this post but its somewhat dated and didn't know if
it applied to 2.0

http://groups.google.com/group/micro...framework.clr/...

the posting makes reference to this guide by MS but it only speaks of .Net
1.0 so I'm not sure how accurate it still is in 2.0

http://www.microsoft.com/downloads/d...d=8a2e454d-f30...

any thoughts or references?

thanks alot
You shouldn't have to do anything. The OS will affinitize the threads
automatically.

Apr 19 '07 #2
One thing to watch out for is that the tick count on the various
processors may not be identical. Some vendors have BIOS updates to fix
this. I also understand that Vista handles this issue as well. But if
you're using the StopWatch or high frequency counters accessed some
other way -- watch out! You'll need to set thread affinity on those.

Apr 19 '07 #3
On Thu, 19 Apr 2007 04:30:20 -0700, Coaster <Co*****@Coaster.netwrote:
I am designing a process which will spawn a good number of threads and
some of them will execute a c++ process which is quite memory intensive
(although not multithreaded). This will run on a 2 cpu (both dual core)
server. What do I need to do if anything in order to spread the
workload across the cpu's / cores in order to tune it properly?
Nothing really. Keep in mind that for CPU-intensive tasks, it doesn't do
any good to have more threads than you have processors, and in fact adding
more than that many threads will only slow things down due to the context
switch costs. If your tasks involve a lot of i/o, then having lots of
extra threads can help by allowing new work to be started or finished
while other threads are waiting for i/o to complete. It's okay to have a
few extra threads, but if you have too many runnable threads (not waiting
on i/o or other things) at once they will just spend a lot of time
fighting over the processor(s).

Multi-threaded algorithms can get very complicated, there are lots of
little details to get right, and lots of different ways to optimize how
things work. So sure, in that sense you can do lots to ensure that your
code is "tuned properly". But fundamentally, the main goal is to have
just enough threads to ensure that there's exactly one thread that is
runnable for each processor on the computer. If you do that, Windows will
take care of the rest.

The links you posted aren't, I don't think, very relevant to your
question. They do address some relatively esoteric issues related to
multi-threading programming, but I don't think they should affect you.
The same general rules apply.

Pete
Apr 19 '07 #4

"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Thu, 19 Apr 2007 04:30:20 -0700, Coaster <Co*****@Coaster.netwrote:
>I am designing a process which will spawn a good number of threads and
some of them will execute a c++ process which is quite memory intensive
(although not multithreaded). This will run on a 2 cpu (both dual core)
server. What do I need to do if anything in order to spread the
workload across the cpu's / cores in order to tune it properly?

Nothing really. Keep in mind that for CPU-intensive tasks, it doesn't do
any good to have more threads than you have processors, and in fact adding
more than that many threads will only slow things down due to the context
switch costs. If your tasks involve a lot of i/o, then having lots of
extra threads can help by allowing new work to be started or finished
while other threads are waiting for i/o to complete. It's okay to have a
few extra threads, but if you have too many runnable threads (not waiting
on i/o or other things) at once they will just spend a lot of time
fighting over the processor(s).

Multi-threaded algorithms can get very complicated, there are lots of
little details to get right, and lots of different ways to optimize how
things work. So sure, in that sense you can do lots to ensure that your
code is "tuned properly". But fundamentally, the main goal is to have
just enough threads to ensure that there's exactly one thread that is
runnable for each processor on the computer. If you do that, Windows will
take care of the rest.

The links you posted aren't, I don't think, very relevant to your
question. They do address some relatively esoteric issues related to
multi-threading programming, but I don't think they should affect you.
The same general rules apply.

Pete
ok thanks for the info, it makes sense, I never thought about it like that.
For the links I was just wondering if the information still applied to the
2.0 environment.

Apr 20 '07 #5
Coaster wrote:
I am designing a process which will spawn a good number of threads and some
of them will execute a c++ process which is quite memory intensive (although
not multithreaded). This will run on a 2 cpu (both dual core) server. What
do I need to do if anything in order to spread the workload across the cpu's
/ cores in order to tune it properly?
As other has stated: you do not need to do anything. .NET and Windows
will utilize all the CPU's and cores.

But a small extra note: if your code is not as thread safe as it should
be, then moving from a 1 core environment to a 4 core environment can
bring out the problems. So be sure to test in a multi core environment !

I speak from experience ... :-(

Arne
Apr 22 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: thejackofall | last post by:
Hi. I have a TemplateColumn with sorting. However, it does not fire the sort event. Here is what I have. Please help. <asp:TemplateColumn HeaderText="Wire ID" SortExpression="WireID">...
3
by: Robert Blackwell | last post by:
Just a curious individual here. I dont' know anything about writing programs cross platform or anything, just wondering if this move would have any affect in porting the CLR to mac? And, how that...
4
by: MLH | last post by:
A programmer developed an AMP (Apache/MySQL/PHP) application for me. When he was done, he sent me the PHP files and the MySQL dump file. Now, when I connect to the application on my LAN using...
0
by: mike | last post by:
regards: Does the following programming architecture make sense? http://www.wretch.cc/album/show.php?i=otp&b=1&f=1111993473&p=2 ...
12
by: Jason | last post by:
hello everyone! recently i've been working through K&R's The C programming language, and i just finished exercise 3.3, since my solution is shorter than the "suggested solution" online, i want to...
0
by: GHicks | last post by:
My company uses HTML code for a button that works with Javascript. Someone told me that javascript does not work with DotNet Nuke, which is a version of ASP.net. Is this correct?
7
by: Sebarry | last post by:
Hi, I'm having trouble creating a blank table row in Javascript using document.createElement( '&nbsp;' ). When I look at the generated source it has intrepreted it as <td>&amp;nbsp;</td>. What do I...
6
by: dba | last post by:
using the following code with a problem.... echo "<input type='hidden' name='member_id' value=\"{$row}\">{$row}"; echo "<input type='radio' name='member_name' value=\"{$row}\">{$row}<br />"; ...
1
by: Jack Wu | last post by:
hello everyone! i am a freshman of computer science and not a native English speaker, so if i made some stupid grammatic or spelling mistake please tell me. i'll correct it as soon as possible and...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.