[petsc-dev] how to use GPU, is my speed up sufficient?
Matthew Knepley
knepley at gmail.com
Thu Jul 12 10:50:03 CDT 2012
On Thu, Jul 12, 2012 at 10:42 AM, Olga Tramontano
<tramontanoolga at yahoo.it>wrote:
> Hi all
> I am very new to PETSc. I just learnt its class structure and I just
> understood that the interface Vec has been reimplemented with the class
> VecCUSP that is able to support GPU. My question is: if I have a simple
> code that allocates a vector and sets it with the database options, if I
> specify -vec_type seqcusp then this vector is allocated AND computed on the
> GPU?
> Because I compared the execution time of the same algorithm with the
> database options -vec_type seq and -vec_type seqcusp: these two times are
> very close.
>
For any performance question, you have to send the output of -log_summary
for all runs, or we have no idea what you actually did.
Matt
> This is the code: I'm just trying to compute how long does it take to
> execute the function VecScale:
> #include <petscvec.h>
> #include <string.h>
>
> #undef __FUNCT__
> #define __FUNCT__ "main"
> int main(int argc,char **argv)
> {
> Vec x;
> PetscInt n;
> PetscErrorCode ierr;
> PetscBool exists;
> PetscLogDouble t1,t2;
> PetscInt a=10;
>
> ierr = PetscInitialize(&argc,&argv,(char*)0,help);CHKERRQ(ierr);
>
> ierr = PetscOptionsGetInt(PETSC_NULL,"-size",&n,&exists); CHKERRQ(ierr);
>
> ierr = VecCreate(PETSC_COMM_SELF,&x);CHKERRQ(ierr);
> ierr = VecSetSizes(x,PETSC_DECIDE,n);CHKERRQ(ierr);
> ierr = VecSetFromOptions(x);CHKERRQ(ierr);
>
> ierr = VecSetRandom(x, PETSC_NULL); CHKERRQ(ierr);
>
> PetscGetTime(&t1);
> ierr = VecScale(x,a); CHKERRQ(ierr);
> PetscGetTime(&t2);
> ierr = PetscPrintf(PETSC_COMM_WORLD, "%2.5f\n",(t2-t1));
>
> ierr = VecDestroy(&x);CHKERRQ(ierr);
>
> ierr = PetscFinalize();
> return 0;
> }
>
> I use a vector of about 500000 numbers. With the database option
> -vec_type seqcusp , the method VecScale should call the
> method VecScale_SeqCUSP, right? Am I wrong? Should I do it expressly?
> Anyway with the option -vec_type seq , the method VecScale takes 0.05681
> seconds,
> with the option -vec_type seqcusp, the method VecScale takes 0.04242
> seconds.
>
> Is this speed up sufficient and realistic?
> thanks
>
> Olga
>
--
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-dev/attachments/20120712/289e7281/attachment.html>
More information about the petsc-dev
mailing list