Hi Andy,

instead of viennacl::backend::memory_copy(), you want to use
viennacl::backend::memory_read(), which directly transfers the data into 
your buffer(s).

If you *know* that your handles are in host memory, you can even grab 
the values directly via
  viennacl::linalg::host_based::detail::extract_raw_pointer<T>();
defined in viennacl/linalg/host_based/common.hpp, around line 40.

Please let me know if you still get errors after using that.

Best regards,
Karli




On 07/20/2016 09:05 PM, Andrew Palumbo wrote:
> Hello,
>
>
> I'm Having some difficulties with compressed_matrix multiplication.
>
>
> Essentially I am copying  three buffers, the CSR conversion of an Apache
> Mahout SparseMatrix, into two compressed_matrices performing matrix
> multiplication. I am doing this in scala and Java using javacpp.
>
>
> For example, I have a 5 x 10 matrix of ~20% non-zero values which in CSR
> format looks like this:
>
>
> NNz: 12
>
> Row Pointer: [0, 1, 4, 6, 9, 12, ]
>
> Col Pointer: [9, 0, 8, 7, 2, 9, 0, 8, 9, 0, 3, 5, ]
>
> element Pointer: [0.4065367203992265, 0.04957158909682802,
> 0.5205586068847993, 0.3708618354358446, 0.6963900565931678,
> 0.8330915529787706, 0.32839112750638844, 0.7856168903297948,
> 0.4265801782090245, 0.14733066454561583, 0.9501663495824946,
> 0.9710498974366047, ]
>
> Multiplied by a similarly Sparse 10 x 5 compressed_matrix
>
> I use a CompressedMatrix wrapper which essentially wraps the
>
>      viennacl:: compressed_matrix (vcl_size_t rows, vcl_size_t cols,
> vcl_size_t nonzeros=0, viennacl::context ctx=viennacl::context())
>
> constructor as well as the
>
>      compressed_matrix (matrix_expression< const compressed_matrix,
> const compressed_matrix, op_prod > const &proxy).
>
> I have a helper function, /toVclCompressedMatrix/(..) which essentially
> does the CSR conversion from a Mahout src matrix, calls the constructor
> and uses viennacl::compressed_matrix::set(...) to set the buffers:
>
> val ompA =toVclCompressedMatrix(src = mxA, ompCtx)
> val ompB =toVclCompressedMatrix(src = mxB, ompCtx)
>
>
> and then create a new viennacl::compressed_matrix from the
> viennacl::linalg::prod of the 2 matrices i.e.:
>
> val ompC =new CompressedMatrix(prod(ompA, ompB))
>
> The context in the above case is either the Host or OpenMP (I know that
> there is some special casting of the row_jumpers and col_idxs that needs
> to be done in the OpenCL version)
>
> The Matrix multiplication completes without error on small Matrices eg.
> < 300 x 300
> but seems to overwrite the resulting buffers on larger Matrices.
>
> My real problem, though is getting the memory back out of the
> resulting`ompC` compresed_matrix so that i can write it back to a mahout
> SparseMatrix.
>
> currently I am using:
>
> void viennacl::backend::memory_copy (mem_handle const &  src_buffer,
>          mem_handle &      dst_buffer,
>          vcl_size_t      src_offset,
>          vcl_size_t      dst_offset,
>          vcl_size_t      bytes_to_copy
>      )
>
> on ompC.handel1,ompC.handel2 and ompC.handel source handels
>
> to copy into pre-allocated  row_jumper,  col_index and element buffers
> (of size ompC.size1() + 1, ompC.nnz and ompC.nnz, respectivly).
>
> I am getting nonsensical values back that one would expect from memory
> errors. eg:
>
> the Matrix geometry of the result: ompC.size1(), and omp.size2() are
> correct and ompC.nnz is a reasonable value.
>
> It is possible that I have mis-allocated some of the memory on my side,
> but I am pretty sure that most of the Buffers are allocated correctly
> (usually JavaCPP does a pretty good job of this).
>
>
> I guess, long story short, my question is am i using the correct method
> of copying the memory out of a compressed_matrix?  is there something
> glaringly incorrect that i am doing here?  Should I be using
> viennacl::backend::memory_copy or is there a different method that i
> should be using?
>
>
> Thanks very much,
>
> Andy
>
>
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity planning
> reports.http://sdm.link/zohodev2dev
>
>
>
> _______________________________________________
> ViennaCL-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/viennacl-devel
>


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
ViennaCL-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/viennacl-devel

Reply via email to