Hi,

I have discovered something rather odd.

If I run an minimal example (as shown in eigen-with-viennacl.cpp) all runs fine where I pass a compressed_matrix directly to the copy e.g.

    Eigen::SparseMatrix<float, Eigen::RowMajor> spAm;

    ... code to fill spAm;

    viennacl::matrix<float> A = viennacl::compressed_matrix(K, M)

I assume you mean
  viennacl::compressed_matrix<float> A =
     viennacl::compressed_matrix<float>(K, M);
here? This may result in an unnecessary temporary object, so I'd recommend


    viennacl::copy(spAm, A);


However, if my compressed_matrix is wrapped up in a std::shared_ptr (C++11) I don't seem to be able to copy even when dereferencing.

    std::shared_ptr<viennacl::compressed_matrix<T> > shptr =
    std::make_shared<viennacl::compressed_matrix<float>
     >(viennacl::compressed_matrix<T>(K,M));

    viennacl::copy(spAm, *shptr);

T == float?






Strangely, this results in a series of memory errors, the top relevant ones are here

    0x00000000701CF5F6 (0x0000000018C5A670 0x000000001502E060
    0x00000000043EB20B 0x00000000043EB230),
    _ZN8viennacl7backend13memory_createERNS0_10mem_handleEyRKNS_7contextEPKv()
    + 0x1C6 bytes(s)
    0x00000000701C00C0 (0x0000000000000000 0x0000000004627FD0
    0x0000000000000010 0x0000000000000004),
    
_ZN8viennacl6detail9copy_implINS_5tools27const_sparse_matrix_adapterIdjEEdLj1EEEvRKT_RNS_17compressed_matrixIT0_XT1_EEEy()
    + 0x3A0 bytes(s)
    0x00000000701BD721 (0x00000000043EB350 0x0000000004627FD0
    0x0000000004530620 0x0000000007474070),
    
_ZN8viennacl4copyIdLi1ELj1EEEvRKN5Eigen12SparseMatrixIT_XT0_EiEERNS_17compressed_matrixIS3_XT1_EEE()
    + 0x321 bytes(s)


which following some c++filt we get the following

    viennacl::backend::memory_create(viennacl::backend::mem_handle&,
    unsigned long long, viennacl::context const&, void const*)
    void
    
viennacl::detail::copy_impl<viennacl::tools::const_sparse_matrix_adapter<float,
    unsigned int>, float,
    1u>(viennacl::tools::const_sparse_matrix_adapter<float, unsigned
    int> const&, viennacl::compressed_matrix<float, 1u>&, unsigned long
    long)
    void viennacl::copy<float, 1, 1u>(Eigen::SparseMatrix<float, 1, int>
    const&, viennacl::compressed_matrix<float, 1u>&)


Any insight as to why this would be would be appreciated.

compressed_matrix has the copy-constructor implemented, so that should be okay. Maybe it doesn't copy *all* internal members. I'll try to reproduce the problem so that I can debug it.

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-devel mailing list
ViennaCL-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/viennacl-devel

Reply via email to