On Thu, Jul 12, 2012 at 10:42 AM, Olga Tramontano <span dir="ltr"><<a href="mailto:tramontanoolga@yahoo.it" target="_blank">tramontanoolga@yahoo.it</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div style="font-size:12pt;font-family:times new roman,new york,times,serif"><div style="font-family:'times new roman','new york',times,serif;font-size:12pt">Hi all</div><div style="font-family:'times new roman','new york',times,serif;font-size:12pt">
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?</div>
<div style="font-family:'times new roman','new york',times,serif;font-size:12pt">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.</div>
</div></div></blockquote><div><br></div><div>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.</div><div><br></div><div> Matt</div><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-size:12pt;font-family:times new roman,new york,times,serif"><div style="font-family:'times new roman','new york',times,serif;font-size:12pt">
This is the code: I'm just trying to compute how long does it take to execute the function VecScale:</div><div><div><font face="times new roman, new york, times, serif">#include <petscvec.h></font></div><div><font face="times new roman, new york, times, serif">#include <string.h></font></div>
<div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif">#undef __FUNCT__</font></div><div><font face="times new roman, new york, times, serif">#define __FUNCT__ "main"</font></div>
<div><font face="times new roman, new york, times, serif">int main(int argc,char **argv)</font></div><div><font face="times new roman, new york, times, serif">{</font></div><div><font face="times new roman, new york, times, serif"> Vec
x;</font></div><div><font face="times new roman, new york, times, serif"> PetscInt n;</font></div><div><font face="times new roman, new york, times, serif"> PetscErrorCode ierr;</font></div><div><font face="times new roman, new york, times, serif"> PetscBool exists;</font></div>
<div><font face="times new roman, new york, times, serif"> PetscLogDouble t1,t2;</font></div><div><font face="times new roman, new york, times, serif"> PetscInt a=10;</font></div><div><font face="times new roman, new york, times, serif"><br>
</font></div><div><span style="font-family:'times new roman','new york',times,serif"> ierr = PetscInitialize(&argc,&argv,(char*)0,help);CHKERRQ(ierr); </span><br></div><div><font face="times new roman, new york, times, serif"><br>
</font></div><div><font face="times new roman, new york, times, serif"> ierr =
PetscOptionsGetInt(PETSC_NULL,"-size",&n,&exists); CHKERRQ(ierr);</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><span style="font-family:'times new roman','new york',times,serif"> ierr = VecCreate(PETSC_COMM_SELF,&x);CHKERRQ(ierr);</span><br>
</div><div><font face="times new roman, new york, times, serif"> ierr = VecSetSizes(x,PETSC_DECIDE,n);CHKERRQ(ierr);</font></div><div><font face="times new roman, new york, times, serif"> ierr = VecSetFromOptions(x);CHKERRQ(ierr);</font></div>
<div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif"> ierr = VecSetRandom(x, PETSC_NULL); CHKERRQ(ierr);</font></div><div><font face="times new roman, new york, times, serif"><br>
</font></div><div><font face="times new roman, new york, times, serif"> PetscGetTime(&t1);</font></div><div><font face="times
new roman, new york, times, serif"> ierr = VecScale(x,a); CHKERRQ(ierr);</font></div><div><font face="times new roman, new york, times, serif"> PetscGetTime(&t2);</font></div><div><font face="times new roman, new york, times, serif"> ierr = PetscPrintf(PETSC_COMM_WORLD, "%2.5f\n",(t2-t1));</font></div>
<div><font face="times new roman, new york, times, serif"><br></font></div><div><span style="font-family:'times new roman','new york',times,serif"> ierr = VecDestroy(&x);CHKERRQ(ierr);</span><br></div>
<div><font face="times new roman, new york, times, serif"><br></font></div><div><span style="font-family:'times new roman','new york',times,serif"> ierr = PetscFinalize();</span><br></div><div><font face="times new roman, new york, times, serif"> return 0;</font></div>
<div><font face="times new roman, new york, times, serif">}</font></div><div><font face="times new roman, new york, times,
serif"><br></font></div><div><font face="times new roman, new york, times, serif">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?</font></div>
<div><font face="times new roman, new york, times, serif">Anyway with the option -vec_type seq , the method VecScale takes 0.05681 seconds, </font></div><div><font face="times new roman, new york, times, serif">with the option -vec_type seqcusp, </font><span style="font-family:'times new roman','new york',times,serif"> </span><span style="font-family:'times new roman','new york',times,serif">the method VecScale takes 0.04242 seconds.</span></div>
<div><span style="font-family:'times new roman','new york',times,serif"><br></span></div><div><span style="font-family:'times new roman','new york',times,serif">Is this
speed up sufficient and realistic?</span></div><div><span style="font-family:'times new roman','new york',times,serif">thanks</span></div><span class="HOEnZb"><font color="#888888"><div><span style="font-family:'times new roman','new york',times,serif"><br>
</span></div><div><span style="font-family:'times new roman','new york',times,serif">Olga</span></div></font></span></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>