Repetitive calls to cusparseSpGEMM

I am working on a problem that requires repetitive multiplications of two sparse matrices, one of which does not vary over calls and the other varies over calls only in its elements (size not variable). I am using “cusparseSpGEMM” for multiplication. I can see from the document that memory allocation is conducted twice, one after the first call to “cusparseSpGEMM_workEstimation” and the other after the first call to “cusparseSpGEMM_compute”. As I observed, repetitive calls to memory allocation generally lead to poor performance. I am wondering if it is possible to allocate buffers only once.

And another issue I observed with “cusparseSpGEMM” is prohibitively large memory allocated. For instance, I created two thousand-by-thousand sparse matrices whose zeros are randomly decided. The buffer size allocated for “cusparseSpGEMM” was much larger than the two matrices themselves. I am wondering if this large memory need was due to my incorrect understanding of this function or if it is indeed a problem with CUSPARSE library.

I am expecting a general reply that answers if my observation is reasonable. If needed, I can provide my verification code.

Hi Ziqi, do you have any follow up regarding the large required memory? I encountered the same issue causing me running out of memory on device.

Please checkout the new SpGEMM algorithms provided to minimize memory usage (cuSPARSE)