I am trying out PETSc's GPU features for the first time. <div><br></div><div>After skimming, a paper on the PETSc-GPU interface. <a href="http://www.stanford.edu/~vminden/docs/gpus.pdf">http://www.stanford.edu/~vminden/docs/gpus.pdf</a></div>
<div><br></div><div>I just wanted to confirm whether the following observation is correct. </div><div><br></div><div>Suppose I want to solve Ax=b and set the PETSc vector- and matrix-type from the command-line </div><div>
<br></div><div>Then to make my code run on the GPU, *all* I need to do is to </div><div> (1) set the "-vec_type" at the command-line as "seqcusp" or "<font class="Apple-style-span" face="monospace"><span class="Apple-style-span" style="white-space:pre">mpicusp</span></font>" (depending on whether I am using a single/multiple GPU process )</div>
<div><div> (2) set the "-mat_type" at the command-line as "seqaijcusp" or "<font class="Apple-style-span" face="monospace"><span class="Apple-style-span" style="white-space:pre">mpiaijcusp</span></font>" (depending on whether I am using a single/multiple CPU process )</div>
<div> (3) Solving the system Ax=b is done the "usual" way (see below) i.e nothing CUDA specific. </div></div><div><div> </div><div> ierr = KSPCreate(PETSC_COMM_WORLD,&ksp);CHKERRQ(ierr);</div><div>
ierr = KSPSetOperators(ksp,A,A,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr);</div><div> ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr);</div><div> ierr = PCSetType(pc,PCJACOBI);CHKERRQ(ierr);</div><div> ierr = KSPSetTolerances(ksp,1.e-5,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT);CHKERRQ(ierr);</div>
</div><div><div><br></div><div> if (nonzeroguess) {</div><div> PetscScalar p = .5;</div><div> ierr = VecSet(x,p);CHKERRQ(ierr);</div><div> ierr = KSPSetInitialGuessNonzero(ksp,PETSC_TRUE);CHKERRQ(ierr);</div><div>
}</div><div>ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr); </div></div><div><br></div><div>(4) Looking at the type of the vector and the matrix, PETSc hands over the control to the corresponding CUSP solver. </div><div><br></div>
<div><br></div><div><br></div><div>Thank you,</div><div><br></div><div>Gaurish </div>