Some notes on Lab 1 =================== Exercise 1 1. Your modified version of mpiexample1.c should look like this: #include #include #include "mpi.h" int main( argc, argv ) int argc; char **argv; { int rank, size; char hostname[256]; MPI_Init( &argc, &argv ); MPI_Comm_size( MPI_COMM_WORLD, &size ); MPI_Comm_rank( MPI_COMM_WORLD, &rank ); gethostname(hostname, sizeof hostname); printf( "Hello world from process %d of %d on %s\n", rank, size, hostname ); MPI_Finalize(); return 0; } This should print something like: Hello world from process 0 of 1 executing on xe 2. Your code should now be executing on a numbered node of XE, for example: Hello world from process 0 of 4 executing on x23 Hello world from process 2 of 4 executing on x23 Hello world from process 3 of 4 executing on x23 Hello world from process 1 of 4 executing on x23 3. Your modified batch_job script should look something like: #PBS -q express #PBS -l walltime=00:00:10,vmem=4GB,ncpus=16 #PBS -wd mpirun -np 16 ./mpiexample1 cat $PBS_NODEFILE Exercise 2 4. *Timer overhead* is the length of time it takes to call the timer function. The total time to run your program will be increased by this value multiplied by the number of times you call the timer. *Timer resolution* is the period of time below which the timer will sometimes report a value of zero. It represents the smallest period that can accurately be measured by the timer. 5. For timers that operate like clocks (real time or CPU time), the differences represent the change in the value of the clock between each call. The overhead is the average of the reported differences. The lowest measured values will be integer multiples of the resolution. If the resolution is finer than the overhead, some of the measurements may be zero. 6. Example output: Total timings 124652 1 1 44 0 1 5 0 1 6 1 1 4 0 1 5 1 1 4 0 1 50 0 1 5 1 1 4 0 1 6 0 1 4 0 1 5 1 1 5 1 1 6 1 1 4 0 1 6 0 1 4 1 1 4 0 1 5 1 1 6 1 1 2 1 1 4 1 1 5 0 1 4 0 1 4 0 1 6 1 1 6 1 1 6 1 1 6 1 1 6 1 1 5 0 1 5 0 1 6 1 The smallest non-zero value is 1, so the resolution of the timer is 1us. There are several zero values, so the overhead of the timer is <1us. 7. The following code tests the resolution of MPI_Wtime(): double mpitime[ASIZE]; double t1, t2; ... i=0; icnt=0; while(i 0.0) i++; } printf("MPI_Wtime Total timings %d \n",icnt); for (i=0; i #include #include "mpi.h" #define ITERS 100 int main( argc, argv ) int argc; char **argv; { int rank, size, i, len; MPI_Status status; int *mbuf; double t1,t2,timeMean; MPI_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &rank ); MPI_Comm_size( MPI_COMM_WORLD, &size ); if (!rank){ printf(" Length Time(s) Bandwidth(MB/s)\n"); printf("----------------------------------------\n"); } for (len=1; len<=4*1024*1024; len*=4) { mbuf = malloc(len*sizeof(int)); t1 = MPI_Wtime(); for (i=0; i