/****************************************************************************** * FILE: mpi_hello.c * DESCRIPTION: * MPI tutorial example code: Simple hello world program * Original Source: https://computing.llnl.gov/tutorials/mpi/exercise.html#Exercise1 * How to Compile and Run @euclid.cyi.ac.cy: * from 103ws*.in.ucy.ac.cy copy source files to euclid like * scp mpi_hello.c epl655u03@euclid.cyi.ac.cy:~/epl372 * scp mpirun.sh epl655u03@euclid.cyi.ac.cy:~/epl372 * ssh epl655u03@euclid.cyi.ac.cy [epl655u03@euclid epl372]$ module load goolf/1.6.10 [epl655u03@euclid epl372]$ mpicc mpi_hello.c -o hello.out petrosp@103ws15:>scp mpirun.sh epl655u03@euclid.cyi.ac.cy:~/epl372/ [epl655u03@euclid epl372]$ sbatch mpirun.sh [epl655u03@euclid epl372]$ cat hello.output.out Hello from task 0 on e01! MASTER: Number of MPI tasks is: 16 Hello from task 1 on e01! Hello from task 2 on e01! Hello from task 4 on e01! Hello from task 7 on e01! Hello from task 9 on e02! Hello from task 5 on e01! Hello from task 6 on e01! Hello from task 11 on e02! Hello from task 13 on e02! Hello from task 15 on e02! Hello from task 8 on e02! Hello from task 3 on e01! Hello from task 12 on e02! Hello from task 10 on e02! Hello from task 14 on e02! ******************************************************************************/ #include "mpi.h" #include #include #define MASTER 0 int main (int argc, char *argv[]) { int numtasks, taskid, len; char hostname[MPI_MAX_PROCESSOR_NAME]; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &numtasks); MPI_Comm_rank(MPI_COMM_WORLD,&taskid); MPI_Get_processor_name(hostname, &len); printf ("Hello from task %d on %s!\n", taskid, hostname); if (taskid == MASTER) printf("MASTER: Number of MPI tasks is: %d\n",numtasks); MPI_Finalize(); }