[petsc-users] MatMult scalability problem
Matthew Knepley
knepley at gmail.com
Wed May 2 11:36:29 CDT 2012
On Wed, May 2, 2012 at 12:01 PM, Javier Fresno <jfresno at infor.uva.es> wrote:
>
>
> I have a very simple Petsc program that multiplies a matrix and a vector
> several times. It works fine but it has some scalability issues. I execute
> it in a shared memory machine with 16 processors and it only runs 5 or 6
> times faster (only taking into account the MatMult call). I have programmed
> the same algorithm with C and MPI and it shows a proper speedup (around 14
> or 15). The matrices I use have millions of non zero elements, so I think
> they are big enough.
>
> What can I do to get the same speedup that in the manual C version?
>
> I enclose an except of the code. Thank you in advance.
>
We need the output of -log_summary to say anything about performance. Also,
we need to know what the
machine architecture is.
Matt
> Javier
>
>
>
> /**
> * Main function
> */
> int main(int argc, char ** argv){
>
> // Initialize Petsc
> PetscInitialize(&argc, &argv, (char *) 0, NULL);
>
> // Timers
> PetscLogDouble t_start, t_end;
>
> // File Viewer
> PetscViewer fd;
> PetscViewerBinaryOpen(PETSC_**COMM_WORLD,"matrix_file",FILE_**
> MODE_READ,&fd);
>
> // M matrix
> Mat M;
> MatCreate(PETSC_COMM_WORLD,&M)**;
> MatSetFromOptions(M);
> MatLoad(M,fd);
> PetscViewerDestroy(&fd);
> MatAssemblyBegin(M,MAT_FINAL_**ASSEMBLY);
> MatAssemblyEnd(M,MAT_FINAL_**ASSEMBLY);
>
> PetscInt n, m, local_n, local_m;
> MatGetSize(M,&n,&m);
> MatGetLocalSize(M,&local_n,&**local_m);
>
> // b and c vectors
> Vec b,c;
> VecCreate(PETSC_COMM_WORLD,&b)**;
> VecSetFromOptions(b);
> VecSetSizes(b,local_n,n);
>
> VecCreate(PETSC_COMM_WORLD,&c)**;
> VecSetFromOptions(c);
> VecSetSizes(c,local_n,n);
>
> init_vector_values(b);
>
> VecAssemblyBegin(b);
> VecAssemblyEnd(b);
>
>
> // Main computation
> PetscGetTime(&t_start);
> int i;
> for(i=0; i<iter/2; i++){
> MatMult(M,b,c);
> MatMult(M,c,b);
> }
> PetscGetTime(&t_end);
>
> PetscPrintf(PETSC_COMM_WORLD,"**Comp time: %lf\n",t_end-t_start);
>
> PetscFinalize();
>
> return 0;
> }
>
>
>
--
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/20120502/710c6b2a/attachment.htm>
More information about the petsc-users
mailing list