Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I have a 4-core workstation, what would linux (Ubuntu) do if I execute

mpirun -np 9 XXX

Q1. Will 9 run immediately together, or they will run 4 after 4?

Q2. I suppose that using 9 is not good, because the remainder 1, it will make the computer confused, (I don't know is it going to be confused at all, or the "head" of the computer will decide which core among the 4 cores will be used?) Or it will be randomly picked. Who decide which one core to call?

Q3. If I feel my cpu is not bad and my ram is okay and large enough, and my case is not very big. Is it a good idea in order to fully use my cpu and ram, that I do mpirun -np 8 XXX, or even mpirun -np 12 XXX.

Q4. Who decides all of these effciency optimization, Ubuntu, or linux, or motherboard or cpu?

Your enlightenment would be really appreciated.

share|improve this question
up vote 3 down vote accepted
  1. 9 will run simultaneously.
  2. There is no confusion for the remaining 1 process; mpirun schedules in round-robin order by default, so the 1st core/node will be assigned that process.
  3. You can certainly increase np beyond the number of available physical cores/nodes. The tradeoff is that the overhead increases with a larger number of processes than cores/nodes. If your code is not tightly CPU-bound (e.g. requires significant IO wait time), you should do this. Ultimately, you don't know if it will be faster until you try.
  4. MPI does the initial scheduling, but for more than one process per node, or just in general (since there are a number of other processes running in the background too), the Linux kernel scheduler takes over.

See this man page for much more information.

share|improve this answer

9 immediatly.

If not, the universe's size will be incorrect. All the processes must exist at the same time or won't be visible for the other instances.

If your instance's memory is too high you can manually stop the other 5 processes until the other 4 have finished tho.

However, if you're using MPI in that way ( only for your local machine ), let me recommend you OpenMP/tbb instead. MPI is really designed to distribute the app across multiple network computers or cluster nodes.

share|improve this answer
Can I just openmp -np 8 XXX, or tbb -np 8 XXX? Or do I need to modify the code itself? How to decide using 8 or 12. Thanks! – Daniel May 30 '12 at 22:02

Yes, you would need to modify the code significantly to turn it from an MPI application to an OpenMP or TBB application. If your application has already been developed, try it and make performance measurements before doing anything that drastic.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.