![]() |
| | #1 |
| Registered User Join Date: Jan 2009
Posts: 156
| questions on multiple thread programming I can access a cluster with 8 CPUs, each of which has one core. I was wondering how many threads to create would get approximately best time performance on my cluster? Is it the same number of CPUs? If I am using multiple thread library like POSIX, will the library take care of which thread run on which CPU or do I have to specify this in my code? Thanks! |
| lehe is offline | |
| | #2 |
| Registered User Join Date: Sep 2004 Location: California
Posts: 2,845
| To get the best performance, create one thread per core. The library (or more specifically, the OS scheduler) will take care of which thread runs on which core. You don't need to worry about this. |
| bithub is offline | |
| | #3 | |
| CSharpener Join Date: Oct 2006
Posts: 5,242
| Quote:
plus you can have several IO threads for example which will most of the time spend in waiting state while io operation is been completed
__________________ If I have eight hours for cutting wood, I spend six sharpening my axe. | |
| vart is offline | |
| | #4 | ||
| Registered User Join Date: Sep 2004 Location: California
Posts: 2,845
| Quote:
Quote:
| ||
| bithub is offline | |
| | #5 | |
| CSharpener Join Date: Oct 2006
Posts: 5,242
| Quote:
several IO? because you can have a logger thread writign logs to file, db connection threads - requestion data from remote db server sochet thread - processing some network connection etc... it is too complicated to put all these task on one io thread
__________________ If I have eight hours for cutting wood, I spend six sharpening my axe. | |
| vart is offline | |
| | #6 |
| Registered User Join Date: Mar 2003
Posts: 3,844
| |
| Codeplug is offline | |
| | #7 | ||
| Registered User Join Date: Jan 2009
Posts: 156
| Thanks! Yes I remember people called my server "cluster". But how to check if it is distributed system and running a distributed OS providing SSI? And which shall I use, multi-threading or distributed-parallel programming? Here is the info of my server from uname: Quote:
Quote:
| ||
| lehe is offline | |
| | #8 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| That is one machine for all intents and purposes. -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. |
| matsp is offline | |
| | #9 |
| Registered User Join Date: Jan 2009
Posts: 156
| Hi Matsp, Thanks! From where did you tell it is not a distribution system? Does "cluster" only refer to distributed system? So I should stick to multi-threading programming? |
| lehe is offline | |
| | #10 | |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Quote:
-- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. | |
| matsp is offline | |
| | #11 |
| Registered User Join Date: Mar 2003
Posts: 3,844
| The term "cluster" implies more than one physical machine (PC). You have a single machine with 8 cores, so Posix "multi-threading" (with pthreads or processes) is appropriate in this case. >> I was wondering how many threads to create would get approximately best time performance on my cluster? The answer can depend on what you're doing, but a typical answer is one thread per core - as bithub and vart mentioned. >> will the library take care of which thread run on which CPU or do I have to specify this in my code? The typical answer is that you let your OS/library take care of this for you. gg |
| Codeplug is offline | |
| | #12 | |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Quote:
-- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. | |
| matsp is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multithreading (flag stopping a thread, ring buffer) volatile | ShwangShwing | C Programming | 3 | 05-19-2009 07:27 AM |
| Thread confusion | pyrolink | C Programming | 0 | 01-29-2006 09:42 PM |
| C++ Threading? | draggy | C++ Programming | 5 | 08-16-2005 12:16 PM |
| [code] Win32 Thread Object | Codeplug | Windows Programming | 0 | 06-03-2005 03:55 PM |
| injecting my own thread into the address space of another process - cannot call any f | Andrew_5342 | Windows Programming | 12 | 05-17-2003 05:58 AM |