/* ! ========================================================================= ! Print name of processor and size of communicator as seen by MPI rank 0 ! Then have every MPI process print its rank (use %3.3d for easy sorting) ! ! mpicc -xCORE-AVX512 -O3 mpi_hello.c -o mpi_hello ! mpirun ./mpi_hello | sort ! ! To run on multiple nodes of a TACC cluster: ! ibrun ./mpi_hello | sort ! ========================================================================= */ #include #include int main(int argc, char *argv[]){ int ierr, nranks, irank, namelen; char name[MPI_MAX_PROCESSOR_NAME]; ierr = MPI_Init(&argc, &argv); ierr = MPI_Comm_size(MPI_COMM_WORLD, &nranks ); ierr = MPI_Comm_rank(MPI_COMM_WORLD, &irank ); ierr = MPI_Get_processor_name( name, &namelen); if(irank==0){ printf(" 0> Hello from Xeon SP at processor %s\n", name); printf(" 0> Size of the MPI communicator is: %3d\n", nranks); } printf(" => Hello from MPI process %3.3d\n", irank); ierr = MPI_Finalize(); }