/*********************************************************** * * * Parallel Basic Linear Algebra Subroutines (PBLAS) mpicc.openmpi TS.c -lblacs-openmpi -lscalapack-openmpi -o TS mpirun.openmpi -np 4 ./TS * * * ***********************************************************/ #include #include #include #include "mpi.h" /*********************************************************** * Globals * ***********************************************************/ int N=10, ZERO=0, ONE=1;; main(int argc, char* argv[]) { int myid; /* process rank */ int p; /* number of processes */ int n, nb, i,j, i0; int ctxt, prow, pcol, myrow, mycol; /* BLACS stuff */ int descx[9], desca[9], info; int size = N * sizeof(double); double s, *x, **a; printf("avant size=%d\n", size); /* Start the MPI engine */ MPI_Init(&argc, &argv); /* Find out number of processes */ MPI_Comm_size(MPI_COMM_WORLD, &p); size = (size + p - 1)/p; printf("size=%d\n", size); x = (double*) malloc(size); a = (double**) malloc(size); /* Find out process rank */ MPI_Comm_rank(MPI_COMM_WORLD, &myid); /* Get a BLACS context */ Cblacs_get(0, 0, &ctxt); /* Initialize a 1-dimensional grid */ Cblacs_gridinit(&ctxt, "R", p, 1); Cblacs_gridinfo(ctxt, &prow, &pcol, &myrow, &mycol); nb = (N + p - 1)/p; /* nb = ceil(N/p) */ i0 = myid*nb; n = nb; if (myid == p-1) n = N - i0; for(i=0;i