<div dir="ltr">petsc4py is "too clever" in the sense that it tries to interpret many different kids of "sizes" arguments. You can always pass the pair (localsize, globalsize), but you can also pass only a global size (in which case the vector will be split apart). If you want to set only the local size, you should pass (localsize, None).<div>
<br></div><div>Your example is invalid, with each process passing different global sizes. petsc-dev will now error if you do this.</div><div><br></div><div>I changed your example to:</div><div><br></div><div><br></div><div>
<div>X = PETSc.Vec().create(comm=PETSc.COMM_WORLD)</div><div>X.setSizes((sizes[mpi_rank],PETSc.DECIDE),bsize=1)</div><div>X.setFromOptions()</div><div>ilow,ihigh = X.getOwnershipRange()</div><div><br></div><div>PETSc.Sys.syncPrint("rank: ",mpi_rank,"low/high: ",ilow,ihigh)</div>
<div>PETSc.Sys.syncFlush()</div><div><br></div><div style>and now get the output:</div><div style><br></div><div><div>rank: 0 low/high: 0 35675</div><div>rank: 1 low/high: 35675 401185</div><div>rank: 2 low/high: 401185 766927</div>
<div>rank: 3 low/high: 766927 802370</div></div><div><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Feb 4, 2013 at 4:01 PM, Weston Lowrie <span dir="ltr"><<a href="mailto:wlowrie@uw.edu" target="_blank">wlowrie@uw.edu</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">
Hi,<br>I'm confused what the Vec().setSizes() routine is doing in petsc4py. Consider this example:<br><br><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><font face="courier new, monospace">#!/usr/bin/env python</font><font face="courier new, monospace"><br>
</font><font face="courier new, monospace">import sys,os<br></font><font face="courier new, monospace">from petsc4py import PETSc<br></font><font face="courier new, monospace">from numpy import *<br></font><font face="courier new, monospace"><br>
</font><font face="courier new, monospace">mpi_rank = PETSc.COMM_WORLD.getRank()<br></font><font face="courier new, monospace">mpi_size = PETSc.COMM_WORLD.getSize()</font><font face="courier new, monospace"><br></font><font face="courier new, monospace"><br>
sizes = zeros(4)<br></font><font face="courier new, monospace">sizes[0] = 35675<br></font><font face="courier new, monospace">sizes[1] = 365510<br></font><font face="courier new, monospace">sizes[2] = 365742<br></font><font face="courier new, monospace">sizes[3] = 35443</font><font face="courier new, monospace"><br>
</font><font face="courier new, monospace"><br>X = PETSc.Vec().create(comm=PETSc.COMM_WORLD)<br></font><font face="courier new, monospace">X.setSizes(mpi_size*sizes[mpi_rank],bsize=1)<br></font><font face="courier new, monospace">X.setFromOptions()<br>
</font><font face="courier new, monospace">ilow,ihigh = X.getOwnershipRange()</font><font face="courier new, monospace"><br></font><font face="courier new, monospace"><br>print "rank: ",mpi_rank,"low/high: ",ilow,ihigh</font></blockquote>
<br><br>Why is it that when setting the local sizes explicitly do I need to multiply by the mpi_size? My understanding is that when using this routine it is telling PETSc what the local processor core size should be. It seems to divide it by total number of processors cores.<br>
<div><br></div><div>Thanks,</div><div>Wes</div>
</blockquote></div><br></div></div></div>