#include "mpi.h" #include #include #define YES 1 #define NO 0 #define MILLION 100000000 #define ONEITEM 1 #define MPIHEAD 0 #define word long int commsize,myrank; #include "INC.MPI.tdecl.c" int main(int argc,char *argv[]) { word count,i; double x; double startwtime = 0.0, endwtime = 0.0; int namelen; char processor_name[MPI_MAX_PROCESSOR_NAME]; MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&commsize); MPI_Comm_rank(MPI_COMM_WORLD,&myrank); MPI_Get_processor_name(processor_name,&namelen); fprintf(stdout,"Process %d of %d on %s\n",myrank, commsize, processor_name); timecall("beginning",stdout,myrank); if(myrank == MPIHEAD) { startwtime = MPI_Wtime(); } x = 2.2; if(myrank <= commsize/2) count = (commsize/2-myrank+1)*MILLION; else count = (myrank+commsize/2)*MILLION; count /= 100; fprintf(stdout,"%2d:%2d: count=%ld\n", myrank,commsize,count); for(i = 1; i <= count; i++) { x = x * x * x * x; } if(myrank == MPIHEAD) { endwtime = MPI_Wtime(); printf("wall clock time = %f\n", endwtime-startwtime); } timecall("ending",stdout,myrank); MPI_Finalize(); return 0; }