I am doing some expensive caluations right now. It is one programm, which I run several instances of at the same time. I am running them under linux on a machine with 4 cpus with 6 cores each. The cpus are Intel Xeon X5660, which support hyper thearting. (That's some insane hardware, huh?) Right now I am running 24 processes at once. Would it be better to run more, b/c of HT ?
Without more information on your calculations it's going to be difficult, if not impossible, to give you a definitive answer. Even with this information there's a good chance any answer would be a guess.
You really need to do some timings/profiling of your solution. However, in the first instance you need to be able to configure the number of threads/processes you run at any one time.
Once you have this you can set up a scenario, run it and measure the result.
Repeat for different values and see which performs best.
Measuring first is a good idea, but you can also consider following:
- If the processes may block (particulary on IO), more of them is probably better.
- If the processes do a lot of math most of their time, you may take advantage of HyperThreading with more processes.
- On the other hand, if the processes have any shared state (memory or files), too much of them will increase contention and cache thrashing.
I was about to type almost exactly what Viktor wrote, so I have him +1 instead.
I would like to add that processes impose more overhead when there is a context switch than threads.
If your application architecture allows it, consider a single process with multiple threads or perhaps N processes with M threads each, where N and M are determined by benchmarking.