/* ***************************************************************** C-DAC Tech Workshop : hyPACK-2013 October 15-18, 2013 Example 5.4: : mat_infnorm_blkstp.c Objective : Calculate Infinity Norm using block striped partitioning Input : Read file (infndata.inp) for Matrix Output : Process with rank 0 prints the value of Infinity Norm Necessary Condition : Number of Processes should be less than or equal to 8 Created : August-2013 E-mail : hpcfte@cdac.in *****************************************************************/ #include #include #include main(int argc, char** argv) { int Numprocs, MyRank; int NoofCols, NoofRows, ScatterSize; int index, irow, icol; int Root = 0; float **InputMatrix, *Buffer, *MyBuffer; float max=0, sum=0, Inf_norm=0; FILE *fp; int MatrixFileStatus = 1; /* ........MPI Initialisation .......*/ MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &MyRank); MPI_Comm_size(MPI_COMM_WORLD, &Numprocs); if(MyRank == 0) { /*.......Read the Matrix Input file ......*/ if((fp = fopen ("./data/infndata.inp", "r")) == NULL){ MatrixFileStatus = 0; } if( MatrixFileStatus != 0 ) { fscanf(fp, "%d %d\n", &NoofRows, &NoofCols); /* .......Allocate memory for matrix .....*/ InputMatrix = (float **) malloc(NoofRows*sizeof(float *)); for(irow=0; irow=0)?(MyBuffer[index]):(0-MyBuffer[index]); index++; } max = max=0)?(Buffer[index]):(0-Buffer[index]); index++; } max = max