<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Apr 20, 2018 at 1:30 PM, Klaus Burkart <span dir="ltr"><<a href="mailto:k_burkart@yahoo.com" target="_blank">k_burkart@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:10px"><div><div><font size="3">In my case N=M but n for process 0, 1, 2, 3,... no_processes-1 can be different from the nth process like in the example where the nth process=Proc2 and has only two rows while all other processes have three rows:</font></div></div></div></div></blockquote><div><br></div><div>Yes.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:10px"><div><div><div><div><font size="3">Example from the PETSc webpage mentioned before:<br></font></div><font size="3"><span><pre> 1 2 0 | 0 3 0 | 0 4
Proc0 0 5 6 | 7 0 0 | 8 0
9 0 10 | 11 0 0 | 12 0
------------------------------<wbr>-------
13 0 14 | 15 16 17 | 0 0
Proc1 0 18 0 | 19 20 21 | 0 0
0 0 0 | 22 23 0 | 24 0
------------------------------<wbr>-------
Proc2 25 26 27 | 0 0 28 | 29 0
30 0 0 | 31 32 33 | 0 34</pre>and</span><span><font size="3"> I need to enter different values for d_nnz and o_nnz for each row somewhere too<br></font><font size="3"><span><pre> proc0: d_nnz = [2,2,2] and o_nnz = [2,2,2]
proc1: d_nnz = [3,3,2] and o_nnz = [2,1,1]
proc2: d_nnz = [1,1] and o_nnz = [4,4]</pre></span></font></span></font></div></div></div></div></div></blockquote><div>Each process only sets d_nnz and o_nnz for its LOCAL rows. Thus, it is exactly as shown above. Proc1 sets values</div><div>only for rows 3-5.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:10px"><div><div><div><div><div><font size="3">I simply can't identify the function(s) used to set the values for n, d_nnz and o_nnz for the individual local matrices allocated to all the processes if n isn't the same for all processes and d_nnz and o_nnz are different for each local matrix?<br></font><div><div><br><font size="3">Approach described on the PETSc webpage:</font><br></div><span><pre><font size="3"> <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreate.html#MatCreate" rel="nofollow" target="_blank">MatCreate</a>(...,&A);
</font><div><br></div><div><br></div></pre><font size="3">
</font><pre><font size="3"> <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetType.html#MatSetType" rel="nofollow" target="_blank">MatSetType</a>(A,<a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MATMPIAIJ.html#MATMPIAIJ" rel="nofollow" target="_blank">MATMPIAIJ</a>);
</font><div><br></div><div><br></div></pre><font size="3">
</font><pre><font size="3"> <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetSizes.html#MatSetSizes" rel="nofollow" target="_blank">MatSetSizes</a>(A, m,n,M,N); // for the example above using this function would set the no. of rows for Proc2 to 3 but it's 2
</font><div><br></div><div><br></div><div><br></div></pre><font size="3">
</font><pre><font size="3"> <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatMPIAIJSetPreallocation.html#MatMPIAIJSetPreallocation" rel="nofollow" target="_blank">MatMPIAIJSetPreallocation</a>(A,..<wbr>.); // this function can be used to set values for ONE local matrix only</font><div><br></div><br><font size="3">In addition to that I don't know which functions to use to preallocate memory for ALL local matrices when each of them has different values for d_nnz and o_nnz.<br><br>I other words, what's the code for the 3 process example above? (entering the matrix structure and allocating memory)<br></font><br></pre></span></div></div></div></div></div></div><font size="3">
</font><div><font size="3">Klaus<br></font></div><div><br></div>
<div id="m_800689018898067999yahoo_quoted_4478250076" class="m_800689018898067999yahoo_quoted">
<div style="font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;color:#26282a">
<div>
Am Freitag, 20. April 2018, 17:13:26 MESZ hat Smith, Barry F. <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>> Folgendes geschrieben:
</div>
<div><br></div>
<div><br></div>
<div><div dir="ltr"><br clear="none"> For square matrices almost always n is the same as m. On different processes m can be different. You get to decide what makes sense for each processes what its m should be.<br clear="none"><br clear="none"> Barry<br clear="none"><br clear="none"><div class="m_800689018898067999yqt5043941089" id="m_800689018898067999yqtfd85913"><br clear="none">> On Apr 20, 2018, at 10:05 AM, Klaus Burkart <<a shape="rect" href="mailto:k_burkart@yahoo.com" target="_blank">k_burkart@yahoo.com</a>> wrote:<br clear="none">> <br clear="none">> I think I understood the matrix structure for parallel computation with the rows, diagonal (d) and off-diagonal (o) structure, where I have problems is how to do the setup including memory allocation in PETSc:<br clear="none">> <br clear="none">> Lets assume, I use a 16 core workstation (=16 processes) and the number of nonzeros varies in each row for both d and o and the number of rows assigned to each process differs too - at least for the nth process.<br clear="none">> <br clear="none">> Looking at the manual and <a shape="rect" href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateAIJ.html#MatCreateAIJ," target="_blank">http://www.mcs.anl.gov/petsc/<wbr>petsc-current/docs/<wbr>manualpages/Mat/MatCreateAIJ.<wbr>html#MatCreateAIJ, </a>I don't understand how to enter a global matrix when n is NOT the same for each process as e.g. in MatSetSizes(A, m,n,M,N); n and m are integers, not arrays?<br clear="none">> <br clear="none">> MatCreate(...,&A);<br clear="none">> <br clear="none">> MatSetType(A,MATMPIAIJ);<br clear="none">> <br clear="none">> MatSetSizes(A, m,n,M,N); // seems to assume n and m are the same for each process which isn't even the case in the example on the page mentioned above?!<br clear="none">> <br clear="none">> MatMPIAIJSetPreallocation(A,..<wbr>.);<br clear="none">> <br clear="none">> <br clear="none">> How can I enter the parallel global-local matrix structure?<br clear="none">> <br clear="none">> How can the memory preallocation be done?<br clear="none">> <br clear="none">> Klaus<br clear="none">> <br clear="none">> Am Donnerstag, 19. April 2018, 01:47:59 MESZ hat Smith, Barry F. <<a shape="rect" href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>> Folgendes geschrieben:<br clear="none">> <br clear="none">> <br clear="none">> <br clear="none">> <br clear="none">> > On Apr 18, 2018, at 4:42 PM, <a shape="rect" href="mailto:k_burkart@yahoo.com" target="_blank">k_burkart@yahoo.com</a> wrote:<br clear="none">> > <br clear="none">> > So, practically speaking, l should invent routines to decompose the matrix e.g. into a block matrix structure to be able to make real use of PETSc ie. be able to solve a linear system using more than one process/core?<br clear="none">> <br clear="none">> To really use PETSc efficiently/effectively you need to generate your matrix in parallel.<br clear="none">> <br clear="none">> Barry<br clear="none">> <br clear="none">> > <br clear="none">> > Klaus<br clear="none">> > <br clear="none">> > Von meinem Huawei-Mobiltelefon gesendet<br clear="none">> > <br clear="none">> > <br clear="none">> > -------- Originalnachricht --------<br clear="none">> > Betreff: Re: [petsc-users] Matrix and vector type selection & memory allocation for efficient matrix import?<br clear="none">> > Von: "Smith, Barry F." <br clear="none">> > An: Klaus Burkart <br clear="none">> > Cc: PETSc Users List <br clear="none">> > <br clear="none">> > <br clear="none">> > <br clear="none">> > If you can only generate the nonzero allocation sequentially you can only solve sequentially which means your matrix is MATSEQAIJ and your vector is VECSEQ and your communicator is PETSC_COMM_SELF.<br clear="none">> > <br clear="none">> > If you pass and array for nnz, what you pass for nz is irrelevant, you might as well pass 0.<br clear="none">> > <br clear="none">> > Barry<br clear="none">> > <br clear="none">> > <br clear="none">> > > On Apr 18, 2018, at 10:48 AM, Klaus Burkart wrote:<br clear="none">> > > <br clear="none">> > > More questions about matrix and vector type selection for my application:<br clear="none">> > > <br clear="none">> > > My starting point is a huge sparse matrix which can be symmetric or asymmetric and a rhs vector. There's no defined local or block structure at all, just row and column indices and the values and an array style rhs vector together describing the entire linear system to be solved. With quite some effort, I should be able to create an array nnz[N] containing the number of nonzeros per row in the global matrix for memory allocation which would leave me with MatSeqAIJSetPreallocation(M, 0, nnz); as the only option for efficient memory allocation ie. a MATSEQAIJ matrix and VECSEQ. I assume here, that 0 indicates different numbers of nonzero values in each row, the exact number being stored in the nnz array. Regarding this detail but one example assume a constant number of nz per row so I am not sure whether I should write 0 or NULL for nz?<br clear="none">> > > <br clear="none">> > > I started with:<br clear="none">> > > <br clear="none">> > > MatCreate(PETSC_COMM_WORLD, &M);<br clear="none">> > > MatSetSizes(M, PETSC_DECIDE, PETSC_DECIDE, N, N);<br clear="none">> > > MatSetFromOptions(M);<br clear="none">> > > <br clear="none">> > > taken from a paper and assume, the latter would set the matrix type to MATSEQAIJ which might conflict with PETSC_COMM_WORLD. Maybe decompositioning took place at an earlier stage and the authors of the paper were able to retrieve the local data and structure. <br clear="none">> > > <br clear="none">> > > What type of matrix and vector should I use for my application e.g. MATSEQAIJ and VECSEQ to be able to use MatSeqAIJSetPreallocation(M, 0, nnz); for efficient memory allocation?<br clear="none">> > > <br clear="none">> > > In this case, where would the decompositioning / MPI process allocation take place?<br clear="none">> > <br clear="none"></div></div></div>
</div>
</div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.caam.rice.edu/~mk51/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div>
</div></div>