开发者

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 " << m开发者_如何学Pythonynode;
    cout << " of " << totalnodes << endl;
    MPI_Finalize();
}

I use mpich2 with mpirun --version:1.3.1


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜