Copying a MPI vector into a small MPI vector
liu chang
liuchangjohn at gmail.com
Wed Dec 6 00:56:06 CST 2006
Hi, I'm fairly new to PETSc so excuse me if the problem seems obvious.
I'm trying to copy the first m entries of a MPI vector of size n (m <
n) into another MPI vector of size m. From the Petsc documentation I
think I need to use VecScatter, so I wrote the following code
test.cpp:
int main(int argc, char *argv[])
{
int info;
PetscInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);
Vec w, wv;
info = VecCreateMPI(PETSC_COMM_WORLD, PETSC_DECIDE, 100, &w); CHKERRQ(info);
info = VecCreateMPI(PETSC_COMM_WORLD, PETSC_DECIDE, 110, &wv);
CHKERRQ(info);
IS wv2w;
VecScatter s_wv2w;
info = ISCreateStride(PETSC_COMM_WORLD, 100, 0, 1, &wv2w); CHKERRQ(info);
info = VecScatterCreate(wv, wv2w, w, PETSC_NULL, &s_wv2w); CHKERRQ(info);
// actual copying skipped
PetscFinalize();
return 0;
}
The code runs fine on a single process, but when I run it over 2 processes:
mpirun -np 2 -machinefile ~/machines.LINUX test
The program crashes on the VecScatterCreate() statement:
------------------------------------------------------------------------
Petsc Release Version 2.3.1, Patch 15, Thu Jul 6 21:32:01 CDT 2006 HG
revision: dc39078b37aa6becf2c4f8b06facf07566bf5454
See docs/changes/index.html for recent updates.
See docs/faq.html for hints about trouble shooting.
See docs/index.html for manual pages.
------------------------------------------------------------------------
... Wed Dec 6 14:52:09 2006
Libraries linked from ...
Configure run at Sat Jul 8 15:09:13 2006
Configure options --download-f-blas-lapack=1 --with-mpi-dir=/opt/mpich
-with-clanguage=C++ --with-shared
------------------------------------------------------------------------
[0]PETSC ERROR: VecScatterCreate() line 1350 in src/vec/vec/utils/vscat.c
[0]PETSC ERROR: Nonconforming object sizes!
[0]PETSC ERROR: Local scatter sizes don't match!
[0]PETSC ERROR: User provided function() line 20 in test.cpp
------------------------------------------------------------------------
Petsc Release Version 2.3.1, Patch 15, Thu Jul 6 21:32:01 CDT 2006 HG
revision: dc39078b37aa6becf2c4f8b06facf07566bf5454
See docs/changes/index.html for recent updates.
See docs/faq.html for hints about trouble shooting.
See docs/index.html for manual pages.
------------------------------------------------------------------------
... Wed Dec 6 14:52:39 2006
Libraries linked from ...
Configure run at Sat Jul 8 15:09:13 2006
Configure options --download-f-blas-lapack=1 --with-mpi-dir=/opt/mpich
-with-clanguage=C++ --with-shared
------------------------------------------------------------------------
[1]PETSC ERROR: VecScatterCreate() line 1350 in src/vec/vec/utils/vscat.c
[1]PETSC ERROR: Nonconforming object sizes!
[1]PETSC ERROR: Local scatter sizes don't match!
[1]PETSC ERROR: User provided function() line 20 in test.cpp
So the problem is `local scatter sizes don't match'. I guess it's
because some entries need to be passed from one process to the other
due to the different layouts of the two vectors. So if VecScatter
refuses to do it for me, how can it be done? Any help is greatly
appreciated.
Liu Chang
More information about the petsc-users
mailing list