Note that there are some explanatory texts on larger screens.

plurals
  1. POcholesky decomposition ScaLapack error
    primarykey
    data
    text
    <p>I'm getting the following error and i'm not sure why.</p> <pre><code>{ 1, 1}: On entry to PDPOTRF parameter number 2 had an illegal value { 1, 0}: On entry to PDPOTRF parameter number 2 had an illegal value { 0, 1}: On entry to PDPOTRF parameter number 2 had an illegal value { 0, 0}: On entry to PDPOTRF parameter number 2 had an illegal value info &lt; 0: If the i-th argument is an array and the j-entry had an illegal value, then INFO = -(i*100+j), if the i-th argument is a scalar and had an illegal value, then INFO = -i. </code></pre> <p>I Know what the error messages means but I followed the dated documentation available on the web as best as possible and tried to piece together a parallel cholesky factorization from working example codes on the web. I'm not sure where I went wrong.</p> <p>Could some one explain where I went wrong in the code below? Here's an overview of what the code does, I'm testing with 4 processors and divide the 8x8 matrix into 2 x 2 processor block grid loads a matrix from file, heres an example 8 x 8 matrixfile , </p> <pre><code>182 147 140 125 132 76 126 157 147 213 185 150 209 114 166 188 140 185 232 129 194 142 199 205 125 150 129 143 148 81 104 150 132 209 194 148 214 122 172 189 76 114 142 81 122 102 129 117 126 166 199 104 172 129 187 181 157 188 205 150 189 117 181 259 </code></pre> <p>I followed examples to distribute the Matrix to 4 separate 4x4 local arrays one on each of the 4 nodes. I then run <code>descinit_</code> and call the associated <code>pdpotrf_</code> routine which yields the above error. I have no idea where i went wrong and tried to follow documentation as best as I could. A working example of a parallel cholesky decomposition in fortran would also greatly help </p> <p><strong>References for function calls</strong></p> <p><a href="http://www.netlib.org/scalapack/explore-html/d5/d9e/pdpotrf_8f_source.html" rel="nofollow noreferrer">pdpotrf_</a></p> <p><a href="http://www.netlib.org/scalapack/explore-html/dd/d22/descinit_8f_source.html" rel="nofollow noreferrer">descinit_</a></p> <p><strong>Run Parameters</strong></p> <pre><code>code name - Meaning = Value N - Global Rows = 8 M - Global Cols = 8 Nb - Local Block Rows = 2 Mb - Local Block Cols = 2 nrows - Local Rows = 4 ncols Local Cols= 4 lda - Leading dimension of local array = 4 (i've tried 2,4,8) ord - Order of Matrix = 4 (i've also tried many different things here as well) </code></pre> <p>I Printed the above parameters on every node and they are the same</p> <pre><code>#include &lt;mpi.h&gt; #include &lt;iostream&gt; #include &lt;iomanip&gt; #include &lt;string&gt; #include &lt;fstream&gt; #include &lt;iostream&gt; #include &lt;stdlib.h&gt; #include &lt;sstream&gt; using namespace std; /* To compile: mpic++ test.cpp -o test -L/home/admin/libs -lscalapack -lrefblas -ltmg -lreflapack -lgfortran -Wall -O2 To run: mpirun -np 4 ./test matrixfile 8 8 2 2 */ extern "C" { /* Cblacs declarations */ void Cblacs_pinfo(int*, int*); void Cblacs_get(int, int, int*); void Cblacs_gridinit(int*, const char*, int, int); void Cblacs_gridinfo(int, int*, int*, int*,int*); void Cblacs_pcoord(int, int, int*, int*); void Cblacs_gridexit(int); void Cblacs_barrier(int, const char*); void Cdgerv2d(int, int, int, double*, int, int, int); void Cdgesd2d(int, int, int, double*, int, int, int); int numroc_(int*, int*, int*, int*, int*); void pdpotrf_(char*, int*, double*, int*, int*, int*, int*); void descinit_( int *, int *, int *, int *, int *, int *, int *, int *, int *, int *); } int main(int argc, char **argv){ /* MPI */ int mpirank,nprocs; MPI_Init(&amp;argc, &amp;argv); MPI_Comm_rank(MPI_COMM_WORLD, &amp;mpirank); MPI_Comm_size(MPI_COMM_WORLD, &amp;nprocs); double MPIelapsed; double MPIt2; double MPIt1; /* Helping vars */ int iZERO = 0; int verbose = 1; bool mpiroot = (mpirank == 0); if (argc &lt; 6) { if (mpiroot) cerr &lt;&lt; "Usage: matrixTest matrixfile N M Nb Mb" &lt;&lt; endl &lt;&lt; " N = Rows , M = Cols , Nb = Row Blocks , Mb = Col Blocks " &lt;&lt; endl; MPI_Finalize(); return 1; } /* Scalapack / Blacs Vars */ int N, M, Nb, Mb; int descA[9]; int info = 0; // int mla = 4; int ord = 8; double *A_glob = NULL, *A_glob2 = NULL, *A_loc = NULL; /* Parse command line arguments */ if (mpiroot) { /* Read command line arguments */ stringstream stream; stream &lt;&lt; argv[2] &lt;&lt; " " &lt;&lt; argv[3] &lt;&lt; " " &lt;&lt; argv[4] &lt;&lt; " " &lt;&lt; argv[5]; stream &gt;&gt; N &gt;&gt; M &gt;&gt; Nb &gt;&gt; Mb; /* Reserve space and read matrix (with transposition!) */ A_glob = new double[N*M]; A_glob2 = new double[N*M]; string fname(argv[1]); ifstream file(fname.c_str()); for (int r = 0; r &lt; N; ++r) { for (int c = 0; c &lt; M; ++c) { file &gt;&gt; *(A_glob + N*c + r); } } /* Print matrix */ if(verbose == 1) { cout &lt;&lt; "Matrix A:\n"; for (int r = 0; r &lt; N; ++r) { for (int c = 0; c &lt; M; ++c) { cout &lt;&lt; setw(3) &lt;&lt; *(A_glob + N*c + r) &lt;&lt; " "; } cout &lt;&lt; "\n"; } cout &lt;&lt; endl; } } /* Begin Cblas context */ int ctxt, myid, myrow, mycol, numproc; //&lt;TODO&gt; make dynamic int procrows = 2, proccols = 2; Cblacs_pinfo(&amp;myid, &amp;numproc); Cblacs_get(0, 0, &amp;ctxt); Cblacs_gridinit(&amp;ctxt, "Row-major", procrows, proccols); Cblacs_gridinfo( ctxt, &amp;procrows, &amp;proccols, &amp;myrow, &amp;mycol ); /* process coordinates for the process grid */ // Cblacs_pcoord(ctxt, myid, &amp;myrow, &amp;mycol); /* Broadcast of the matrix dimensions */ int dimensions[4]; if (mpiroot) { dimensions[0] = N;//Global Rows dimensions[1] = M;//Global Cols dimensions[2] = Nb;//Local Rows dimensions[3] = Mb;//Local Cols } MPI_Bcast(dimensions, 4, MPI_INT, 0, MPI_COMM_WORLD); MPI_Bcast(&amp;ord, 1, MPI_INT, 0, MPI_COMM_WORLD); N = dimensions[0]; M = dimensions[1]; Nb = dimensions[2]; Mb = dimensions[3]; int nrows = numroc_(&amp;N, &amp;Nb, &amp;myrow, &amp;iZERO, &amp;procrows); int ncols = numroc_(&amp;M, &amp;Mb, &amp;mycol, &amp;iZERO, &amp;proccols); int lda = max(1,nrows); MPI_Bcast(&amp;lda, 1, MPI_INT, 0, MPI_COMM_WORLD); /* Print grid pattern */ if (myid == 0) cout &lt;&lt; "Processes grid pattern:" &lt;&lt; endl; for (int r = 0; r &lt; procrows; ++r) { for (int c = 0; c &lt; proccols; ++c) { Cblacs_barrier(ctxt, "All"); if (myrow == r &amp;&amp; mycol == c) { cout &lt;&lt; myid &lt;&lt; " " &lt;&lt; flush; } } Cblacs_barrier(ctxt, "All"); if (myid == 0) cout &lt;&lt; endl; } if(myid == 0){ cout &lt;&lt;"Run Parameters"&lt;&lt;endl; cout &lt;&lt;"Global Rows = " &lt;&lt; M &lt;&lt;endl; cout &lt;&lt;"Global Cols = " &lt;&lt; N &lt;&lt;endl; cout &lt;&lt;"Local Block Rows = " &lt;&lt; Mb &lt;&lt;endl; cout &lt;&lt;"Local Block Cols = " &lt;&lt; Nb &lt;&lt;endl; cout &lt;&lt; "nrows = "&lt;&lt;nrows&lt;&lt;endl; cout &lt;&lt; "ncols = "&lt;&lt;ncols&lt;&lt;endl; cout &lt;&lt; "lda = "&lt;&lt;lda&lt;&lt;endl; cout &lt;&lt;"Order = "&lt;&lt;ord&lt;&lt;endl; } for (int id = 0; id &lt; numproc; ++id) { Cblacs_barrier(ctxt, "All"); } A_loc = new double[nrows*ncols]; for (int i = 0; i &lt; nrows*ncols; ++i) *(A_loc+i)=0.; /* Scatter matrix */ int sendr = 0, sendc = 0, recvr = 0, recvc = 0; for (int r = 0; r &lt; N; r += Nb, sendr=(sendr+1)%procrows) { sendc = 0; int nr = Nb; if (N-r &lt; Nb) nr = N-r; for (int c = 0; c &lt; M; c += Mb, sendc=(sendc+1)%proccols) { int nc = Mb; if (M-c &lt; Mb) nc = M-c; if (mpiroot) { Cdgesd2d(ctxt, nr, nc, A_glob+N*c+r, N, sendr, sendc); } if (myrow == sendr &amp;&amp; mycol == sendc) { Cdgerv2d(ctxt, nr, nc, A_loc+nrows*recvc+recvr, nrows, 0, 0); recvc = (recvc+nc)%ncols; } } if (myrow == sendr) recvr = (recvr+nr)%nrows; } /* Print local matrices */ if(verbose == 1) { for (int id = 0; id &lt; numproc; ++id) { if (id == myid) { cout &lt;&lt; "A_loc on node " &lt;&lt; myid &lt;&lt; endl; for (int r = 0; r &lt; nrows; ++r) { for (int c = 0; c &lt; ncols; ++c) cout &lt;&lt; setw(3) &lt;&lt; *(A_loc+nrows*c+r) &lt;&lt; " "; cout &lt;&lt; endl; } cout &lt;&lt; endl; } Cblacs_barrier(ctxt, "All"); } } for (int id = 0; id &lt; numproc; ++id) { Cblacs_barrier(ctxt, "All"); } /* DescInit */ info=0; descinit_(descA, &amp;N, &amp;M, &amp;Nb, &amp;Mb,&amp;iZERO,&amp;iZERO,&amp;ctxt, &amp;lda, &amp;info); if(mpiroot){ if(verbose == 1){ if (info == 0){ cout&lt;&lt;"Description init sucesss!"&lt;&lt;endl; } if(info &lt; 0){ cout &lt;&lt;"Error Info &lt; 0: if INFO = -i, the i-th argument had an illegal value"&lt;&lt; endl &lt;&lt;"Info = " &lt;&lt; info&lt;&lt;endl; } } // Cblacs_barrier(ctxt, "All"); } //psgesv_(n, 1, al, 1,1,idescal, ipiv, b, 1,1,idescb, info) */ // psgesv_(&amp;n, &amp;one, al, &amp;one,&amp;one,idescal, ipiv, b, &amp;one,&amp;one,idescb, &amp;info); //pXelset http://www.netlib.org/scalapack/tools/pdelset.f /* CHOLESKY HERE */ info = 0; MPIt1=MPI_Wtime(); pdpotrf_("L",&amp;ord,A_loc,&amp;Nb,&amp;Mb,descA,&amp;info); for (int id = 0; id &lt; numproc; ++id) { Cblacs_barrier(ctxt, "All"); } MPIt2 = MPI_Wtime(); MPIelapsed=MPIt2-MPIt1; if(mpiroot){ std::cout&lt;&lt;"Cholesky MPI Run Time" &lt;&lt; MPIelapsed&lt;&lt;std::endl; if(info == 0){ std::cout&lt;&lt;"SUCCESS"&lt;&lt;std::endl; } if(info &lt; 0){ cout &lt;&lt; "info &lt; 0: If the i-th argument is an array and the j-entry had an illegal value, then INFO = -(i*100+j), if the i-th argument is a scalar and had an illegal value, then INFO = -i. " &lt;&lt; endl; cout&lt;&lt;"info = " &lt;&lt; info &lt;&lt; endl; } if(info &gt; 0){ std::cout&lt;&lt;"matrix is not positve definte"&lt;&lt;std::endl; } } //sanity check set global matrix to zero before it's recieved by nodes if(mpiroot){ for (int r = 0; r &lt; N; ++r) { for (int c = 0; c &lt; M; ++c) { A_glob2[c *N + r] = 0; } } } /* Gather matrix */ sendr = 0; for (int r = 0; r &lt; N; r += Nb, sendr=(sendr+1)%procrows) { sendc = 0; // Number of rows to be sent // Is this the last row block? int nr = Nb; if (N-r &lt; Nb) nr = N-r; for (int c = 0; c &lt; M; c += Mb, sendc=(sendc+1)%proccols) { // Number of cols to be sent // Is this the last col block? int nc = Mb; if (M-c &lt; Mb) nc = M-c; if (myrow == sendr &amp;&amp; mycol == sendc) { // Send a nr-by-nc submatrix to process (sendr, sendc) Cdgesd2d(ctxt, nr, nc, A_loc+nrows*recvc+recvr, nrows, 0, 0); recvc = (recvc+nc)%ncols; } if (mpiroot) { // Receive the same data // The leading dimension of the local matrix is nrows! Cdgerv2d(ctxt, nr, nc, A_glob2+N*c+r, N, sendr, sendc); } } if (myrow == sendr) recvr = (recvr+nr)%nrows; } /* Print test matrix */ if (mpiroot) { if(verbose == 1){ cout &lt;&lt; "Matrix A test:\n"; for (int r = 0; r &lt; N; ++r) { for (int c = 0; c &lt; M; ++c) { cout &lt;&lt; setw(3) &lt;&lt; *(A_glob2+N*c+r) &lt;&lt; " "; } cout &lt;&lt; endl; } } } /* Release resources */ delete[] A_glob; delete[] A_glob2; delete[] A_loc; Cblacs_gridexit(ctxt); MPI_Finalize(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload