Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPI: cores or processors?

Tags:

Hi I am kind of MPI noob so please bear with me on this one. :)

Say I have an MPI program called foo.c and I run the executable with

mpirun -np 3 ./foo

Now this means the program will be run in parallel using 3 processors (1 process per processor). But since most processors today have more than one core, (take 2 cores per processor say) does this mean the program will be run on 3 cores or 3 processors?

Probably this has to do with my poor understanding of what the difference between a core and a processor really is so if you could also explain a little more that would be helpful.

Thank you.

like image 716
smilingbuddha Avatar asked Apr 26 '11 23:04

smilingbuddha


People also ask

Can MPI be run on a single processor?

So, if you have a single CPU single-core machine, you can still use MPI but (yes, you can run multi-process jobs on a single-cpu single-core machine...)

What is MPI in multicore processors?

The MPI library allows threads across multiple processors or computers to send messages among each other for communication and synchronization. This programming model is compatible with distributed memory multiprocessor systems as well as shared memory systems.

Which is better single-core or multi core performance?

A CPU that offers multiple cores may perform significantly better than a single-core CPU of the same speed. Multiple cores allow PCs to run multiple processes at the same time with greater ease, increasing your performance when multitasking or under the demands of powerful apps and programs.

How many MPI processes can I run?

It is almost never efficient to use more than about 4 MPI processes. If you are running a job with multiple structures, the number of threads and MPI processes that you specify are used for each structure.


2 Answers

mpirun will execute a number of "processes" on the machine. The cpu or core where these processes are executed is operating-system dependent. On a N cpu machines with M cores on each cpu, you have room for N*M processes running at full speed.

But, typically:

  • If you have multiple cores, each process will run on a separate core
  • If you ask for more processes than the available core*cpus, everything will run, but with a lower efficiency (yes, you can run multi-process jobs on a single-cpu single-core machine...)
  • If you are using a queuing system or a preconfigured MPI system for which a list of remote machines exists, the allocation will be distributed on the remote machines.

(Depending of the mpi implementation, there might be some options to force a specific cpu or core, but you should not need to worry about that).

like image 147
Blklight Avatar answered Sep 21 '22 04:09

Blklight


Distribution of processes to cores and processors is handled by the operating system and the MPI implementation. Running on a desktop, the operating system will generally put each process on a different core, potentially redistributing processes during run-time. In larger systems such a s a supercomputer or a cluster, the distribution is handled by resource managers such as SLURM. However this happens, one or multiple processes will be assigned to each core.

Regarding hardware, a core can run only a single process at a time. Technologies such as hyper-threading allows multiple processes to share the resources of a single core. There are cases where two or more processes per core is optimal. For instance, if a processes is doing a large amount of file I/O another may take its place and do computation while the first is hung on a read or write.

In short, give MPI the number of processes you want to execute. Distribution of these processes is then handled transparent to the user. The number of processes that you use should be determined by requirements of the application (powers of 2, number of files to be read), the number of cores available, and the optimal number of processes per core for the application.

like image 41
corahm Avatar answered Sep 21 '22 04:09

corahm