5

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

7
  • you should tell us what version of MPI you are running. Commented Oct 12, 2011 at 15:10
  • Also what VERSION of mpich2 you are using. They changed process manager from MPD to Hydra between version 1.2 and 1.3, so details about how to launch a parallel application changes. You can see it running mpirun --version. Commented Oct 12, 2011 at 15:16
  • "Suppose"? Meh, you have this problem on your particular version. In the latest version, you should use mpiexec and a properly-defined machinefile. Commented Oct 12, 2011 at 15:19
  • There are some alternatives: you can use a backport, grab the latest package from the "experimental" branch of your distribution and install it by hand or by configuring the package manager or, simply, you compile it from the distribution source package. However, this is a question which should be posed individually and, maybe, in a different Q&A site. Commented Oct 12, 2011 at 15:26
  • What exactly happens when you try to run it as above? Commented Oct 12, 2011 at 15:41

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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.

4 Comments

I dont know how can I write machine file
For your simple case, you want a file named machinefile with the single line localhost:8. Then run mpiexec -f machinefile -n 8 /path/to/application arguments.
now I have compile problem .the error is usr/bin/ld :cannot find -lcr collect2:ld returned 1 exit status process manager worked but compiler now do not work!
this is a Q&A site, not a "we make your stuff work" one. Ask each question separately.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.