clMathLibraries / clSPARSE

a software library containing Sparse functions written in OpenCL
Apache License 2.0
173 stars 60 forks source link

Documentation does not make clear when output matrices are allocated by the library and when they have to be supplied by the user #207

Open TillAlex opened 7 years ago

TillAlex commented 7 years ago

Some of the methods calculating sparse matrices are allocating their outputs internally (e.g. clsparseScsrSpGemm) which makes sense, because it is not known in advance how many non-zero entries there will be.

Other methods need the user to allocate the output buffers ( e.g. Sdense2Csr). In this case the user has to know in advance how many non-zero entries there will be. However, internally Sdense2Csr counts non-zero entries to be able to allocate the intermediate CooMatrix anyway, so zeros are counted twice in the end.

1) Documentation should clearly state when the user has to allocate output buffers and when the library does

2) Methods calculating sparse outputs should either allocate internally after counting non-zero entries or trust the non-zero count passed by the user in the user allocated output matrix to speed up calculations.