[petsc-dev] [petsc-maint #60349] Saving multiple Vec in the same binary file

Barry Smith bsmith at mcs.anl.gov
Thu Jan 6 18:04:03 CST 2011


On Jan 6, 2011, at 5:54 PM, Blaise Bourdin wrote:

> 
> On Jan 6, 2011, at 5:16 PM, Barry Smith wrote:
> 
>> 
>> On Jan 6, 2011, at 5:12 PM, Blaise Bourdin wrote:
>> 
>>> Dear Barry,
>>> 
>>> 
>>> On Jan 6, 2011, at 12:22 PM, Barry Smith wrote:
>>> 
>>>> 
>>>> Blaise,
>>>> 
>>>> PETSc uses a flat binary file for storing matrices and vectors. If you write A then B then C then you need to read back A then B then C. Names are not even stored in the binary file. With VecLoad() if you set the size of the Vec before calling VecLoad() then the size has to match the vector in the file. But you don't need to set the size of the Vec before Vec load and then it will use the size in the file.
>>> That makes a lot of sense. I got it working, thanks.
>>> 
>>>> 
>>>> You can put a bunch of Vecs of different sizes into the same file.
>>>> 
>>>> If you want something fancy then you are stuck with HDF5.
>>> I lost time, sleep, and whatever hair and sanity I had left trying to compile parallel hdf5 using some antique version of the PGI compilers, and a weird SCAMPI. That's why I went back to petsc binary format...
>> 
>>  I was kinda of being sarcastic, based on my limited experience and reports from lots of people HDF5 sucks big time. But unfortunately since it has been christened as the parallel file API for HPC, no one can support something better. Performance wise PETSc binary IO should be fine for you, but you have to manage the order of the objects in the file.
> 
> Building hdf5 can be a pain. Having to to write a xdmf file so that post processing softwares other than visit can read hdf5 files can be a pain. Other than that, for DA based vectors it is not too bad...
> 
> I guess one could store some kind of a catalog in the .info file that would allow reloading object by name in any order. Do you have a feeling that anybody other than me could be interested?

   I think the appropriate response is that you are suppose to use the quality, high performance tools that do this kind of good stuff; tools like HDF5 :-)

   Take a look at PetscViewerBinaryMatlabOpen(). It is different in detail, but similar in idea. It generates a Matlab script that reads in a bunch of stuff from the binary file. You could do something similar, only different obviously :-).

  Barry

  Note: I don't like the PetscViewerBinaryMatlabOpen() interface, had I unlimited time I would make it PetscViewer format so the user would just set the format and then use the usual Viewer commands and the so the user wouldn't have to call the funky PetscViewerBinaryMatlabOpen().

> 
> Blaise
> 
>> 
>>> 
>>> On a different but not unrelated topic, Imtiaz who had started looking at the vtk IO had to leave LSU after our international services office screwed up his immigration paperwork... I am going to work with another student, Matt Kemp, on this project. Matt happens to also work part time for ANL and will be at MCS next week. I'll ask him to stop by and introduce himself to the group. He is also a good python / web programer so I was thinking of asking him to have a look at item 3 of the proposed project list: "Converting PetscLogViewPython() to generate JSON instead and developing Python parsers for quickly generating nice tables of performance details from runs or groups of runs." Is this still open?
>> 
>>  Cool beans.
>> 
>>  Barry
>> 
>>> 
>>> Blaise
>>> 
>>>> 
>>>> Barry
>>>> 
>>>> On Jan 6, 2011, at 12:10 PM, Blaise Bourdin wrote:
>>>> 
>>>>> Hi,
>>>>> 
>>>>> I am trying to save multiple vectors into a single binary file using petsc-3.1, but am encountering several issues. I am attaching 2 small examples documenting the problems.
>>>>> -mode 0 saves 2 vectors into a single file, mode 1 reads them back
>>>>> the size of each vector can be set with -ndofu -ndofv
>>>>> 
>>>>> 1. If I save U then V but read V then U, then V get U and V get U. What seems to matter is the order in which the vecs are read, while names are ignored, unlike, say the hdf5 viewer, Is this the desired behavior? Giving names to the Vec does not help
>>>>> 
>>>>> 2. if U and V do not have the same number of degrees of freedom, reading fails.
>>>>> 
>>>>> with petsc-dev, I can't even read then write a Vec created from a DMDA. There must be a bug in my example, but I can't figure it out right now.
>>>>> 
>>>>> Is saving multiple objects in the same binary file possible / supported, or it is an accident that it works when the objects are of exactly the same type?
>>>>> 
>>>>> Blaise
>>>>> 
>>>>> 
>>>>> <makefile.TestVecLoad><TestVecLoad-dev.c><TestVecLoad.c>
>>>>> -- 
>>>>> Department of Mathematics and Center for Computation & Technology
>>>>> Louisiana State University, Baton Rouge, LA 70803, USA
>>>>> Tel. +1 (225) 578 1612, Fax  +1 (225) 578 4276 http://www.math.lsu.edu/~bourdin
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>> 
>>> 
>>> -- 
>>> Department of Mathematics and Center for Computation & Technology
>>> Louisiana State University, Baton Rouge, LA 70803, USA
>>> Tel. +1 (225) 578 1612, Fax  +1 (225) 578 4276 http://www.math.lsu.edu/~bourdin
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>> 
> 
> -- 
> Department of Mathematics and Center for Computation & Technology
> Louisiana State University, Baton Rouge, LA 70803, USA
> Tel. +1 (225) 578 1612, Fax  +1 (225) 578 4276 http://www.math.lsu.edu/~bourdin
> 
> 
> 
> 
> 
> 
> 
> 




More information about the petsc-dev mailing list