<div class="gmail_quote">On Sun, Nov 27, 2011 at 01:44, Aron Ahmadia <span dir="ltr"><<a href="mailto:aron.ahmadia@kaust.edu.sa">aron.ahmadia@kaust.edu.sa</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div>qbc is a multi-dimensional, Fortran ordered numpy array</div></div></blockquote><div><br></div><div>Why is it a separate array instead of the one inside of the local vector?</div><div><br></div><div>Well, let's just think about what actually happens.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><br></div><div><div># METHOD 1</div><div><br></div><div><div># with fset(self,q) defined as follows:</div>
</div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div><div><div>        def fset(self,q):</div>
<div>            self.gqVec.setArray(q.reshape([-1], order = 'F'))</div></div></div></div></blockquote><div><br></div><div>This is memcpy</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div><br></div><div>        self.q = qbc[:,mbc:-mbc,mbc:-mbc]</div></div></blockquote><div><br></div><div>This will do another copy to turn the view into contiguous storage that can be passed on.</div><div><br></div>
<div><br></div><div>Note: I think PyClaw's use of fset for setting elements of an array is confusing since the call site looks like it should have different semantics than it does.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div><br></div></div><div># METHOD 2  </div><div><br></div><div>
        self.lqVec.placeArray(qbc.reshape([-1], order = 'F'))</div></blockquote><div><br></div><div>I think/hope this does no copy on the Numpy side.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>        self.q_da.localToGlobal(self.lqVec,self.gqVec)</div></blockquote><div><br></div><div>This updates the ghost values without an intermediate copy.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>        self.lqVec.resetArray() </div><div><br></div><div><div># METHOD 3  </div>
<div><br></div><div>        self.lqVec.placeArray(qbc)</div></div></blockquote><div><br></div><div>This is the same as before, right?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div>        self.q_da.localToGlobal(self.lqVec,self.gqVec)</div><div>        self.lqVec.resetArray() </div></div><div></div></blockquote></div><br>