I've built my first cluster in VirtualBox out of 4 installs of CentOS 6. I'm using OpenMPI and an NFS share hosted from the master node "node0". I've been able to run...
Code:
mpdboot -n 4

mpdtrace -l

#output
node0_40635 (192.168.2.1)
node1_55356 (192.168.2.2)
node2_42638 (192.168.2.3)
node3_32958 (192.168.2.4)
then...
Code:
mpiexec -n 4 mpptest -n 4 -memcpy 4 -auto

#Lots of output
... the result is satisfying. I see output and a spike of activity on all 4 nodes. If I run...
Code:
mpiexec -n 4 hostname

#output
node2
node1
node3
node0
So clearly it works, but not always the way I expected. For instance, I've noticed if I do...
Code:
mpiexec -n 4 echo $HOSTNAME
I get...
Code:
node0
node0
node0
node0
I'm guessing this is just related to how environment variables are passed to nodes, which is fine. My biggest concern is when I tried to run a simple C program. Here's my code:
Code:
#include <mpi.h>
#include <stdio.h>

int main(int argc, char ** argv){
    int rank,size;
    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD,&rank);
    MPI_Comm_size(MPI_COMM_WORLD,&size);
    printf("MPI hello from process &#37;d of %d\n",rank,size);
    MPI_Finalize();
    return 0;
}
It compiles and runs just fine, but the output is...
Code:
MPI hello from process 0 of 1
MPI hello from process 0 of 1
MPI hello from process 0 of 1
MPI hello from process 0 of 1
As far as I know, this is the simplest code for getting process rank. I'm expecting it to read "n of 4." What am I doing wrong?