|
|
|||||||
| About Us | Register | FAQ | Members List | Calendar | Mark Forums Read |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Eric Cartmenez
![]() ![]() ![]() Join Date: Jul 2006
Location: Brazil
Posts: 357
|
Well,
I've been searching for understanding about distributed computation. So I saw some interesting therms: Process and Thread. Both are almost the same thing, except by, process is composite by one or more threads, create process is more expensive (for hardware) than a thread. Reading this things I had the impression that only the Process could use a "new" multicore feature(CPU). Question: If I dev a program that creates multiThread for many task, my program will take the advantage of multi-core? Or it will used just when I creat one process for each task (sub-rotine, method, function, whatever) Just developer an application with many thread/process my application will use the feature multicore? ps: I know is not "just" dev system with so many task,,, you need to manage it and this is hard... Last edited by dreampeppers99; May 20th, 2008 at 17:11. Reason: bad english, miss word |
|
|
|
|
|
#4 (permalink) |
|
PCSX3 Coder
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Oct 2007
Location: Maryland, where the big boys play.
Posts: 3,093
|
well first things first. multi threading does not equate to multi core. to code a program with multi core, you have to write instructions for each of the execution cores (which is a pain to do)
__________________
Antec P182 Special Edition (Chrome Finish) : Intel e8400 : Thermaltake ToughPower 650 watt PSU : Corsair Dominater DHX 1066 DDR2 Ram : Asus P5K : 500 Gb Seagate : 74 GB Raptor : Samsung 20x DVD optical Drive : Samsung Syncmaster T220 22" LCD : Windows 95 : XFX 8800gt ![]() Cooling: Swiftech Apogee GTX Special Edition (Copper Finish) : Feser X-Changer Dual 120mm Radiator : XSPC Bay Resevoir : Danger den Chrome Barbs : Feser UV anti kink 1/2" ID tubing : Danger Den D5 |
|
|
|
|
|
#5 (permalink) |
|
NGemu's Kawaii Imoutochan
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Sep 2007
Location: Super Mario World
Posts: 2,549
|
nah, actually phil, multi-threading does allow the different cores of the CPU to be used.
an application usually runs in 1 process who's priority is handled by the OS, and the application can set up functions that run in their own threads. the difference between threads and processes is that a process is independant from other processes, and a thread is used if there will be communication between other threads. a thread can use the same variables another thread is using if its part of the same process. heres more information since i'm too tired to explain anymore Threads vs. Processes i'll be honest, i'm not an expert on multi-threading, i've only written a few programs that use threads. but the art of multi-threading and taking advantage of multiple CPU cores isn't like, Code:
use core 0 for function 1; use core 1 for function 2; Code:
make a thread for function 1; make a thread for function 2;
__________________
PC Specs: AMD X2 4400+ @ 2.921 Ghz, 1.47 vCore | G92 8800 GTS 512mb @ 740/1944| 4GB Dual Channel OCZ Memory @ 835 Mhz (5-4-4-15-2T) | 700 Watt PSU | DVD-RW Drive | 500 GB Hitachi SATA II Hard Drive, 30 GB & 40 GB Western Digital IDE Hard Drives | 1920x1080 40" LCD Flat Pannel HDTV monitor | Consoles: 1 PS3 (60 GB), 2 PS2s, 1 PS, 3 GBAs, 1 GB, and 1 old school NES Having troubles with PCSX2? Check out my guide to get it running correctly. Running PCSX2 Guide for Noobs ![]() Last edited by cottonvibes; May 21st, 2008 at 05:43. |
|
|
|
|
|
#6 (permalink) | |
|
Emu author
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Feb 2007
Location: Wuzzleberg
Posts: 1,356
|
Quote:
You can pragmatically specify which cores threads run on. Research SetThreadAffinityMask().
__________________
"Software is getting slower more rapidly than hardware becomes faster......" -Niklaus Wirth |
|
|
|
|
|
|
#7 (permalink) |
|
PCSX3 Coder
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Oct 2007
Location: Maryland, where the big boys play.
Posts: 3,093
|
exactley: like i said....if you want true optimization, you must assign specific code to each core
like Core 0: specific action Core 1: specific action Core 2: specific action Core 3: specific action anyway wheres mud? he knows this stuff better then both of us ![]() Edit: Beat me to it lol
__________________
Antec P182 Special Edition (Chrome Finish) : Intel e8400 : Thermaltake ToughPower 650 watt PSU : Corsair Dominater DHX 1066 DDR2 Ram : Asus P5K : 500 Gb Seagate : 74 GB Raptor : Samsung 20x DVD optical Drive : Samsung Syncmaster T220 22" LCD : Windows 95 : XFX 8800gt ![]() Cooling: Swiftech Apogee GTX Special Edition (Copper Finish) : Feser X-Changer Dual 120mm Radiator : XSPC Bay Resevoir : Danger den Chrome Barbs : Feser UV anti kink 1/2" ID tubing : Danger Den D5 |
|
|
|
|
|
#8 (permalink) | ||
|
NGemu's Kawaii Imoutochan
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Sep 2007
Location: Super Mario World
Posts: 2,549
|
Quote:
like i said, i've only used threads a few times in code, didn't know you can choose the core it runs on. i guess thats what PCSX2 does when you select the "Dual Core Mode" option. Quote:
think about if a user is running your multi-threaded application, and hes also watching a video in windows media player. say WMP takes up ~99% of core 0's processing time, and core 1 is idle using ~1% of its processing power. say you told your application to use core 0 to do one thing, and core 1 to do another thing. since core 0 is being used at 99%, the application will take forever. but had you let windows choose what core to use, then it would have set both threads to use core 1, and then the application would most-likely run faster.
__________________
PC Specs: AMD X2 4400+ @ 2.921 Ghz, 1.47 vCore | G92 8800 GTS 512mb @ 740/1944| 4GB Dual Channel OCZ Memory @ 835 Mhz (5-4-4-15-2T) | 700 Watt PSU | DVD-RW Drive | 500 GB Hitachi SATA II Hard Drive, 30 GB & 40 GB Western Digital IDE Hard Drives | 1920x1080 40" LCD Flat Pannel HDTV monitor | Consoles: 1 PS3 (60 GB), 2 PS2s, 1 PS, 3 GBAs, 1 GB, and 1 old school NES Having troubles with PCSX2? Check out my guide to get it running correctly. Running PCSX2 Guide for Noobs ![]() Last edited by cottonvibes; May 21st, 2008 at 06:10. Reason: Automerged Doublepost |
||
|
|
|
|
|
#9 (permalink) |
|
PCSX3 Coder
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Oct 2007
Location: Maryland, where the big boys play.
Posts: 3,093
|
you mean "offloading"
hmmm i hear Nehalem will be stronger in that regard..
__________________
Antec P182 Special Edition (Chrome Finish) : Intel e8400 : Thermaltake ToughPower 650 watt PSU : Corsair Dominater DHX 1066 DDR2 Ram : Asus P5K : 500 Gb Seagate : 74 GB Raptor : Samsung 20x DVD optical Drive : Samsung Syncmaster T220 22" LCD : Windows 95 : XFX 8800gt ![]() Cooling: Swiftech Apogee GTX Special Edition (Copper Finish) : Feser X-Changer Dual 120mm Radiator : XSPC Bay Resevoir : Danger den Chrome Barbs : Feser UV anti kink 1/2" ID tubing : Danger Den D5 |
|
|
|
|
|
#10 (permalink) | ||
|
Eric Cartmenez
![]() ![]() ![]() Join Date: Jul 2006
Location: Brazil
Posts: 357
|
First thanks so much dude,
I always think that way. Quote:
Quote:
I prefer let the OS choose this too.
__________________
OS: Windows XP Professional SP2 (32bits) CPU: Athlon XP 2400+ (2.0 Ghz) Graphics Card: ATI X1650 Pro 512MB Memory: 1GB DDR |
||
|
|
|
|
|
#11 (permalink) |
|
War Games coder
![]() ![]() ![]() ![]() ![]() Join Date: Apr 2001
Location: Florida
Posts: 1,918
|
In general, you will get much better performance if you let the OS decide which core or CPU to run on. It also makes coding a bit easier as you simply don't have to worry about it.
For most developers, threading was simply a methodology of being able to do stuff while I/O was going on... it was always flawed, but it was all they could see because they never owned or had access to multi-CPU machines. On a single-CPU/core machine, that's really all that threading does for you. On the other hand... things just don't work that way any more. Hardly anyone has a single-core machine. Consequently, you can now use threading to do simultaneous non-I/O related tasks that are truly simultaneous (as long as the data they're working on fits in the cache of the core they're working on, or cache updates never happen simultaneously). At any rate, back to the original point, in general the OS does a good job of distributing active threads across idle CPUs. Some OS's do a much better job of this (Sun, for example... been doing large CPU arrays for decades)... and this is one of the few things that at an OS level, MS does better than linux (linux does not support threads, only LWPs (Light-Weight Processes) masquerading as threads).
__________________
Primary CPU: Athlon 64 X2 4400+ Mobo: Biostar N4SLI-A9 RAM: 2G Crucial (DDR400) Video: eVGA GeForce 7900 GTX (512M) Audio: HDA X-Mystique HD(s): Maxtor 300G SATA2, Samsung 400G SATA2 OS(s): WinXP x64 Pro, Vista x32 Ultimate, Gentoo x64 Monitor(s): Primary - 19" Flat Panel (1280x1024) Secondary - 19" Flat Panel (1280x1024) Tertiary - Zenith 42" Plasma TV (1024x768 res) Many other machines... sig too short |
|
|
|
|
|
#12 (permalink) | ||||
|
Google-translated
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Nov 2006
Location: Santa Cruz, CA
Posts: 3,383
|
Quote:
Quote:
Quote:
Quote:
__________________
My best friend: Kopu: Asus Eee PC 701 Next best friend: Gamu CPU: Intel Core 2 Duo E7200 @ 3.80GHz RAM: 2GB of DDR2 800MHz (brandless, and brainless) GPU: ATI Radeon HD 4850 @ 800/1100 Good for PCSX2: overclock, overclock, and even more overclock. |
||||
|
|
|
|
|
#13 (permalink) | |
|
Emu author
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Feb 2007
Location: Wuzzleberg
Posts: 1,356
|
Quote:
__________________
"Software is getting slower more rapidly than hardware becomes faster......" -Niklaus Wirth |
|
|
|
|
|
|
#14 (permalink) | |
|
NGemu's Kawaii Imoutochan
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Sep 2007
Location: Super Mario World
Posts: 2,549
|
Quote:
well i wasn't sure because lots of times windows limits the control of the programmer to prevent problems. for instance, in PCSX2, the VM hack of it uses some way to bypass Window's OS layer and directly accesses the memory; which windows dosn't usually allow. i was thinking if the coder personally assigns the core the thread should be run on, then it might conflict with something windows is doing or something... plus, i've only done threads in java. And i'm not sure if theres a way to manually assign a thread to a core in Java.
__________________
PC Specs: AMD X2 4400+ @ 2.921 Ghz, 1.47 vCore | G92 8800 GTS 512mb @ 740/1944| 4GB Dual Channel OCZ Memory @ 835 Mhz (5-4-4-15-2T) | 700 Watt PSU | DVD-RW Drive | 500 GB Hitachi SATA II Hard Drive, 30 GB & 40 GB Western Digital IDE Hard Drives | 1920x1080 40" LCD Flat Pannel HDTV monitor | Consoles: 1 PS3 (60 GB), 2 PS2s, 1 PS, 3 GBAs, 1 GB, and 1 old school NES Having troubles with PCSX2? Check out my guide to get it running correctly. Running PCSX2 Guide for Noobs ![]() |
|
|
|
|
|
|
#15 (permalink) |
|
Atari 2600 > PS3/360/Wii
![]() ![]() ![]() ![]() Join Date: Aug 2006
Location: A crappy state in a crappy country
Posts: 890
|
Not to go too off topic, but if you design an application that is expressly designed to use multicore, and contains no code for what to do if the end user has a single core, how would this be handled? Would it just use threads?
I'm not a programmer, but this kind of interests me.
__________________
![]() Intel Core 2 Quad Q6600 @ 3.4GHz , 4GB Kingston DDR2-1066 , EVGA GeForce 9600GT 512MB Superclocked , 320GB Seagate Barracuda, Realtek ALC662, Rosewill 850 Watt,Windows XP X64 / Windows Vista Ultimate X64 17" Dell CRT Monitor Last edited by BigIg; May 22nd, 2008 at 01:13. |
|
|
|
|
|
#16 (permalink) | |
|
NGemu's Kawaii Imoutochan
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Sep 2007
Location: Super Mario World
Posts: 2,549
|
Quote:
if you specifically programmed it to run on 2 cores, then most-likely you would code the application to say something like "Error: Single-core detected" and then exit out if the user only has a single-core CPU. but if you use threads, and don't tell windows to specifically have the threads run on 2 different cores, than the program will still work. however, it's behavior could be pretty odd. this is because Window's will decide how much CPU time to give each thread. And it might not give them both 50-50, it might give one of the threads 90% CPU power and the other ~10%. heres a perfect example. I was looking at some code for a cell-phone game. and the author had the character animation being done in 1 thread, and the game logic done in another thread. when i ran the code on my cell-phone, which only has 1 CPU, the animation wasn't fluent at all, and it lagged. then i re-coded the code to have both the animation and the game logic be done in just 1 thread, and the animation was nice and in-sync. so its usually not a good idea to have code in threads, if you're on a single-cored CPU. (well at least from my experience )
__________________
PC Specs: AMD X2 4400+ @ 2.921 Ghz, 1.47 vCore | G92 8800 GTS 512mb @ 740/1944| 4GB Dual Channel OCZ Memory @ 835 Mhz (5-4-4-15-2T) | 700 Watt PSU | DVD-RW Drive | 500 GB Hitachi SATA II Hard Drive, 30 GB & 40 GB Western Digital IDE Hard Drives | 1920x1080 40" LCD Flat Pannel HDTV monitor | Consoles: 1 PS3 (60 GB), 2 PS2s, 1 PS, 3 GBAs, 1 GB, and 1 old school NES Having troubles with PCSX2? Check out my guide to get it running correctly. Running PCSX2 Guide for Noobs ![]() |
|
|
|
|
|
|
#17 (permalink) | |
|
Atari 2600 > PS3/360/Wii
![]() ![]() ![]() ![]() Join Date: Aug 2006
Location: A crappy state in a crappy country
Posts: 890
|
Quote:
![]()
__________________
![]() Intel Core 2 Quad Q6600 @ 3.4GHz , 4GB Kingston DDR2-1066 , EVGA GeForce 9600GT 512MB Superclocked , 320GB Seagate Barracuda, Realtek ALC662, Rosewill 850 Watt,Windows XP X64 / Windows Vista Ultimate X64 17" Dell CRT Monitor |
|
|
|
|
|
|
#18 (permalink) | |
|
NGemu's Kawaii Imoutochan
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Sep 2007
Location: Super Mario World
Posts: 2,549
|
Quote:
you'll need alot of patience to get to the point of learning multi-threaded programming, since its usually taught after you've learned the programming basics. anyways, programming is fun once you're familiar with it... but i find learning it to be kindoff boring; especially since lots of programming books are written in such a boring way, and make you code stupid applications just to learn how to use a programming concept.
__________________
PC Specs: AMD X2 4400+ @ 2.921 Ghz, 1.47 vCore | G92 8800 GTS 512mb @ 740/1944| 4GB Dual Channel OCZ Memory @ 835 Mhz (5-4-4-15-2T) | 700 Watt PSU | DVD-RW Drive | 500 GB Hitachi SATA II Hard Drive, 30 GB & 40 GB Western Digital IDE Hard Drives | 1920x1080 40" LCD Flat Pannel HDTV monitor | Consoles: 1 PS3 (60 GB), 2 PS2s, 1 PS, 3 GBAs, 1 GB, and 1 old school NES Having troubles with PCSX2? Check out my guide to get it running correctly. Running PCSX2 Guide for Noobs ![]() |
|
|
|
|