Menu

methods like clear() for compressed_matrix<T> types

suchismit
2014-09-12
2014-09-13
  • suchismit

    suchismit - 2014-09-12

    hi folks,
    i was wondering if there any clear() like methods for compressed_matrix<T> types in ViennaCL which would allow me to clear out large matrices when i am done using them.

    when T is double and i have to deal with 4 large matrices of dimensions (2 each for 6-by-23040 and 23040-by-23040), it has a large memory requirement and i was hoping to clear unused matrices out. clearing out dense matrices (which are my data matrices) and intermediate vectors are straightforward using the clear() method. i also wanted to clear out one of my large sparse matrices if possible.

    i had another query. what exactly happens when we multiply a compressed_matrix<T> by a matrix of all zeros (of appropriate dimensions) ? does it have the same effect as clearing out compressed_matrix<T> ?

    currently even if i am able to manage with not clearing some matrices, i will be going in for larger matrices pretty soon. that 23040 figure might get close to 100k or more. the question would be much more relevant when that happens.

    warm regards,
    suchismit

     
  • suchismit

    suchismit - 2014-09-12

    it turns out ublas compressed_matrix<T> type has a clear() method.
    this should suffice for my scenario. :)

    thank you.

     
  • Karl Rupp

    Karl Rupp - 2014-09-13

    Hi Suchismit,

    you are right, a clear() method should be added to improve compatibility with uBLAS. I created an issue here, which should just make it into the upcoming 1.6.0 release: https://github.com/viennacl/viennacl-dev/issues/98

    There are a couple of other options already available:
    If you don't need the sparse matrix object, destroy it. This automatically frees the memory.
    You can use the resize() member to reduce the memory buffer to something tiny, e.g. 1-by-1
    * If the first two methods are not applicable, use viennacl::copy() with a diagonal matrix to reduce the number of nonzeros (and hence the memory required) in the compressed_matrix object.

    In order to get good performance, it's actually good to go to higher matrix sizes. Sparse matrices with 23k rows/columns are usually still to small to hide latency effects from PCI-Express communication.

    Best regards,
    Karli

     

Log in to post a comment.