Hey,

On 04/06/2017 11:48 PM, Chris Marsh wrote:
>     Unless you are changing only a few entries, this is likely to be too
>     slow.
>
> Big time :)
>
> Ok, so even though it is pre allocated for the right number of nnz
> values, operator() still incurs the cost? Must admit that is not what
> I'd have expected.

Well, this is a sparse matrix. Since operator() deals with a single 
entry, there is no way this could be fast (note that CSR has 
requirements on entries from the same row being located consecutively in 
memory)


> When I obtain those CSR buffers, they will be the correct size, and I
> should be able to insert into them in parallel, correct?

Yes, exactly.
You may need to populate the matrix in two passes: The first determines 
the sparsity pattern, the second writes the actual numerical values.

Best regards,
Karli



> On 6 April 2017 at 13:13, Karl Rupp <[email protected]
> <mailto:[email protected]>> wrote:
>
>     Hi!
>
>
>
>     On 04/06/2017 06:44 PM, Chris Marsh wrote:
>
>         Hi,
>
>         I know the number of non-zero entries for a sparse matrix so I
>         am trying
>         to pre-allocate it with
>
>          viennacl::compressed_matrix<vcl_scalar_type>  vl_C(row, col, nnz);
>
>
>     At this point your matrix is still empty (i.e. no nonzeros). It only
>     preallocated an array to hold up to 'nnz' entries.
>
>
>         and access it with vl_C.operator().
>
>
>     Unless you are changing only a few entries, this is likely to be too
>     slow.
>
>
>         I am using host only memory context, with ViennaCL 1.7.1 from
>         homebrew.
>
>         How should I proceed with this?
>
>
>     To fill the CSR format efficiencly, have a look here:
>     
> https://sourceforge.net/p/viennacl/discussion/1143678/thread/325a937c/?limit=25#d6f0
>     
> <https://sourceforge.net/p/viennacl/discussion/1143678/thread/325a937c/?limit=25#d6f0>
>
>     For host-based memory, an example of how to get pointers to the
>     three CSR arrays is here:
>     
> https://github.com/viennacl/viennacl-dev/blob/master/viennacl/linalg/host_based/sparse_matrix_operations.hpp#L115
>     
> <https://github.com/viennacl/viennacl-dev/blob/master/viennacl/linalg/host_based/sparse_matrix_operations.hpp#L115>
>
>     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