[petsc-users] Write binary to matrix

Hong hzhang at mcs.anl.gov
Thu Sep 22 11:34:43 CDT 2016


Florian:
Would it work if replacing MATSBAIJ to MATAIJ or MATMPISBAIJ?

Hong

Hey,
>
> this code reproduces the error when run with 2 or more ranks.
>
> #include <petscmat.h>
> #include <petscsys.h>
>
> int main(int argc, char *argv[])
> {
>   PetscInitialize(&argc, &argv, "", NULL);
>
>   Mat matrix;
>   MatCreate(PETSC_COMM_WORLD, &matrix);
>   MatSetType(matrix, MATSBAIJ);
>   MatSetSizes(matrix, 10, 10, PETSC_DETERMINE, PETSC_DETERMINE);
>   MatSetFromOptions(matrix);
>   MatSetUp(matrix);
>
>   MatAssemblyBegin(matrix, MAT_FINAL_ASSEMBLY);
>   MatAssemblyEnd(matrix, MAT_FINAL_ASSEMBLY);
>
>   PetscViewer viewer;
>   PetscViewerBinaryOpen(PETSC_COMM_WORLD, "test.mat", FILE_MODE_WRITE,
> &viewer);
>   MatView(matrix, viewer);
>   PetscViewerDestroy(&viewer);
>   MatDestroy(&matrix);
>
>   PetscFinalize();
> }
>
>
> The complete output is:
>
>
> lindnefn at neon /data/scratch/lindnefn/aste (git)-[master] % mpic++
> petsc.cpp -lpetsc &&  mpirun -n 2 ./a.out
>
> [0]PETSC ERROR: --------------------- Error Message
> --------------------------------------------------------------
> [0]PETSC ERROR: No support for this operation for this object type
> [0]PETSC ERROR: Cannot get subcomm viewer for binary files or sockets
> unless SubViewer contains the rank 0 process
> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html
> for trouble shooting.
> [0]PETSC ERROR: Petsc Release Version 3.7.3, unknown
> [0]PETSC ERROR: ./a.out on a arch-linux2-c-debug named neon by lindnefn
> Thu Sep 22 16:10:34 2016
> [0]PETSC ERROR: Configure options --with-debugging=1
> --download-petsc4py=yes --download-mpi4py=yes
> --download-superlu_dist --download-parmetis --download-metis
> [0]PETSC ERROR: #1 PetscViewerGetSubViewer_Binary() line 46 in
> /data/scratch/lindnefn/software/petsc/src/sys/classes/viewer/impls/binary/
> binv.c
> [0]PETSC ERROR: #2 PetscViewerGetSubViewer() line 43 in
> /data/scratch/lindnefn/software/petsc/src/sys/
> classes/viewer/interface/dupl.c
> [0]PETSC ERROR: #3 MatView_MPISBAIJ_ASCIIorDraworSocket() line 900 in
> /data/scratch/lindnefn/software/petsc/src/mat/impls/sbaij/mpi/mpisbaij.c
> [0]PETSC ERROR: #4 MatView_MPISBAIJ() line 926 in /data/scratch/lindnefn/
> software/petsc/src/mat/impls/sbaij/mpi/mpisbaij.c
> [0]PETSC ERROR: #5 MatView() line 901 in /data/scratch/lindnefn/
> software/petsc/src/mat/interface/matrix.c
> WARNING! There are options you set that were not used!
> WARNING! could be spelling mistake, etc!
> Option left: name:-ksp_converged_reason (no value)
> Option left: name:-ksp_final_residual (no value)
> Option left: name:-ksp_view (no value)
> [neon:113111] *** Process received signal ***
> [neon:113111] Signal: Aborted (6)
> [neon:113111] Signal code:  (-6)
> [neon:113111] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x36cb0)
> [0x7feed8958cb0]
> [neon:113111] [ 1] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37)
> [0x7feed8958c37]
> [neon:113111] [ 2] /lib/x86_64-linux-gnu/libc.so.6(abort+0x148)
> [0x7feed895c028]
> [neon:113111] [ 3]
> /data/scratch/lindnefn/software/petsc/arch-linux2-c-
> debug/lib/libpetsc.so.3.7(PetscTraceBackErrorHandler+0x563)
> [0x7feed8d8db31]
> [neon:113111] [ 4] /data/scratch/lindnefn/software/petsc/arch-linux2-c-
> debug/lib/libpetsc.so.3.7(PetscError+0x374)
> [0x7feed8d88750]
> [neon:113111] [ 5] /data/scratch/lindnefn/software/petsc/arch-linux2-c-
> debug/lib/libpetsc.so.3.7(+0x19b2f6) [0x7feed8e822f6]
> [neon:113111] [ 6]
> /data/scratch/lindnefn/software/petsc/arch-linux2-c-
> debug/lib/libpetsc.so.3.7(PetscViewerGetSubViewer+0x4f1)
> [0x7feed8e803cb]
> [neon:113111] [ 7] /data/scratch/lindnefn/software/petsc/arch-linux2-c-
> debug/lib/libpetsc.so.3.7(+0x860c95) [0x7feed9547c95]
> [neon:113111] [ 8] /data/scratch/lindnefn/software/petsc/arch-linux2-c-
> debug/lib/libpetsc.so.3.7(+0x861494) [0x7feed9548494]
> [neon:113111] [ 9] /data/scratch/lindnefn/software/petsc/arch-linux2-c-
> debug/lib/libpetsc.so.3.7(MatView+0x12b6)
> [0x7feed971c08f]
> [neon:113111] [10] ./a.out() [0x400b8b]
> [neon:113111] [11] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)
> [0x7feed8943f45]
> [neon:113111] [12] ./a.out() [0x4009e9]
> [neon:113111] *** End of error message ***
> --------------------------------------------------------------------------
> mpirun noticed that process rank 1 with PID 113111 on node neon exited on
> signal 6 (Aborted).
> --------------------------------------------------------------------------
>
> Thanks,
> Florian
>
>
>
> Am 22.09.2016 um 13:32 schrieb Matthew Knepley:
> > On Thu, Sep 22, 2016 at 5:42 AM, Florian Lindner <mailinglists at xgm.de
> <mailto:mailinglists at xgm.de>> wrote:
> >
> >     Hello,
> >
> >     I want to write a MATSBAIJ to a file in binary, so that I can load
> it later using MatLoad.
> >
> >     However, I keep getting the error:
> >
> >     [5]PETSC ERROR: No support for this operation for this object type!
> >     [5]PETSC ERROR: Cannot get subcomm viewer for binary files or
> sockets unless SubViewer contains the rank 0 process
> >     [6]PETSC ERROR: PetscViewerGetSubViewer_Binary() line 46 in
> >     /data/scratch/lindnefn/software/petsc/src/sys/
> classes/viewer/impls/binary/binv.c
> >
> >
> > Do not truncate the stack.
> >
> > Run under valgrind.
> >
> >   Thanks,
> >
> >      Matt
> >
> >
> >     The rank 0 is included, as you can see below, I use PETSC_COMM_WORLD
> and the matrix is also created like that.
> >
> >     The code looks like:
> >
> >     PetscErrorCode ierr = 0;
> >     PetscViewer viewer;
> >     PetscViewerBinaryOpen(PETSC_COMM_WORLD, filename.c_str(),
> FILE_MODE_WRITE, &viewer); CHKERRV(ierr);
> >     MatView(matrix, viewer); CHKERRV(ierr);
> >     PetscViewerDestroy(&viewer);
> >
> >     Thanks,
> >     Florian
> >
> >
> >
> >
> > --
> > What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any
> > results to which their experiments lead.
> > -- Norbert Wiener
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160922/9cdbaca0/attachment.html>


More information about the petsc-users mailing list