![]() |
Department of
Mathematics and Computer Science |
|
math.scu.edu dsmolars
This file should have access mode 600. To make sure it has the
correct permissions, after saving the file, enter the system
command:
chmod 600 .rhosts
set path=( $path . )
out by putting a # as the first character in the line and
add the following line
set path=( $path /usr/local/lib/mpich/bin . )
If, however, your shell is bash or sh (i.e., Posix), edit your
.profile startup file in your root directory. Comment
the line
PATH=$PATH:.
out by putting a # as the first character in the line and
add the following line
PATH=$PATH:/usr/local/lib/mpich/bin:.
The options are
Using these compiler scripts will produce an a.out as is usual by default. Usually, a user will use the standard -o filename switch to produce a default executable with another filename. This executable file is not used by itself (although it will produce output). Instead, one uses a execution driver script, mpirun with an option -np indicating the number of "processors" one wishes to emulate. E.g.,
mpif90 for Fortran-90 source files mpif77 for Fortran-77 source files mpicc for C source files mpiCC for C++ source files
mpicc mpitest.c
mpirun -np 4 a.out
or
mpicc -o mpitest mpitest.c
mpirun -np 4 mpitest
/* synch_ex.c
*
* Illustrates the fact that sequences of broadcasts on different
* processes (that use the same communicator) are matched by
* their order.
*
* Input: None
* Output: Values of x and y on each process
*
* Note: Should be run with at least three processes.
*
* See pp. 72-73 of PPMPI.
*/
#include <stdio.h>
#include <unistd.h> /* needed for using the "sleep" function */
#include "mpi.h" /* needed to call MPI functions */
main(int argc, char* argv[]) {
int x = 0;
int y = 0;
int my_rank;
MPI_Init(&argc, &argv); /* this must be the first MPI function called */
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
/* this tells MPI all the processes running and
returns the number of the local process */
if (my_rank == 0) {
x = 5;
y = 10;
MPI_Bcast(&x, 1, MPI_INT, 0, MPI_COMM_WORLD);
MPI_Bcast(&y, 1, MPI_INT, 0, MPI_COMM_WORLD);
/* Local work (call to sleep isn't really needed) */
sleep(2);
} else if (my_rank == 1) {
/* Local work (call to sleep isn't really needed) */
sleep(2);
MPI_Bcast(&y, 1, MPI_INT, 0, MPI_COMM_WORLD);
MPI_Bcast(&x, 1, MPI_INT, 0, MPI_COMM_WORLD);
} else if (my_rank == 2) {
/* Local work (call to sleep isn't really needed) */
sleep(2);
MPI_Bcast(&x, 1, MPI_INT, 0, MPI_COMM_WORLD);
MPI_Bcast(&y, 1, MPI_INT, 0, MPI_COMM_WORLD);
}
printf("Process %d > x = %d, y = %d\n", my_rank, x, y);
MPI_Finalize(); /* this must be the LAST MPI function called */
}
math 21: script Script started on Fri Apr 28 21:34:37 2000 math 22: mpicc mpitest.c /usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (/usr/local/lib/mpich-1.2.0/lib/libmpich.a(initfcmn.o)) was detected. The linked output may not run on a PA 1.x system. math 23: mpirun -np 4 a.out Process 0 > x = 5, y = 10 Process 2 > x = 5, y = 10 Process 3 > x = 0, y = 0 Process 1 > x = 10, y = 5 math 24: exit exit script done on Fri Apr 28 21:35:37 2000
My email address is
dsmolarski@math.scu.edu
This page last updated 6 May 2000.