peaceman
peaceman

Reputation: 1529

MPI parallel program execution on single computer

I want to run parallel codes on single pc with core i7 cpu I can compile my code but I have problem with running it.

I compile my code with mpicxx and when I run it by " mpirun -np 8 ./a.out" only one process is. My operating system is linux ubuntu 11.04.

Working what must I do?

For example I want to run this code:

#include <iostream>
#include <mpi.h>
using namespace std;

int main(int argc, char **argv)
{
    int mynode, totalnodes;
    MPI_Init(&argc,&argv);
    MPI_Comm_size(MPI_COMM_WORLD, &totalnodes);
    MPI_Comm_rank(MPI_COMM_WORLD, &mynode);
    cout << "Hello world from process " << mynode;
    cout << " of " << totalnodes << endl;
    MPI_Finalize();
}

I use mpich2 with mpirun --version:1.3.1

Upvotes: 5

Views: 8474

Answers (2)

user1285136
user1285136

Reputation:

If you use ubuntu operating system you can execute your codes with mpiexec -n 8 /path/to/application too and no machine file is required just be sure that you installed mpich library properly for doing this you can use synaptic package manager for installing library.

Upvotes: 2

akappa
akappa

Reputation: 10490

In your mpich2 version, it is encouraged to use mpiexec in lieu of mpirun.

To launch an application, you should write a machinefile with this syntax:

machine1[:number of cores]
...
machinen[:number of cores]

One line for each machine, with optionally the number of cores preceded by a colon, example:

node0:2
node1:3

You invoke then your application like that:

mpiexec -f machinefile -n <number of processes> yourapplication

Try it and tell us what you get.

Remember that, in the default configuration, mpich2 requires a loginless ssh configuration in order to launch the processes.

Upvotes: 2

Related Questions