Hi Aleksandra,

I suggest you create a viennacl::compressed_matrix with the respective 
numbers of rows (N), columns (M) and nonzeros (nnz):

viennacl::compressed_matrix<T> A(N, M, nnz);

If you have the CUDA backend enabled (via VIENNACL_WITH_CUDA), this will 
allocate the necessary buffers.

Then you can extract the CUDA raw points via viennacl::cuda_arg() as
   viennacl::cuda_arg<unsigned int>(A.handle1()); // row array
   viennacl::cuda_arg<unsigned int>(A.handle2()); // column indices array
   viennacl::cuda_arg<T>(A.handle0()); // nonzeros
and fill the arrays with your kernel (mind the CSR format and keep 
column indices in increasing order for each row).

When you're done, call
  A.generate_row_block_information();
and that's it :-)

Best regards,
Karli



On 12/08/2016 05:17 PM, Aleksandra Chuchvara wrote:
> Hello,
>
>
>
> I would like to use ViennaCL library to solve a sparse linear system. I know 
> exact number of non-zero elements in the matrix, so I wanted to use a 
> CUDA-kernel to fill-in vectors of elements, row and column indices and then 
> assign this data to a compressed matrix. I thought I could do smth like that:
>
> vcl_compressed_matrix.handle() = vcl_val.handle();
>
> vcl_compressed_matrix.handle1() = vcl_row.handle();
>
> vcl_compressed_matrix.handle2() = vcl_col.handle();
>
> But in this way I am getting a memory error... so I guess I am missing 
> something here, or it is a completely wrong approach.
>
> I could not find any method that takes three vectors or buffers as parameters.
>
> So my question is, how can I populate a compressed matrix from CUDA buffers?
>
>
>
> Thank you,
>
> Aleksandra
>
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today.http://sdm.link/xeonphi
> _______________________________________________
> ViennaCL-support mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/viennacl-support
>


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
_______________________________________________
ViennaCL-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/viennacl-support

Reply via email to