Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Application Programming

Reply
 
LinkBack Thread Tools
Old 07-24-08   #1 (permalink)
Programmer
 
xtascox's Avatar
 
intel nvidia

Join Date: Jul 2007
Location: Dallas, PA
Posts: 439

Rep: 20 xtascox is acknowledged by some
Unique Rep: 19
Folding Team Rank: 532
Trader Rating: 1
Default multi-threading question

Hey guys, I'm working on a multi-threaded program. I want the program to take advantage of multiple cores and I am just wondering if I have to tell the machine to use a specific core for each thread or if it will automatically allocate the thread to an open core. Say the user had a dual core cpu and my program launched 2 threads for execution. Would one thread automatically execute on core 1 and the other on core 2? The program is still on the drawing boards right now but it's either going to be written in C++ or Java. I'm not necessarily looking for code, just for an answer to the question.

Thanks ahead of time!
__________________


System: SVT
CPU
Q6600 G0 @ 3.0ghz
Motherboard
Asus P5N-E SLI
Memory
4GB G. Skill
Graphics Card
2X EVGA 8800GTS 512
Hard Drive
160GB Seagate Barracuda 7200 SATA and WD 160GB IDE
Sound Card
Onboard Realtek ALC883
Power Supply
CORSAIR CMPSU-750TX
Case
Chenming 901A
CPU cooling
Arctic Freezer 7 + Arctic Silver 5
GPU cooling
Stock Heatsink and fan
OS
Windows Vista Home Premium
Monitor
Hanns-G 22" LCD
xtascox is offline I fold for Overclock.net   Reply With Quote
Old 07-24-08   #2 (permalink)
Miscelaneous
 
Licht's Avatar
 
amd ati

Join Date: Mar 2007
Location: Bel Air
Posts: 9,933
Blog Entries: 3

Rep: 289 Licht is a proven memberLicht is a proven memberLicht is a proven member
Unique Rep: 188
Folding Team Rank: 904
Trader Rating: 0
Default

Windows will manage the thread affinity for you, or you can use kernel32.dll to force a thread to execute on a specific core. I recommend letting Windows handle it myself. Windows will chose : is it better to execute them both on this core, or on each core. Pending the work load it may be better to execute on only 1 core and let other programs use the remaining core. However that is unusual, in short : yes it will do this for you (most of the time.)

System: Uzicht #4
CPU
Athlon X2 5200+ Windsor
Motherboard
Gigabyte 790X AM2+
Memory
6GB Kingston DDR2 667MHZ
Graphics Card
Saphire HD 3870
Hard Drive
4x WD1600AAJS RAID0
Sound Card
X-Fi Extreme Gamer Fatality Professional
Power Supply
OCZ Game-X-Stream 700w
Case
NZXT Black Steel
CPU cooling
Xigmatec Rifle
GPU cooling
Stock Saphire 3870 Cooling
OS
Vista Home Premium x64 SP1
Monitor
Samsung SyncMaster 19"Wide
Licht is offline I fold for Overclock.net Overclocked Account Licht's Gallery   Reply With Quote
Old 07-24-08   #3 (permalink)
Programmer
 
xtascox's Avatar
 
intel nvidia

Join Date: Jul 2007
Location: Dallas, PA
Posts: 439

Rep: 20 xtascox is acknowledged by some
Unique Rep: 19
Folding Team Rank: 532
Trader Rating: 1
Default

Ok that works, thanks for the info!
__________________


System: SVT
CPU
Q6600 G0 @ 3.0ghz
Motherboard
Asus P5N-E SLI
Memory
4GB G. Skill
Graphics Card
2X EVGA 8800GTS 512
Hard Drive
160GB Seagate Barracuda 7200 SATA and WD 160GB IDE
Sound Card
Onboard Realtek ALC883
Power Supply
CORSAIR CMPSU-750TX
Case
Chenming 901A
CPU cooling
Arctic Freezer 7 + Arctic Silver 5
GPU cooling
Stock Heatsink and fan
OS
Windows Vista Home Premium
Monitor
Hanns-G 22" LCD
xtascox is offline I fold for Overclock.net   Reply With Quote
Old 07-24-08   #4 (permalink)
Every base is base 10
 
rabidgnome229's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Pittsburgh
Posts: 5,009
Blog Entries: 1

Rep: 566 rabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famous
Unique Rep: 338
FAQs Submitted: 6
Trader Rating: 5
Default

The scheduler will run whatever thread needs CPU time on whatever core is available when it decides to preempt the currently running thread. Every system has dozens of threads running at a time, and the OS will constantly (every few milliseconds or any time a blocking system call is made) switch between them. It isn't as simple as thread 1 runs on core 1, thread 2 runs on core 2, because there are many threads running and context switches are very frequent.

As a programmer you don't need to worry about any of that. You can manually control those things, but situations in which that would gain performance are few and far between
__________________
BIG BROTHER
Apple doesn't love you

IS WATCHING

System: It goes to eleven
CPU
E6300
Motherboard
DS3
Memory
2GB XMS2 DDR2-800
Graphics Card
EVGA 8600GTS
Hard Drive
1.294 TB
Sound Card
Audigy 2 ZS
Power Supply
Corsair 520HX
Case
Lian-Li v1000B Plus
CPU cooling
TTBT
GPU cooling
Thermalright V2
OS
Arch Linux/XP
Monitor
Samsung 226bw
rabidgnome229 is offline Overclocked Account   Reply With Quote
Old 07-25-08   #5 (permalink)
Programmer
 
xtascox's Avatar
 
intel nvidia

Join Date: Jul 2007
Location: Dallas, PA
Posts: 439

Rep: 20 xtascox is acknowledged by some
Unique Rep: 19
Folding Team Rank: 532
Trader Rating: 1
Default

Quote:
Originally Posted by rabidgnome229 View Post
The scheduler will run whatever thread needs CPU time on whatever core is available when it decides to preempt the currently running thread. Every system has dozens of threads running at a time, and the OS will constantly (every few milliseconds or any time a blocking system call is made) switch between them. It isn't as simple as thread 1 runs on core 1, thread 2 runs on core 2, because there are many threads running and context switches are very frequent.

As a programmer you don't need to worry about any of that. You can manually control those things, but situations in which that would gain performance are few and far between
Well I can't give out what the program actually does but I can say that it takes a series of calculations and comparisons that would normally take days, and splits it up, say, in half for a dual core system, so that one half of the calculations are handled in one thread and the second half is handled by the second thread.
__________________


System: SVT
CPU
Q6600 G0 @ 3.0ghz
Motherboard
Asus P5N-E SLI
Memory
4GB G. Skill
Graphics Card
2X EVGA 8800GTS 512
Hard Drive
160GB Seagate Barracuda 7200 SATA and WD 160GB IDE
Sound Card
Onboard Realtek ALC883
Power Supply
CORSAIR CMPSU-750TX
Case
Chenming 901A
CPU cooling
Arctic Freezer 7 + Arctic Silver 5
GPU cooling
Stock Heatsink and fan
OS
Windows Vista Home Premium
Monitor
Hanns-G 22" LCD
xtascox is offline I fold for Overclock.net   Reply With Quote
Old 07-25-08   #6 (permalink)
Miscelaneous
 
Licht's Avatar
 
amd ati

Join Date: Mar 2007
Location: Bel Air
Posts: 9,933
Blog Entries: 3

Rep: 289 Licht is a proven memberLicht is a proven memberLicht is a proven member
Unique Rep: 188
Folding Team Rank: 904
Trader Rating: 0
Default

Quote:
Originally Posted by xtascox View Post
Well I can't give out what the program actually does but I can say that it takes a series of calculations and comparisons that would normally take days, and splits it up, say, in half for a dual core system, so that one half of the calculations are handled in one thread and the second half is handled by the second thread.
Lol... so your making a multithreaded program basically?

System: Uzicht #4
CPU
Athlon X2 5200+ Windsor
Motherboard
Gigabyte 790X AM2+
Memory
6GB Kingston DDR2 667MHZ
Graphics Card
Saphire HD 3870
Hard Drive
4x WD1600AAJS RAID0
Sound Card
X-Fi Extreme Gamer Fatality Professional
Power Supply
OCZ Game-X-Stream 700w
Case
NZXT Black Steel
CPU cooling
Xigmatec Rifle
GPU cooling
Stock Saphire 3870 Cooling
OS
Vista Home Premium x64 SP1
Monitor
Samsung SyncMaster 19"Wide
Licht is offline I fold for Overclock.net Overclocked Account Licht's Gallery   Reply With Quote
Old 07-25-08   #7 (permalink)
Programmer
 
xtascox's Avatar
 
intel nvidia

Join Date: Jul 2007
Location: Dallas, PA
Posts: 439

Rep: 20 xtascox is acknowledged by some
Unique Rep: 19
Folding Team Rank: 532
Trader Rating: 1
Default

Quote:
Originally Posted by Licht View Post
Lol... so your making a multithreaded program basically?

__________________


System: SVT
CPU
Q6600 G0 @ 3.0ghz
Motherboard
Asus P5N-E SLI
Memory
4GB G. Skill
Graphics Card
2X EVGA 8800GTS 512
Hard Drive
160GB Seagate Barracuda 7200 SATA and WD 160GB IDE
Sound Card
Onboard Realtek ALC883
Power Supply
CORSAIR CMPSU-750TX
Case
Chenming 901A
CPU cooling
Arctic Freezer 7 + Arctic Silver 5
GPU cooling
Stock Heatsink and fan
OS
Windows Vista Home Premium
Monitor
Hanns-G 22" LCD
xtascox is offline I fold for Overclock.net   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 03:43 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.29487 seconds with 8 queries