LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   How does software know how to use Multiple CPU and Cores (http://www.linuxquestions.org/questions/linux-software-2/how-does-software-know-how-to-use-multiple-cpu-and-cores-850866/)

Ronayn 12-17-2010 08:35 AM

How does software know how to use Multiple CPU and Cores
 
I am writing a program that is computationally intensive. I have a serial version which runs on one machine, and a parallelized version that can run across several machines (reducing the processing time).

Does the OS handle (intelligently) splitting my application between CPU's and Cores -- or is that something I have to program into my code?

Are there any books explaining how apps are handled on multiple CPU/Core systems?


This is the info for the machine(s) I am working on:
HP Proliant DL380 G5. 2 Dual Core Intel Xeon Processors (3.00 GHz / 1333MHz, 4MB L2 Cache) with 8GB memory, Fedora Core 6 Operating System, running Linux Kernel 2.6.20-1.2948.fc6.

bpogi 12-17-2010 09:24 AM

You have to write threaded applications, basically. I don't know the specifics of what your program does or even what language it's in, but if you write it with the appropriate threading routines and libraries and, if you have enough threads, the OS (if it is multi-core capable) will make use of all the available processor cores.

hyperfluid 12-17-2010 09:31 AM

When you say you have got a parallelized version, it sounds like you already use methods like multi-threading (e.g. via pthread) or MPI. If you do so, the OS will do the rest.

Ronayn 12-20-2010 05:12 AM

Quote:

Originally Posted by hyperfluid (Post 4194788)
When you say you have got a parallelized version, it sounds like you already use methods like multi-threading (e.g. via pthread) or MPI. If you do so, the OS will do the rest.

Yes, I am using C/C++, threads, and MPI. It's just that I was using all that before multi-core/multi-cpu systems came out -- and I thought that there had to be something the programmer had to do in order to take advantage of that tech. But hey, if the OS does it, I am good with that! It means no source code changes for me! YaY!

syg00 12-20-2010 05:36 AM

Multi-threaded code that isn't designed to be multi-processor safe isn't.
Lots of appalling code runs just fine on one processor - because concurrency and race conditions don't come into play. Parallelism (on different machines) doesn't necessarily change this.


All times are GMT -5. The time now is 08:16 AM.