Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ... some libs and inits... */
- /* .......Variables Initialisation ......*/
- MPI_Status status;
- int n_size, NoofRows_Bloc, NoofRows, NoofCols;
- int Numprocs, MyRank, Root = 0;
- int irow, jrow, icol, index, ColofPivot, neigh_proc;
- double **Matrix_A, *Input_A, *Input_B, *ARecv, *BRecv;
- double *Output, Pivot;
- double *X_buffer, *Y_buffer;
- double *Buffer_Pivot, *Buffer_bksub;
- double tmp;
- /* ........MPI Initialisation .......*/
- MPI_Init(&argc, &argv);
- MPI_Comm_rank(MPI_COMM_WORLD, &MyRank);
- MPI_Comm_size(MPI_COMM_WORLD, &Numprocs);
- double time1;
- /* .......Read the Input file ......*/
- if(MyRank == 0) {
- srand(time(0));
- NoofRows = 500;
- NoofCols = 500;
- n_size=NoofRows;
- /* ...Allocate memory and read data .....*/
- Matrix_A = new double*[n_size];
- for(irow = 0; irow < n_size; irow++){
- Matrix_A[irow] = new double[n_size];
- for(icol = 0; icol < n_size; icol++)
- Matrix_A[irow][icol] = rand() % 10;
- }
- Input_B = new double[n_size];
- for (irow = 0; irow<n_size; irow++)
- Input_B[irow] = rand() % 10;
- /* ...Convert Matrix_A into 1-D array Input_A ......*/
- Input_A = new double[n_size * n_size];
- index = 0;
- for(irow=0; irow<n_size; irow++)
- for(icol=0; icol<n_size; icol++)
- Input_A[index++] = Matrix_A[irow][icol];
- time1 = realtime();
- }
- MPI_Barrier(MPI_COMM_WORLD); // Waiting for all processes
- MPI_Bcast(&NoofRows, 1, MPI_INT, Root, MPI_COMM_WORLD);
- MPI_Bcast(&NoofCols, 1, MPI_INT, Root, MPI_COMM_WORLD);
- /* .... Broad cast the size of the matrix to all ....*/
- MPI_Bcast(&n_size, 1, MPI_INT, 0, MPI_COMM_WORLD);
- NoofRows_Bloc = n_size/Numprocs;
- /*......Memory of input matrix and vector on each process .....*/
- ARecv = new double[NoofRows_Bloc * n_size];
- BRecv = new double[NoofRows_Bloc];
- /*......Scatter the Input Data to all process ......*/
- MPI_Scatter (Input_A, NoofRows_Bloc * n_size, MPI_DOUBLE, ARecv, NoofRows_Bloc * n_size,
- MPI_DOUBLE, 0, MPI_COMM_WORLD);
- MPI_Scatter (Input_B, NoofRows_Bloc, MPI_DOUBLE, BRecv, NoofRows_Bloc, MPI_DOUBLE, 0,
- MPI_COMM_WORLD);
- /* ... to be continued... */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement