I’m supposed to send some integer number from one processor to another, and it is to be done on shell server from my university…
First I created my solution code, which is going to look like (at least I think so…)
#include <stdio.h>
#include <mpi.h>
int main(int argc, char **argv)
{
int currentRank = -1;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, ¤tRank);
if(currentRank == 0) {
int numberToSend = 1;
MPI_Send(&numberToSend , 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
}
else if(currentRank == 1) {
int recivedNumber;
MPI_Recv(&recivedNumber, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
printf("Recived number = %d\n", recivedNumber);
}
MPI_Finalize();
return 0;
}
Than I should create some name.pbs file… and run it. And I can’t understand how to specify this number of processors… I tried like follow:
#PBS -l nodes=2:ppn=2
#PBS -N cnt
#PBS -j oe
mpiexec ~/mpi1
But later on still have no idea what to do with this on putty. qstat comamnd seems to do nothing… only when qstat -Q or q it shows me some ‘statistics’ but there are 0 values everywhere… it’s my first program in mpi and I really don’t understand it at all…
And when I try to run my program I get:
164900@halite:~$ ./transfer1
Fatal error in MPI_Send: Invalid rank, error stack:
MPI_Send(174): MPI_Send(buf=0x7fffd28ec640, count=1, MPI_INT, dest=1, tag=0, MPI_COMM_WORLD) failed
MPI_Send(99).: Invalid rank has value 1 but must be nonnegative and less than 1
Can anyone explain me how to run this on the server ?
the example code works fine here, tested with OpenMPI and GCC,
the problem is that when you run the code you need to specific the number of cores via your mpirun instance, you may havecorrectly allocated them using torque or what ever scheduler you are using but you are running the compiled code as if it were serial you need to run it with mpi heres and example with the associated output
with different scheduler hydra,PBS, or different MPI version you need to follow the same pattern as above and specific to your mpi run command the number of cores