<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 31, 2015 at 11:05 PM, Steena M <span dir="ltr"><<a href="mailto:stm8086@yahoo.com" target="_blank">stm8086@yahoo.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"><div><div style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px;background-color:rgb(255,255,255)"><div dir="ltr"><span>Thanks Matt. I'm still getting the malloc error </span></div></div></div></blockquote><div><br></div><div>If you are loading a matrix, its just</div><div><br></div><div> <span style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px;white-space:pre-wrap"> </span><span style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px">CHKERRQ( MatCreate(comm, &A)); </span></div><div><div dir="ltr" style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px"><span style="white-space:pre-wrap"> </span>CHKERRQ( MatLoad(A,fd)); </div></div><div><br></div><div> Matt</div><div> </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"><div><div style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px;background-color:rgb(255,255,255)"><div dir="ltr">[0]PETSC ERROR: Argument out of range!</div><div dir="ltr"></div><div dir="ltr">[0]PETSC ERROR: New nonzero at (2,18) caused a malloc!</div><div dir="ltr"><span><br></span></div><div dir="ltr"><span>and </span></div><div dir="ltr"><span><br></span></div><div dir="ltr"><span>a new incorrect matrix file error:</span></div><div dir="ltr"><span><br></span></div><div dir="ltr">[0]PETSC ERROR: Unexpected data in file!</div><div dir="ltr"></div><div dir="ltr">[0]PETSC ERROR: not matrix object!</div><div dir="ltr"><br></div><div dir="ltr">Maybe the order of calls is mixed up. This is the code snippet:</div><div dir="ltr"><br></div><div dir="ltr"><span style="white-space:pre-wrap"> </span>if (rank ==0)</div><div dir="ltr"><span style="white-space:pre-wrap"> </span>{</div><div dir="ltr"><span style="white-space:pre-wrap"> </span> PetscPrintf (PETSC_COMM_WORLD,"\n On rank %d ", rank);</div><div dir="ltr"><span style="white-space:pre-wrap"> </span> </div><div dir="ltr"><span style="white-space:pre-wrap"> </span>CHKERRQ(MatSetSizes(A, 15, PETSC_DETERMINE, 20, 20));</div><div dir="ltr"><span style="white-space:pre-wrap"> </span>CHKERRQ(MatSetType(A, MATMPIBAIJ));</div><div dir="ltr"><span style="white-space:pre-wrap"> </span>CHKERRQ( MatMPIBAIJSetPreallocation(A,1,1,NULL,1,NULL));</div><div dir="ltr"><span style="white-space:pre-wrap"> </span>CHKERRQ( MatLoad(A,fd)); </div><div dir="ltr"><span style="white-space:pre-wrap"> </span> CHKERRQ(MatSetOption(A,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE));</div><div dir="ltr"><span style="white-space:pre-wrap"> </span>}</div><div dir="ltr"><span style="white-space:pre-wrap"> </span></div><div dir="ltr"><span style="white-space:pre-wrap"> </span>else</div><div dir="ltr"><span style="white-space:pre-wrap"> </span>{</div><div dir="ltr"><span style="white-space:pre-wrap"> </span>PetscPrintf (PETSC_COMM_WORLD,"\n On rank %d ", rank);</div><div dir="ltr"><span style="white-space:pre-wrap"> </span></div><div dir="ltr"><span style="white-space:pre-wrap"> </span>CHKERRQ( MatSetSizes(A, 5, PETSC_DETERMINE, 20, 20) );</div><div dir="ltr"><span style="white-space:pre-wrap"> </span>CHKERRQ(MatSetType(A, MATMPIBAIJ));</div><div dir="ltr"><span style="white-space:pre-wrap"> </span>CHKERRQ( MatMPIBAIJSetPreallocation(A,1,1,NULL,1,NULL));</div><div dir="ltr"><span style="white-space:pre-wrap"> </span>CHKERRQ(MatLoad(A,fd));</div><div dir="ltr"><span style="white-space:pre-wrap"> </span>CHKERRQ(MatSetOption(A,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE));</div><div dir="ltr"><span style="white-space:pre-wrap"> </span><span style="white-space:pre-wrap"> </span>}</div><div dir="ltr"><br></div><div dir="ltr">Is there something I'm missing? </div><div dir="ltr"><br></div><div dir="ltr">Thanks,</div><div dir="ltr">Steena</div><div dir="ltr"><span style="white-space:pre-wrap"> </span></div> <div dir="ltr"><span><br></span></div><br><div><br><br></div><div style="display:block"> <div style="font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px"> <div style="font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px"> <div dir="ltr"> <font face="Arial"> On Tuesday, March 31, 2015 6:10 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br> </font> </div> <br><br> <div><div><div><div dir="ltr"><div><div>On Tue, Mar 31, 2015 at 6:51 PM, Steena M <span dir="ltr"><<a rel="nofollow" shape="rect" href="mailto:stm8086@yahoo.com" target="_blank">stm8086@yahoo.com</a>></span> wrote:<br clear="none"><blockquote 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">Thanks Barry. I'm still getting the malloc error with NULL. Is there a way to distribute the matrix without explicit preallocation? Different matrices will be loaded during runtime and assigning preallocation parameters would mean an additional preprocessing step.<br clear="none"></blockquote><div><br clear="none"></div><div>1) MatSetOption(<span style="color:rgb(0,0,0);font-family:Times;font-size:medium">MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE)</span></div><div> </div><div>2) Note that this is never ever ever more efficient than making another pass and preallocating</div><div><br clear="none"></div><div> Thanks,</div><div><br clear="none"></div><div> Matt</div><blockquote 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">
--------------------------------------------<br clear="none">
On Sun, 3/29/15, Barry Smith <<a rel="nofollow" shape="rect" href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>> wrote:<br clear="none">
<br clear="none">
Subject: Re: [petsc-users] Unequal sparse matrix row distribution for MPI MatMult<br clear="none">
To: "Steena M" <<a rel="nofollow" shape="rect" href="mailto:stm8086@yahoo.com" target="_blank">stm8086@yahoo.com</a>><br clear="none">
Cc: "Matthew Knepley" <<a rel="nofollow" shape="rect" href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>>, <a rel="nofollow" shape="rect" href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br clear="none">
Date: Sunday, March 29, 2015, 9:26 PM<br clear="none">
<br clear="none">
<br clear="none">
> On<br clear="none">
Mar 29, 2015, at 11:05 PM, Steena M <<a rel="nofollow" shape="rect" href="mailto:stm8086@yahoo.com" target="_blank">stm8086@yahoo.com</a>><br clear="none">
wrote:<br clear="none">
><br clear="none">
> Thanks<br clear="none">
Matt. I used PETSC_DETERMINE but I'm now getting an<br clear="none">
allocation-based error:<br clear="none">
><br clear="none">
> [0]PETSC ERROR: ---------------------<br clear="none">
Error Message ------------------------------------<br clear="none">
> [0]PETSC ERROR: Argument out of range!<br clear="none">
> [0]PETSC ERROR: New nonzero at (2,18)<br clear="none">
caused a malloc!<br clear="none">
> [0]PETSC ERROR:<br clear="none">
------------------------------------------------------------------------<br clear="none">
><br clear="none">
> I tried<br clear="none">
preallocating on each rank for the diagonal and off diagonal<br clear="none">
section of the matrix as the next step My current<br clear="none">
approximations for preallocation<br clear="none">
><br clear="none">
> CHKERRQ(<br clear="none">
MatMPIBAIJSetPreallocation(A,1,5,PETSC_DEFAULT,5,PETSC_DEFAULT)); <br clear="none">
<br clear="none">
<br clear="none">
These<br clear="none">
arguments where you pass PETSC_DEFAULT are expecting a<br clear="none">
pointer not an integer. You can pass NULL in those<br clear="none">
locations. Though it is better to provide the correct<br clear="none">
preallocation rather than some defaults.<br clear="none">
<br clear="none">
Barry<br clear="none">
<br clear="none">
><br clear="none">
> are throwing segmentation errors.<br clear="none">
><br clear="none">
> [0]PETSC ERROR: <br clear="none">
Caught signal number 11 SEGV: Segmentation Violation,<br clear="none">
probably memory access out of range<br clear="none">
><br clear="none">
> Any insights into what I'm doing<br clear="none">
wrong?<br clear="none">
><br clear="none">
> Thanks,<br clear="none">
> Steena<br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
> On Sun, 3/29/15, Matthew Knepley <<a rel="nofollow" shape="rect" href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>><br clear="none">
wrote:<br clear="none">
><br clear="none">
> Subject:<br clear="none">
Re: [petsc-users] Unequal sparse matrix row distribution for<br clear="none">
MPI MatMult<br clear="none">
> To: "Steena M"<br clear="none">
<<a rel="nofollow" shape="rect" href="mailto:stm8086@yahoo.com" target="_blank">stm8086@yahoo.com</a>><br clear="none">
> Cc: "Barry Smith" <<a rel="nofollow" shape="rect" href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>>,<br clear="none">
<a rel="nofollow" shape="rect" href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br clear="none">
> Date: Sunday, March 29, 2015, 10:02 PM<br clear="none">
><br clear="none">
> On Sun, Mar 29, 2015<br clear="none">
at<br clear="none">
> 9:56 PM, Steena M <<a rel="nofollow" shape="rect" href="mailto:stm8086@yahoo.com" target="_blank">stm8086@yahoo.com</a>><br clear="none">
> wrote:<br clear="none">
> Hi<br clear="none">
> Barry,<br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
> I am trying to partition a 20 row and 20<br clear="none">
col sparse matrix<br clear="none">
> between two procs<br clear="none">
such that proc 0 has 15 rows and 20 cols<br clear="none">
> and proc 1 has 5 rows and 20 cols. The<br clear="none">
code snippet:<br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
> <br clear="none">
CHKERRQ(MatCreate(PETSC_COMM_WORLD,&A));<br clear="none">
//<br clear="none">
> at runtime: -matload_block_size 1<br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
> <br clear="none">
if (rank ==0)<br clear="none">
><br clear="none">
> {<br clear="none">
><br clear="none">
> <br clear="none">
CHKERRQ( MatSetSizes(A, 15, 20, 20,<br clear="none">
> 20) ); //rank 0 gets 75% of the rows<br clear="none">
><br clear="none">
> <br clear="none">
CHKERRQ( MatSetType(A, MATMPIBAIJ)<br clear="none">
> );<br clear="none">
><br clear="none">
> CHKERRQ(<br clear="none">
MatLoad(A,fd) );<br clear="none">
><br clear="none">
> }<br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
> else<br clear="none">
><br clear="none">
> <br clear="none">
{<br clear="none">
><br clear="none">
> <br clear="none">
CHKERRQ( MatSetSizes(A, 5,<br clear="none">
20, 20,<br clear="none">
> 20) ); //rank 1 gets 25% of the<br clear="none">
rows<br clear="none">
><br clear="none">
> <br clear="none">
CHKERRQ( MatSetType(A, MATMPIBAIJ)<br clear="none">
> );<br clear="none">
><br clear="none">
> CHKERRQ(<br clear="none">
MatLoad(A,fd) );<br clear="none">
><br clear="none">
> }<br clear="none">
><br clear="none">
<br clear="none">
><br clear="none">
><br clear="none">
> This throws the following error (probably<br clear="none">
from psplit.c):<br clear="none">
><br clear="none">
><br clear="none">
[1]PETSC ERROR: --------------------- Error Message<br clear="none">
> ------------------------------------<br clear="none">
><br clear="none">
> [1]PETSC ERROR:<br clear="none">
Nonconforming object sizes!<br clear="none">
><br clear="none">
> [1]PETSC ERROR: Sum of local lengths 40<br clear="none">
does not equal<br clear="none">
> global length 20, my<br clear="none">
local length 20<br clear="none">
><br clear="none">
> likely a call to<br clear="none">
VecSetSizes() or MatSetSizes() is<br clear="none">
><br clear="none">
wrong.<br clear="none">
><br clear="none">
> See<br clear="none">
<a rel="nofollow" shape="rect" href="http://www.mcs.anl.gov/petsc/documentation/faq.html#split" target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html#split</a>!<br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
> This error printout<br clear="none">
doesn't quite make sense to me.<br clear="none">
><br clear="none">
I'm trying to specify a total matrix size of 20x20...<br clear="none">
I<br clear="none">
> haven't yet figured out where the<br clear="none">
'40' comes<br clear="none">
> from in the error<br clear="none">
message.<br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
> Any thoughts on what<br clear="none">
might be going wrong?<br clear="none">
><br clear="none">
> Its the column specification. Just<br clear="none">
> use PETSC_DETERMINE for the local columns<br clear="none">
since all our<br clear="none">
> sparse matrixformats are<br clear="none">
row divisions<br clear="none">
> anyway.<br clear="none">
> <br clear="none">
> Thanks,<br clear="none">
> <br clear="none">
> Matt<br clear="none">
> Thanks in advance,<br clear="none">
><br clear="none">
<br clear="none">
> Steena<br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
--------------------------------------------<br clear="none">
><br clear="none">
> On Sun, 3/22/15,<br clear="none">
Barry Smith <<a rel="nofollow" shape="rect" href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>><br clear="none">
> wrote:<br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
> Subject: Re: [petsc-users] Unequal<br clear="none">
sparse matrix row<br clear="none">
> distribution for MPI<br clear="none">
MatMult<br clear="none">
><br clear="none">
> To:<br clear="none">
"Steena M" <<a rel="nofollow" shape="rect" href="mailto:stm8086@yahoo.com" target="_blank">stm8086@yahoo.com</a>><br clear="none">
><br clear="none">
> Cc: <a rel="nofollow" shape="rect" href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br clear="none">
><br clear="none">
> Date: Sunday,<br clear="none">
March 22, 2015, 3:58 PM<br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
> <br clear="none">
><br clear="none">
> Steena,<br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
> I am<br clear="none">
><br clear="none">
<br clear="none">
> a little unsure of your question.<br clear="none">
<br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
> 1)<br clear="none">
you can create a MPIBAIJ<br clear="none">
><br clear="none">
> matrix with any distribution of block<br clear="none">
rows per process<br clear="none">
> you<br clear="none">
><br clear="none">
> want, just set the<br clear="none">
local row size for each process to<br clear="none">
><br clear="none">
be<br clear="none">
><br clear="none">
> what you<br clear="none">
like. Use MatCreateVecs() to get<br clear="none">
><br clear="none">
correspondingly<br clear="none">
><br clear="none">
> <br clear="none">
laid out vectors.<br clear="none">
><br clear="none">
><br clear="none">
<br clear="none">
><br clear="none">
> <br clear="none">
or 2) if you have a MPIBAIJ<br clear="none">
><br clear="none">
> matrix with<br clear="none">
"equal" row layout and you want a<br clear="none">
> new<br clear="none">
><br clear="none">
> one with uneven row layout you can<br clear="none">
simply use<br clear="none">
><br clear="none">
> <br clear="none">
MatGetSubMatrix() to create that new matrix.<br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
> Barry<br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
> Unless you have<br clear="none">
another reason to have the<br clear="none">
><br clear="none">
> matrix with an equal number row layout I<br clear="none">
would just<br clear="none">
> generate<br clear="none">
><br clear="none">
> the matrix with<br clear="none">
the layout you want.<br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
> > On Mar 22, 2015, at 5:50 PM, Steena<br clear="none">
M<br clear="none">
><br clear="none">
> <<a rel="nofollow" shape="rect" href="mailto:stm8086@yahoo.com" target="_blank">stm8086@yahoo.com</a>><br clear="none">
><br clear="none">
> wrote:<br clear="none">
><br clear="none">
> ><br clear="none">
><br clear="none">
> > Hello,<br clear="none">
><br clear="none">
> ><br clear="none">
><br clear="none">
> > I need to<br clear="none">
distribute<br clear="none">
><br clear="none">
> a<br clear="none">
sparse matrix such that each proc owns an unequal<br clear="none">
> number<br clear="none">
><br clear="none">
> of blocked rows before I proceed with<br clear="none">
MPI MatMult. My<br clear="none">
><br clear="none">
> <br clear="none">
initial thoughts on doing this:<br clear="none">
><br clear="none">
> ><br clear="none">
><br clear="none">
> > 1) Use MatGetSubMatrices() on the<br clear="none">
test<br clear="none">
><br clear="none">
> MATMPIBAIJ<br clear="none">
matrix to produce a new matrix where each<br clear="none">
> proc<br clear="none">
><br clear="none">
> has an unequal number of rows.<br clear="none">
><br clear="none">
> ><br clear="none">
><br clear="none">
> > 2) Provide<br clear="none">
scatter context for vector X<br clear="none">
><br clear="none">
> (for MatMult )using IS iscol from<br clear="none">
MatGetSubMatrices()<br clear="none">
> while<br clear="none">
><br clear="none">
> creating the<br clear="none">
vector X.<br clear="none">
><br clear="none">
> <br clear="none">
><br clear="none">
><br clear="none">
> > 3)<br clear="none">
Call MatMult()<br clear="none">
><br clear="none">
> <br clear="none">
><br clear="none">
><br clear="none">
> > Will<br clear="none">
MatMult_MPIBAIJ continue to scatter<br clear="none">
><br clear="none">
> this matrix and vector such that each<br clear="none">
proc will own an<br clear="none">
> equal<br clear="none">
><br clear="none">
> number of matrix<br clear="none">
rows and corresponding diagonal vector<br clear="none">
><br clear="none">
<br clear="none">
> elements? Should I write my own<br clear="none">
MPIMatMult function to<br clear="none">
><br clear="none">
> retain my redistribution of the matrix<br clear="none">
and vector?<br clear="none">
><br clear="none">
> <br clear="none">
><br clear="none">
><br clear="none">
> ><br clear="none">
Thanks in<br clear="none">
><br clear="none">
> <br clear="none">
advance,<br clear="none">
><br clear="none">
> ><br clear="none">
Steena<br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
><br clear="none">
> --<br clear="none">
> What most<br clear="none">
experimenters<br clear="none">
> take for granted before<br clear="none">
they begin their experiments is<br clear="none">
><br clear="none">
infinitely more interesting than any results to which<br clear="none">
their<br clear="none">
> experiments lead.<br clear="none">
> -- Norbert<br clear="none">
> Wiener<div><br clear="none">
><br clear="none">
<br clear="none"><span class=""><font color="#888888">
</font></span></div></blockquote></div><span class=""><font color="#888888"><div><br clear="none"><br clear="all"><div><br clear="none"></div>-- <br clear="none"><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 clear="none">-- Norbert Wiener</div>
</div></font></span></div></div></div></div><br><br></div> </div> </div> </div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">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></div>