[petsc-users] Matrix Market matrices in PETSc binary format - repository
Jed Brown
jedbrown at mcs.anl.gov
Tue Aug 28 09:33:03 CDT 2012
On Mon, Aug 27, 2012 at 11:18 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
> On Mon, Aug 27, 2012 at 10:49 PM, Pierre-Yves Aquilanti <sperif at gmail.com>wrote:
>
>> 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).
>
>
> Right here, you don't preallocate:
>
> https://github.com/Perif/MatrixMarketToPETSc/blob/master/libs.c#L29
>
> Preallocate (e.g. by making two passes over the input file) and it will
> take seconds to convert that file.
>
> You can write a very simple converter using scipy.io.mmread() and
> bin/pythonscripts/PetscBinaryIO.py.
>
It turns out there was a missing "self" in this code, fixed here
http://petsc.cs.iit.edu/petsc/releases/petsc-3.3/rev/0d7ab44d6198
With that, these three lines of python will do the conversion for you
import scipy.io, PetscBinaryIO
A = scipy.io.mmread('dielFilterV3clx/dielFilterV3clx.mtx')
PetscBinaryIO.PetscBinaryIO().writeMatSciPy(open('petscmatrix','w'), A)
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120828/38d43831/attachment-0001.html>
More information about the petsc-users
mailing list