<div class="gmail_quote">On Mon, Aug 27, 2012 at 11:18 PM, Jed Brown <span dir="ltr"><<a href="mailto:jedbrown@mcs.anl.gov" target="_blank">jedbrown@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><div class="gmail_quote">On Mon, Aug 27, 2012 at 10:49 PM, Pierre-Yves Aquilanti <span dir="ltr"><<a href="mailto:sperif@gmail.com" target="_blank">sperif@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The problem is that when in parallel, it is quite tricky to use a matrix in Matrix Market format as an input. And if I'm not mistaking, it is needed to convert the matrix from MM to PETSc binary format, which can take a lot time in some cases (I am converting dielFilterV3clx, it has been running for 162h and still not finished).</blockquote>
</div><div><br></div></div><div>Right here, you don't preallocate:</div><br><div><a href="https://github.com/Perif/MatrixMarketToPETSc/blob/master/libs.c#L29" target="_blank">https://github.com/Perif/MatrixMarketToPETSc/blob/master/libs.c#L29</a></div>
<div><br></div><div>Preallocate (e.g. by making two passes over the input file) and it will take seconds to convert that file.</div><div><br></div><div>You can write a very simple converter using scipy.io.mmread() and bin/pythonscripts/PetscBinaryIO.py.</div>
</blockquote><div><br></div><div>It turns out there was a missing "self" in this code, fixed here</div><div><br></div><div> <a href="http://petsc.cs.iit.edu/petsc/releases/petsc-3.3/rev/0d7ab44d6198">http://petsc.cs.iit.edu/petsc/releases/petsc-3.3/rev/0d7ab44d6198</a></div>
</div><br><div>With that, these three lines of python will do the conversion for you</div><div><br></div><div><div>import <a href="http://scipy.io">scipy.io</a>, PetscBinaryIO</div><div>A = scipy.io.mmread('dielFilterV3clx/dielFilterV3clx.mtx')</div>
<div>PetscBinaryIO.PetscBinaryIO().writeMatSciPy(open('petscmatrix','w'), A)<br><br>Make sure to set PETSC_ARCH for complex (for this matrix) or manually pass the precision/scalar-type flags. This runs in 30 seconds on my laptop.</div>
</div>