How to copy global data to local ?

2009-12-02 Thread ming zhu
OK. It worksThank you

--- 09?12?1, ming zhu foolishzhu at yahoo.com.cn ???

???: ming zhu foolishzhu at yahoo.com.cn
??: Re: How to copy global data to local ?
???: PETSc users list petsc-users at mcs.anl.gov
??: 2009?12?1?,??,??10:29

It seems that MatGetSubMatrix() only get the local matrix for the processor? If 
U is global(PETSC_COMM_WORLD), the local matrix may not store the column or row 
I wanted. For example, if U is 4*4, and there are 4 processors, processors one 
has local matrix 2*2, but i need the third row, Then,MatGetSubmatrix() may not 
work

--- 09?12?1, Barry Smith bsmith at mcs.anl.gov ???

???: Barry Smith bsmith at mcs.anl.gov
??: Re: How to copy global data to local ?
???: PETSc users list petsc-users at mcs.anl.gov
??: 2009?12?1?,??,??10:23


On Nov 30, 2009, at 11:21 PM, ming zhu wrote:

 Hi
 I have a huge matrix U for
 all processors (PETSC_COMM_WORLD). I only want to copy only two rows (i,j) for 
each local processor. i,j is different for each processor and not related to 
rank.? I was trying to use a vector filter (like, 001). However, if the 
vector is PETSC_COMM_WORLD, it will be changed by different processor. So, how 
to make it ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
? ? ?
 ???^

???I do not understand what this means. To do the multiply you can and should 
use a vector of PETSC_COMM_WORLD.

???Also multiplying by a vector will not give you back rows of a matrix. Do 
you truly want the entire row of nonzeros of the matrix or something else. If 
you want the entire row or part of a row then you can use MatGetSubMatrix().

???Barry

 Thank you
 
 My original code is
 
 Vec filter
 VecCreate(PETSC_COMM_WORLD,filter);
 VecSetsizes(filter,PETSC_DECIDE,m);
 VecSetFromOptions(filter);
 
 Vecset(filter,0);
 VecSetValue(filter,i,1,INSERT_VALUES);
 
 ...
 MatMult(U, filter,ui);
 
 If I create filter with PETSC_COMM_SELF, it is impossible for U and filter to 
 multiply.
 
 

 
 
 
 ?





?


  ___ 
  ? 
http://card.mail.cn.yahoo.com/
-- next part --
An HTML attachment was scrubbed...
URL: 
http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20091202/bd7a0f30/attachment.htm


how to run petsc on different machine

2009-12-02 Thread ming zhu
?With?--download-mpich=1,Petsc install mpi. However, since I want to run my 
Petsc program on different machines and mpiexec -machinefile machineifle does 
not work.?It complains:invalid mpiexec argument -machinefile.
Do I have to install mpi for this?? Or do other way?
Thank you




  ___ 
  ? 
http://card.mail.cn.yahoo.com/
-- next part --
An HTML attachment was scrubbed...
URL: 
http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20091202/980951ec/attachment.htm


How to copy global data to local ?

2009-12-02 Thread ming zhu
HiI tried?MatGetSubMatrix() but I am a little confused by the column parameter. 
For exampleMy matrix is U (m * n). I want to get i,j rows to local.my code is?
PetscInt* rowindex,colindex;PetscMalloc...for (k= 0; k  n; k++)?? colindex[k] 
= k;
rowindex[0] = i;rowindex[1] = j;
MatGetSubMatrixRaw(U,1,i,n,indices,n,MAT_INITIAL_MATRIX,newmat);
What I hope is newmat is 2 * n matrix. But I failed.
Thank you

--- 09?12?1, Barry Smith bsmith at mcs.anl.gov ???

???: Barry Smith bsmith at mcs.anl.gov
??: Re: How to copy global data to local ?
???: PETSc users list petsc-users at mcs.anl.gov
??: 2009?12?1?,??,??10:35


???You misunderstand the usage of MatGetSubMatrix(). Any process can request 
ANY row, including rows that are not originally owned by that process.

???Barry

On Dec 1, 2009, at 8:29 AM, ming zhu wrote:

 It seems that MatGetSubMatrix() only get the local matrix for the processor? 
 If U is global(PETSC_COMM_WORLD), the local matrix may not store the column 
 or row I wanted. For example, if U is 4*4, and there are 4 processors, 
 processors one has local matrix 2*2, but i need the third row, 
 Then,MatGetSubmatrix() may not work
 
 --- 09?12?1, Barry Smith bsmith at mcs.anl.gov ???
 
 ???: Barry Smith bsmith at mcs.anl.gov
 ??: Re: How to copy global data to local ?
 ???: PETSc users list petsc-users at mcs.anl.gov
 ??: 2009?12?1?,??,??10:23
 
 
 On Nov 30, 2009, at 11:21 PM, ming zhu wrote:
 
  Hi
  I have a huge matrix U for all processors (PETSC_COMM_WORLD). I only want 
  to copy only two rows (i,j) for each local processor. i,j is different for 
  each processor and not related to rank.? I was trying to use a vector 
  filter (like, 001). However, if the vector is PETSC_COMM_WORLD, it 
  will be changed by different processor. So, how to make it ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? ? ? ^
 
? ? I do not understand what this means. To do the multiply you can and should 
use a vector of PETSC_COMM_WORLD.
 
? ? Also multiplying by a vector will not give you back rows of a matrix. Do 
you truly want the entire row of nonzeros of the matrix or something else. If 
you want the entire row or part of a row then you can use MatGetSubMatrix().
 
? ? Barry
 
  Thank you
 
  My original code is
 
  Vec filter
  VecCreate(PETSC_COMM_WORLD,filter);
  VecSetsizes(filter,PETSC_DECIDE,m);
  VecSetFromOptions(filter);
 
  Vecset(filter,0);
  VecSetValue(filter,i,1,INSERT_VALUES);
 
  ...
  MatMult(U, filter,ui);
 
  If I create filter with PETSC_COMM_SELF, it is impossible for U and filter 
  to multiply.
 
 
 
 
 
  ?
 
 
 ?




  ___ 
  ? 
http://card.mail.cn.yahoo.com/
-- next part --
An HTML attachment was scrubbed...
URL: 
http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20091202/37a23483/attachment.htm


How to copy global data to local ?

2009-12-02 Thread ming zhu
OK. I am now use MatGetSubMatrix.My code is as follows

? PetscMalloc(n*sizeof(PetscInt),indices);? 
? for (j = 0; j  n; j++)
? {?? 
? indices[j] = j; 
? } 
? ISCreateGeneral(PETSC_COMM_SELF,n,indices,iy); // get all columns 
?

?? PetscMalloc(2*sizeof(PetscInt),indices);? 
??? indices[0] = i;
??? indices[1] = j;
??? ISCreateGeneral(PETSC_COMM_SELF,2,indices,ix); // only get i,j rows

??? Mat ui,uj; 
// I am not sure how to set the third parameter : how many local  columns.. 
Since I want all columns, I set it to n
 ierr = MatGetSubMatrix(U,ix,iy,n, MAT_INITIAL_MATRIX,ui);CHKERRQ(ierr);

What I really hope is to 
 
??? for (i = 0; i  n; i++)
{
? ? PetscInt row = 0;
? MatGetValues(ui,1,row,1,i,u_ik);
}
It does not work. I tried to change the n to PETSC_DECIDE, it still does not 
work

So, I really doubt that whether I can get the entire row of the matrix.

BTW, the matrix is created as follows:
?MatCreateMPIDense(PETSC_COMM_WORLD,PETSC_DECIDE,PETSC_DECIDE,m,n,PETSC_NULL,U)

THank you
--- 09?12?2, Barry Smith bsmith at mcs.anl.gov ???

???: Barry Smith bsmith at mcs.anl.gov
??: Re: How to copy global data to local ?
???: PETSc users list petsc-users at mcs.anl.gov
??: 2009?12?2?,??,??1:46


???Don't know what MatGetSubMatrixRaw() is, but based on the calling sequence 
you are asking for the ith row whatever that is, and n columns in the array 
indices

???For MatGetSubMatrix() each process can ask for any rows it wants, but all 
the processors have to ask for the same columns that are wanted.

???Barry

On Dec 1, 2009, at 9:59 PM, ming zhu wrote:

 Hi
 I tried MatGetSubMatrix() but I am a little confused by the column parameter. 
 For example
 My matrix is U (m * n). I want to get i,j rows to local.
 my code is
 
 PetscInt* rowindex,colindex;
 PetscMalloc...
 for (k= 0; k  n; k++)
? ? colindex[k] = k;
 
 rowindex[0] = i;
 rowindex[1] = j;
 
 MatGetSubMatrixRaw(U,1,i,n,indices,n,MAT_INITIAL_MATRIX,newmat);
 
 What I hope is newmat is 2 * n matrix. But I failed.
 
 Thank you
 
 
 --- 09?12?1, Barry Smith bsmith at mcs.anl.gov ???
 
 ???: Barry Smith bsmith at mcs.anl.gov
 ??: Re: How to copy global data to local ?
 ???: PETSc users list petsc-users at mcs.anl.gov
 ??: 2009?12?1?,??,??10:35
 
 
? ? You misunderstand the usage of MatGetSubMatrix(). Any process can request 
ANY row, including rows that are not originally owned by that process.
 
? ? Barry
 
 On Dec 1, 2009, at 8:29 AM, ming zhu wrote:
 
  It seems that MatGetSubMatrix() only get the local matrix for the 
  processor? If U is global(PETSC_COMM_WORLD), the local matrix may not store 
  the column or row I wanted. For example, if U is 4*4, and there are 4 
  processors, processors one has local matrix 2*2, but i need the third row, 
  Then,MatGetSubmatrix() may not work
 
  --- 09?12?1, Barry Smith bsmith at mcs.anl.gov ???
 
  ???: Barry Smith bsmith at mcs.anl.gov
  ??: Re: How to copy global data to local ?
  ???: PETSc users list petsc-users at mcs.anl.gov
  ??: 2009?12?1?,??,??10:23
 
 
  On Nov 30, 2009, at 11:21 PM, ming zhu wrote:
 
   Hi
   I have a huge matrix U for all processors (PETSC_COMM_WORLD). I only want 
   to copy only two rows (i,j) for each local processor. i,j is different 
   for each processor and not related to rank.? I was trying to use a vector 
   filter (like, 001). However, if the vector is PETSC_COMM_WORLD, 
   it will be changed by different processor. So, how to make it ?
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
 ? ? ? ? ? ? ? ? ? ^
 
 ? ? I do not understand what this means. To do the multiply you can and 
 should use a vector of PETSC_COMM_WORLD.
 
 ? ? Also multiplying by a vector will not give you back rows of a matrix. 
 Do you truly want the entire row of nonzeros of the matrix or something 
 else. If you want the entire row or part of a row then you can use 
 MatGetSubMatrix().
 
 ? ? Barry
 
   Thank you
  
   My original code is
  
   Vec filter
   VecCreate(PETSC_COMM_WORLD,filter);
   VecSetsizes(filter,PETSC_DECIDE,m);
   VecSetFromOptions(filter);
  
   Vecset(filter,0);
   VecSetValue(filter,i,1,INSERT_VALUES);
  
   ...
   MatMult(U, filter,ui);
  
   If I create filter with PETSC_COMM_SELF, it is impossible for U and 
   filter to multiply.
  
  
  
  
  
   ?
 
 
  ?
 
 
 ?




  ___ 
  ? 
http://card.mail.cn.yahoo.com/
-- next part --
An HTML attachment was scrubbed...
URL: 
http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20091202/30912a47/attachment.htm


How to copy global data to local ?

2009-12-02 Thread Barry Smith

   Let's move this over to petsc-maint at mcs.anl.gov to cut the traffic  
on petsc-users See below.
On Dec 2, 2009, at 12:33 AM, ming zhu wrote:

 OK. I am now use MatGetSubMatrix.My code is as follows

   PetscMalloc(n*sizeof(PetscInt),indices);
   for (j = 0; j  n; j++)
   {
   indices[j] = j;
   }
   ISCreateGeneral(PETSC_COMM_SELF,n,indices,iy); // get all columns
  .

PetscMalloc(2*sizeof(PetscInt),indices);
 indices[0] = i;
 indices[1] = j;
 ISCreateGeneral(PETSC_COMM_SELF,2,indices,ix); // only get  
 i,j rows

 Mat ui,uj;
 // I am not sure how to set the third parameter : how many local   
 columns. Since I want all columns, I set it to n
  ierr = MatGetSubMatrix(U,ix,iy,n,  
 MAT_INITIAL_MATRIX,ui);CHKERRQ(ierr);

 What I really hope is to

 for (i = 0; i  n; i++)
 {
 PetscInt row = 0;
   MatGetValues(ui,1,row,1,i,u_ik);
 }
 It does not work. I tried to change the n to PETSC_DECIDE, it still  
 does not work

^ 
^ 
^ 
^ 
^ 
^ 
^ 
^ 
^ 
^ 
^ 
^ 
^ 
^ 
^ 

^ 


Saying it does not work is extremely uninformative and makes it  
difficult for us to know what happened and thus make useful  
suggestions. Please say exactly what goes wrong and cut and paste all  
error messages. At this point we would be totally guessing what is  
happening.

Barry


 So, I really doubt that whether I can get the entire row of the  
 matrix.

 BTW, the matrix is created as follows:
   
 MatCreateMPIDense 
 (PETSC_COMM_WORLD,PETSC_DECIDE,PETSC_DECIDE,m,n,PETSC_NULL,U)

 THank you
 --- 09?12?2, Barry Smith bsmith at mcs.anl.gov ? 
 ??

 ???: Barry Smith bsmith at mcs.anl.gov
 ??: Re: How to copy global data to local ?
 ???: PETSc users list petsc-users at mcs.anl.gov
 ??: 2009?12?2?,??,??1:46


Don't know what MatGetSubMatrixRaw() is, but based on the calling  
 sequence you are asking for the ith row whatever that is, and n  
 columns in the array indices

For MatGetSubMatrix() each process can ask for any rows it wants,  
 but all the processors have to ask for the same columns that are  
 wanted.

Barry

 On Dec 1, 2009, at 9:59 PM, ming zhu wrote:

  Hi
  I tried MatGetSubMatrix() but I am a little confused by the column  
 parameter. For example
  My matrix is U (m * n). I want to get i,j rows to local.
  my code is
 
  PetscInt* rowindex,colindex;
  PetscMalloc...
  for (k= 0; k  n; k++)
 colindex[k] = k;
 
  rowindex[0] = i;
  rowindex[1] = j;
 
  MatGetSubMatrixRaw(U,1,i,n,indices,n,MAT_INITIAL_MATRIX,newmat);
 
  What I hope is newmat is 2 * n matrix. But I failed.
 
  Thank you
 
 
  --- 09?12?1, Barry Smith bsmith at mcs.anl.gov ? 
 ??
 
  ???: Barry Smith bsmith at mcs.anl.gov
  ??: Re: How to copy global data to local ?
  ???: PETSc users list petsc-users at mcs.anl.gov
  ??: 2009?12?1?,??,??10:35
 
 
 You misunderstand the usage of MatGetSubMatrix(). Any process  
 can request ANY row, including rows that are not originally owned by  
 that process.
 
 Barry
 
  On Dec 1, 2009, at 8:29 AM, ming zhu wrote:
 
   It seems that MatGetSubMatrix() only get the local matrix for  
 the processor  If U is global(PETSC_COMM_WORLD), the local matrix  
 may not store the column or row I wanted. For example, if U is 4*4,  
 and there are 4 processors, processors one has local matrix 2*2, but  
 i need the third row, Then,MatGetSubmatrix() may not work
  
   --- 09?12?1, Barry Smith bsmith at mcs.anl.gov ? 
 ??
  
   ???: Barry Smith bsmith at mcs.anl.gov
   ??: Re: How to copy global data to local ?
   ???: PETSc users list petsc-users at mcs.anl.gov
   ??: 2009?12?1?,??,??10:23
  
  
   On Nov 30, 2009, at 11:21 PM, ming zhu wrote:
  
Hi
I have a huge matrix U for all processors (PETSC_COMM_WORLD).  
 I only want to copy only two rows (i,j) for each local processor.  
 i,j is different for each processor and not related to rank.  I was  
 trying to use a vector filter (like, 001). However, if the  
 vector is PETSC_COMM_WORLD, it will be changed by different  
 processor. So, how to make it ?
   
  
   
   
   ^ 
 
  
  I do not understand what this means. To do the multiply you  
 can and should use a vector of PETSC_COMM_WORLD.
  
  Also multiplying by a vector will not give you back rows of  
 a matrix. Do you truly want the entire row of nonzeros of the matrix  
 or something else. If you want the entire row or part of a row then  
 you can use MatGetSubMatrix().
  
  Barry
  
Thank you
   
My original code is
   
Vec filter
VecCreate(PETSC_COMM_WORLD,filter);
VecSetsizes(filter,PETSC_DECIDE,m);
VecSetFromOptions(filter);
   
Vecset(filter,0);

optimized complex number kernel

2009-12-02 Thread Craig Tanis
Hi,

The Petsc 3 manual (pdf)mentions using an optimized fortran kernel for complex 
numbers, that somehow uses the same C interface.  It refers to a document on 
how to build these kernels, but that document does not appear to be in the 
tarball (or on the anl.gov website).

Furthermore, the FAQ on the website only mentions C and C++ in the section on 
complex number performance...

If someone could clarify what was possible, and where to look for more 
information, that would be great!
thanks,
Craig


optimized complex number kernel

2009-12-02 Thread Satish Balay
The performance difference between c/c++ kernels and fortran kernels -
or c-complex/c++-complex can be compiler specific. You can build all
relavent versions [each with a different PETSC_ARCH] and see if it
makes a difference for you code.

The relavent configure options are:
--with-fortran-kernels=generic [default 'none']
--with-clanguage=cxx [or default 'c']
--with-scalar-type=complex [default 'real']

Satish

On Wed, 2 Dec 2009, Craig Tanis wrote:

 Hi,
 
 The Petsc 3 manual (pdf)mentions using an optimized fortran kernel for 
 complex numbers, that somehow uses the same C interface.  It refers to a 
 document on how to build these kernels, but that document does not appear to 
 be in the tarball (or on the anl.gov website).
 
 Furthermore, the FAQ on the website only mentions C and C++ in the section on 
 complex number performance...
 
 If someone could clarify what was possible, and where to look for more 
 information, that would be great!
 thanks,
 Craig



optimized complex number kernel

2009-12-02 Thread Barry Smith

Craig,

 Thanks for pointing this out. I have updated the manual and  
installation.html in PETSc-dev to explicitly provide this information.

Barry

On Dec 2, 2009, at 11:09 AM, Satish Balay wrote:

 The performance difference between c/c++ kernels and fortran kernels -
 or c-complex/c++-complex can be compiler specific. You can build all
 relavent versions [each with a different PETSC_ARCH] and see if it
 makes a difference for you code.

 The relavent configure options are:
 --with-fortran-kernels=generic [default 'none']
 --with-clanguage=cxx [or default 'c']
 --with-scalar-type=complex [default 'real']

 Satish

 On Wed, 2 Dec 2009, Craig Tanis wrote:

 Hi,

 The Petsc 3 manual (pdf)mentions using an optimized fortran kernel  
 for complex numbers, that somehow uses the same C interface.  It  
 refers to a document on how to build these kernels, but that  
 document does not appear to be in the tarball (or on the anl.gov  
 website).

 Furthermore, the FAQ on the website only mentions C and C++ in the  
 section on complex number performance...

 If someone could clarify what was possible, and where to look for  
 more information, that would be great!
 thanks,
 Craig