Hi Karl,

Thanks for the details.

I am only just now getting around to implementing the faster access as per
our previous emails
https://sourceforge.net/p/viennacl/mailman/viennacl-support/
thread/cafgdergddnbu2yfd4u2qxsrjvwhmccenju82hbg4+tzerg5...@mail.gmail.com/

Does this look right?

  viennacl::context host_ctx(viennacl::MAIN_MEMORY);
    auto size = vl_C.nnz();
    viennacl::copy(C,vl_C); // copy C -> vl_C, sets up the sparsity pattern
    // wrap:
    viennacl::vector_base<unsigned int> init_temporary(vl_C.handle(),
viennacl::compressed_matrix<vcl_scalar_type>::size_type(size+1), 0, 1);
    // write:
    init_temporary = viennacl::zero_vector<unsigned
int>(viennacl::compressed_matrix<vcl_scalar_type>::size_type(size+1),
host_ctx);

Second, when I am writing to the element array to fill it on a per-row
basis, what is the best way to do that? Ie, index into row N, then write
let's say 5 non-zero elements. I can of course obtain the row offset from
the CSR vectors. But how to I write to that offset?

Cheers
Chris

On 15 September 2017 at 07:05, Karl Rupp <[email protected]> wrote:

> Hi Chris,
>
> I would like to directly write to the CSR vector. Specifically, I would
>> like to zero the element vector (in prep for a fill) *without* removing the
>> sparsity pattern.
>>
>> Once I obtain the handle via A.handle(), what do I do with it?
>>
>
> If you want to zero it right on the target device, then wrap it in a
> vector and write a zero vector to it. See here for an example:
> https://github.com/viennacl/viennacl-dev/blob/master/viennac
> l/compressed_matrix.hpp#L659
> The relevant code:
>
> {
>  // wrap:
>  viennacl::vector_base<unsigned int> init_temporary(row_buffer_,
> size_type(rows+1), 0, 1);
>  // write:
>  init_temporary = viennacl::zero_vector<unsigned int>(size_type(rows+1),
> ctx);
> }
>
> The alternative is to use viennacl::backend::memory_write(), which in the
> case of GPUs involves the zeros to be sent via PCI-Express.
>
> Best regards,
> Karli
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
ViennaCL-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/viennacl-support

Reply via email to