Hi KarlBased on all your suggestions,I came up with this implementation:
      // Copy Sparse Eigen matrices to Dense viennacl matrices      typedef 
Eigen::Matrix<ScalarType, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> 
RMMatrix;      viennacl::matrix<ScalarType, viennacl::row_major> 
vcl_A(source->rows(), source->cols());      viennacl::copy(RMMatrix(*source), 
vcl_A);      viennacl::matrix<ScalarType, viennacl::row_major> 
vcl_B(target->rows(), target->cols());      viennacl::copy(RMMatrix(*target), 
vcl_B);      viennacl::matrix<ScalarType, viennacl::row_major> 
vcl_C(result->rows(), result->cols());      // Implement the matrix 
multiplication on the GPU.      vcl_C  = viennacl::linalg::prod(vcl_A, vcl_B);  
    // Copy the matrix back to the host matrix      RMMatrix temp = 
RMMatrix(*result);      viennacl::copy(vcl_C, temp);      (*result) = 
temp.sparseView();
Essentially, I have a 100K x 100k matrix that I have to generate. I split it up 
into blocks with a max block size of 2048 x 2048Thus, source, target, and 
result will all have dimensions of 2048 x 2048. I end getting a result. 
However, I was wondering if I can do something differently? For example,can I 
use fast_copy, async_copy anywhere? I would like to avoid this lineRMMatrix 
temp = RMMatrix(*result);
but I am unable to convert to a dense matrix, implicitly.
If you notice, I am converting my sparse matrices to dense matrices and then 
implementing a multiplication. Is this a good idea? I need to do this as I am 
not sure when my matrix will become sparse or dense. Do we have any heuristics 
that can help us (e.g., if source->nonZeros() > (source->rows() x 
source->cols())/2, then switch to a dense multiplication, else use a 
sparse?).... 
If I do a naive sparse matrix multiplication, this is the code that I have:     
 viennacl::compressed_matrix<ScalarType> vcl_A(source->rows(), source->cols()); 
     viennacl::copy((*source), vcl_A);      
viennacl::compressed_matrix<ScalarType> vcl_B(target->rows(), target->cols());  
    viennacl::copy((*target), vcl_B);      
viennacl::compressed_matrix<ScalarType> vcl_C(result->rows(), result->cols());  
    // Implement the matrix multiplication on the GPU.       vcl_C  = 
viennacl::linalg::prod(vcl_A, vcl_B);      // Copy the matrix back to the host 
matrix      viennacl::copy(vcl_C, (*result));
 Thanks and Regards
Sumit
      From: Karl Rupp <[email protected]>
 To: Sumit Kumar <[email protected]> 
Cc: "[email protected]" 
<[email protected]> 
 Sent: Monday, August 3, 2015 1:23 AM
 Subject: Re: [ViennaCL-devel] ViennaCL reductions
   
Hi Sumit,

 > I was trying to run sparse matrix multiplication, but one of my explicit
> template typedefs had Int. After some digging, I found out that CSR only
> supported Float or double. Is there any reason for this? Can we also
> have support for other templates? (like int ?)

It is technically possible, but we haven't implemented it yet. After 5 
years you are the first to even ask for it ;-)


> Another thing would be the alignment order. Suppose I have a Row-major
> Sparse Eigen matrix, then I can copy it to a (Row-Major ?) VCL
> compressed matrix. What about a column-major sparse Eigen matrix?

If you can point me to a fast, massively parallel column-major 
matrix-vector multiplication routine, I look into it. However, as far as 
I know, there is no such routine for general sparse matrices, hence it 
does not make sense for us to support it.

Best regards,
Karli





> ------------------------------------------------------------------------
> *From:* Karl Rupp <[email protected]>
> *To:* Sumit Kumar <[email protected]>
> *Cc:* "[email protected]"
> <[email protected]>
> *Sent:* Friday, July 31, 2015 9:04 PM
> *Subject:* Re: [ViennaCL-devel] ViennaCL reductions
>
> Hi Sumit,
>
>  > I am aware that Eigen can do it for its matrices and I am also aware
>  > that VCL cannot do it natively. My question was this:
>  > In your example of interfacing with Eigen, you have shown a VCL dense
>  > matrix interfacing with an Eigen dense matrix. Do you have any example
>  > of interfacing an Eigen Sparse matrix with a VCL dense matrix?
>
> No, we don't have this.
>
>
>
>
> Best regards,
> Karli
>
>
>
>



  
------------------------------------------------------------------------------
_______________________________________________
ViennaCL-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/viennacl-devel

Reply via email to