<div dir="ltr"><p style="margin:0px;padding:0px;word-wrap:break-word;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">Hi, Jose</p><p style="margin:0px;padding:0px;word-wrap:break-word;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><br></p><p style="margin:0px;padding:0px;word-wrap:break-word;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px"> Thanks for your reply.</p><p style="margin:10px 0px 0px;padding:0px;word-wrap:break-word;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">I will specify the problem more exactly. I want to solve a big generalized eigenvalue problem. The matrices are sparse. My question lies on how to allocate the matrices among the processors. Do I have to do it by myself? Or there is a routine to do so? I notice that one should do something like</p><div style="margin:10px 0px 0px;padding:0px;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><pre style="font-family:'Bitstream Vera Sans Mono','DejaVu Sans Mono',Monaco,Courier,monospace;font-size:12px;line-height:1.4;margin-top:0px;margin-bottom:0px;padding:5px 10px;border:1px solid rgb(204,204,204);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;background:rgb(245,245,245)"><span>from</span> <span style="color:rgb(85,85,85)">petsc4py</span> <span>import</span> <span>PETSc</span>
<span>A</span> <span style="font-weight:bold">=</span> <span>PETSc</span><span style="font-weight:bold">.</span><span>Mat</span><span>()</span><span style="font-weight:bold">.</span><span>create</span><span>()</span>
<span>A</span><span style="font-weight:bold">.</span><span>setType</span><span>(</span><span style="color:rgb(187,136,68)">'aij'</span><span>)</span>
<span>A</span><span style="font-weight:bold">.</span><span>setSizes</span><span>([</span><span>M</span><span>,</span><span>N</span><span>])</span>
<span>A</span><span style="font-weight:bold">.</span><span>setPreallocationNNZ</span><span>([</span><span>diag_nz</span><span>,</span> <span>offdiag_nz</span><span>])</span> <span style="color:rgb(153,153,136);font-style:italic"># optional </span>
<span>A</span><span style="font-weight:bold">.</span><span>setUp</span><span>()</span>
</pre></div><p style="margin:10px 0px 0px;padding:0px;word-wrap:break-word;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">I have several question regarding these lines.</p><p style="margin:10px 0px 0px;padding:0px;word-wrap:break-word;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">(1) I presume M and N are the dimension of the matrix. Then how do the processors divide the matrix? I guess setPreallocationNNZ does the allocation of the matrix among the processors. What does nz mean here? Why here appears diag and offdiag?</p><p style="margin:10px 0px 0px;padding:0px;word-wrap:break-word;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">(2) I actually saw somewhere else that people use A.setPreallocationNNZ(5), with a single parameter 5. What does 5 mean here?</p><p style="margin:10px 0px 0px;padding:0px;word-wrap:break-word;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">(3) I want to make sure that the matrix so generated is sparse (since it uses aij). It is sparse right? I feel it tricky since if the matrix is stored as sparse, will the allocation/parallelization destroy the efficiency of sparse matrix?</p><p style="margin:10px 0px 0px;padding:0px;word-wrap:break-word;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><br></p><p style="margin:10px 0px 0px;padding:0px;word-wrap:break-word;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><br></p><p style="margin:10px 0px 0px;padding:0px;word-wrap:break-word;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">After the matrix is set up, I would like to use SLEPc4py to solve the generalized eigenvalue problem. The example code I got online is like</p><div style="margin:10px 0px 0px;padding:0px;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><pre style="font-family:'Bitstream Vera Sans Mono','DejaVu Sans Mono',Monaco,Courier,monospace;font-size:12px;line-height:1.4;margin-top:0px;margin-bottom:0px;padding:5px 10px;border:1px solid rgb(204,204,204);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;background:rgb(245,245,245)"><span style="color:rgb(0,128,128)">E</span><span style="color:rgb(187,187,187)"> </span><span style="font-weight:bold">=</span><span style="color:rgb(187,187,187)"> </span><span style="color:rgb(0,128,128)">SLEPc</span><span style="font-weight:bold">.</span><span style="color:rgb(0,128,128)">EPS</span><span>();</span><span style="color:rgb(187,187,187)"> </span><span style="color:rgb(0,128,128)">E</span><span style="font-weight:bold">.</span><span style="color:rgb(0,128,128)">create</span><span>()</span>
<span style="color:rgb(0,128,128)">E</span><span style="font-weight:bold">.</span><span style="color:rgb(0,128,128)">setOperators</span><span>(</span><span style="color:rgb(0,128,128)">A</span><span>)</span>
<span style="color:rgb(0,128,128)">E</span><span style="font-weight:bold">.</span><span style="color:rgb(0,128,128)">setProblemType</span><span>(</span><span style="color:rgb(0,128,128)">SLEPc</span><span style="font-weight:bold">.</span><span style="color:rgb(0,128,128)">EPS</span><span style="font-weight:bold">.</span><span style="color:rgb(0,128,128)">ProblemType</span><span style="font-weight:bold">.</span><span style="color:rgb(0,128,128)">GNHEP</span><span>)</span>
<span style="color:rgb(0,128,128)">E</span><span style="font-weight:bold">.</span><span style="color:rgb(0,128,128)">setFromOptions</span><span>()</span>
<span style="color:rgb(0,128,128)">E</span><span style="font-weight:bold">.</span><span style="color:rgb(0,128,128)">solve</span><span>()</span>
</pre></div><p style="margin:10px 0px 0px;padding:0px;word-wrap:break-word;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">I'm afraid this script is not designed for the parallel computation since in the options there is no indication of parallelization. Do you know how to set it up?</p><p style="margin:10px 0px 0px;padding:0px;word-wrap:break-word;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><br></p><p style="margin:10px 0px 0px;padding:0px;word-wrap:break-word;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">Thank you very much for your time. I appreciate it very much.</p><p style="margin:10px 0px 0px;padding:0px;word-wrap:break-word;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">Best,</p><p style="margin:10px 0px 0px;padding:0px;word-wrap:break-word;color:rgb(51,51,51);font-family:Arial,sans-serif;font-size:14px;line-height:20px">Mengqi</p></div><div class="gmail_extra"><br><div class="gmail_quote">2014-10-26 15:21 GMT-02:00 Jose E. Roman <span dir="ltr"><<a href="mailto:jroman@dsic.upv.es" target="_blank">jroman@dsic.upv.es</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
El 26/10/2014, a las 17:10, Mengqi Zhang escribió:<br>
<div><div class="h5"><br>
> Dear all PETSc users,<br>
><br>
> I'm new to PETSc/SLEPc. And I'm currently trying to use Python/PETSc4py/SLEPc4py to solve a big generalized eigenvalue problem, A x = B lambda x.<br>
><br>
> After several days' digging and trying, I can write a script for solving a smaller eigenvalue problem locally, but when the problem size increases, I realize I should go parallel. My question is how to do it in parallel? How could I preallocate the matrices among the processors? I presume there should be a way to do that, but I couldn't find a clear guide on the Internet.<br>
><br>
> Currently, the matrices are implemented locally, and then I use<br>
><br>
> E = SLEPc.EPS(); E.create()<br>
><br>
> E.setOperators(A,B)<br>
><br>
> E.setProblemType(SLEPc.EPS.ProblemType.GNHEP)<br>
><br>
> E.setFromOptions()<br>
><br>
> to locally solve the eigenvalue problem.<br>
><br>
><br>
><br>
> Could you help me and guide me to set the code up? Any suggestion is welcomed and appreciated. Thank you very much.<br>
><br>
><br>
><br>
> Best regards,<br>
><br>
> Mengqi<br>
><br>
<br>
</div></div>You may want to do A.setPreallocationNNZ(5) or something like that.<br>
Also, take into account that in generalized eigenproblems you will probably want to use a parallel linear solver, see discussion in section 3.4.1 of SLEPc's users guide.<br>
<span class="HOEnZb"><font color="#888888"><br>
Jose<br>
<br>
<br>
</font></span></blockquote></div><br></div>