[petsc-users] direct access of seqcusp Vec

Barry Smith bsmith at mcs.anl.gov
Mon Oct 3 08:10:22 CDT 2011


On Oct 2, 2011, at 11:13 PM, Shiyuan wrote:

> 
> 
> On Thu, Sep 29, 2011 at 3:22 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> 
> On Sep 29, 2011, at 2:56 PM, Shiyuan wrote:
> 
> > What about a direct access to seqaijcusp Mat? Is there a function call which return the pointed to the cusp::csr_matrix ?
> 
>   No. But look at the source code to MatMult_SeqAIJCusp and you will see how it may be accessed.
> 
>  
> In MatMult_SeqAIJCUSP, if the mat is CSR, the result first is stored in tmpvec, and then is permuted before stored to the final destination yy. What's the reason for doing that? 

    You ignored the if (usecprow) flag. This flag is set when many many of the matrix rows are identically zero, in that case tempvec computes the resulting vector entries for the nonzero rows and the the "permute" sticks the result back into the larger vector.  Normally just the second case of the if statement is used and it is just a cusp multiply. 

   
> Does petsc also support other format than csr?

   If it did it would be in the code somewhere, we don't have secret code you cannot see. 

    Some user tried another format and got good performance but hasn't given us the code for that.

    Barry

> The part of the code is attached:
> 
> 
>  if (usecprow){ /* use compressed row format */
>     try {
>       cusp::multiply(*cuspstruct->mat,*xarray,*cuspstruct->tempvec);
>       ierr = VecSet_SeqCUSP(yy,0.0);CHKERRQ(ierr);
>       thrust::copy(cuspstruct->tempvec->begin(),cuspstruct->tempvec->end(),thrust::make_permutation_iterator(yarray->begin(),cuspstruct->indices->begin()));
>     } catch (char* ex) {
>       SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"CUSP error: %s", ex);
>     }
>   } else { /* do not use compressed row format */
>     try {
>       cusp::multiply(*cuspstruct->mat,*xarray,*yarray);
>     } catch(char* ex) {
>       SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"CUSP error: %s", ex);
>     } 
>   }
> 



More information about the petsc-users mailing list