<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Fri, May 9, 2014 at 7:19 AM, marco restelli <span dir="ltr"><<a href="mailto:mrestelli@gmail.com" target="_blank">mrestelli@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">2014-05-09 13:14 GMT+0200, Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>>:<br>
> On Fri, May 9, 2014 at 3:15 AM, marco restelli <<a href="mailto:mrestelli@gmail.com">mrestelli@gmail.com</a>> wrote:<br>
><br>
>> 2014-05-09 5:47 GMT+0200, Jed Brown <<a href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>>:<br>
>> > marco restelli <<a href="mailto:mrestelli@gmail.com">mrestelli@gmail.com</a>> writes:<br>
>> >> Matt, thanks but this I don't understand. What I want is getting three<br>
>> >> arrays (i,j,coeff) with all the nonzero local coefficients, so that I<br>
>> >> can send them around with MPI.<br>
>> >><br>
>> >> MatGetSubmatrices would give me some PETSc objects, which I can not<br>
>> >> pass to MPI, right?<br>
>> ><br>
>> > I'm not sure you want this, but you can use MatGetRowIJ and similar to<br>
>> > access the representation you're asking for if you are dead set on<br>
>> > depending on a specific data format rather than using generic<br>
>> > interfaces.<br>
>> ><br>
>><br>
>> Jed, thank you. This is probably not the PETSc solution, but still it<br>
>> might a solution!<br>
>><br>
>> I have found this example for MatGetRowIJ:<br>
>><br>
><br>
> I really do not think you want to do this. It is complex, fragile and I<br>
> believe the performance<br>
> improvement to be non-existent. You can get the effect you want JUST by<br>
> using one function.<br>
> For example, suppose you want 2 procs to get rows [0,5] and two procs to<br>
> get rows [1,3], then<br>
><br>
> procs A.B<br>
><br>
> MatGetSubmatrices(A, 2, [0,5], 2, [0,5], ..., &submat)<br>
><br>
> procs C, D<br>
><br>
> MatGetSubmatrices(A, 2, [1,3], 2, [1,3], ..., &submat)<br>
><br>
> and its done. No MPI, no extraction which depends on the Mat data<br>
> structure.<br>
<br>
Matt, I understand that the idea is to avoid using MPI, but I don't<br>
see how getting a submatrix is related to my problem.<br>
<br>
Probably a simpler version of my problem is the following:<br>
<br>
one matrix is distributed on procs. 0,1<br>
another matrix is distributed on procs. 2,3<br>
<br>
The two matrices have the same size and I want to add them. For the<br>
resulting matrix, I want two copies, one is distributed among 0,1 and<br>
the second one among 2,3.<br></blockquote><div><br></div><div>If you want distributed matrices to come out you could make one call to</div><div>MatGetSubmatrix() for each group, but that is unattractive for a large</div>
<div>number of groups.</div><div><br></div><div>I am not seeing the value you get by distributing these matrices if you are</div><div>just going to make copies later.</div><div><br></div><div> Matt</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
A possibility that I see now is creating a third matrix, with the same<br>
size, distributed among all the four processors: 0,1,2,3, setting it<br>
to zero and then letting processors 0,1 add their matrix, and also 2,3<br>
add their own. Then I could convert the result into two matrices,<br>
making the two copies that I need.<br>
<br>
This works provided that in MatAXPY I can uses matrices distributed on<br>
different processors: given that the function computes<br>
<br>
Y = a*X + Y<br>
<br>
in my case it would be<br>
Y -> procs. 0,1,2,3<br>
X -> procs. 0,1<br>
<br>
Would this work?<br>
<span class=""><font color="#888888"><br>
Marco<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>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>