I am using CUDA 12.2, HPC SDK 23.9 environment with CUDA Fortran to do sparse matrix sparse matrix multiplication.

I asked about the compilation problem before in this forum
, and also in the compiler forum, and solved the problem by writing an interface from CUDA C.

My question is, what is chunk_fraction mathematically?
Also, from a programmatic point of view, can I define any value within the range of (0,1]?
Can I save memory with smaller values?

Also, when I compute the matrix product in the github sample code, ALG1 gives buffersize1=1171, buffersize2=5687.

In contrast, for ALG3, chunk_fraction=0.2d0 or 1d0,
buffersize1=1171, buffersize3=37911, buffersize2=43358.
If chunk_fraction is set to 0.01, then
buffersize1=1171, buffersize3=48533271, buffersize2=48538718.

Would using ALG3 result in a smaller buffersize?
Also, is it possible to change the chunk_fraction to use less memory than ALG1?

Hi,
In ALG3, the work is divided into smaller chunks so that when the alg works on each chunk it’ll consume less memory. The chunk_fraction is the proportion of chunk size over the whole amount of work.
The value range of chunk_fraction is (0,1].
When you decrease the chunk_fraction value you’ll reduce used memory. However, there’s a certain amount of memory that we have to have regardless to the chunk_ratio, so you can’t lower the memory usage up to that point even when chunk_ratio → 0.
ALG3 is designed for very large SpGEMM that needs a lot of memory. For small matrices like in sample code, ALG3 won’t show its memory saving ability.

I understand that the memory savings will not be effective for small sized matrices.

So I tried to compute a double precision matrix product of (44954,1136491)*(1136491,44954) with ALG3, chunk_fraction=1d-5.
The machine used is an NVIDIA A100 80GB.

This resulted in an error:7 on the second cusparseSpGEMM_estimateMemory.
What is the cause of this?

Hi,
What are the nnz of matrix A and B in your case?
What’s the number of products in this SpGEMM? You can get this number by calling cusparseSpGEMM_getNumProducts after calling cusparseSpGEMM_workEstimation (example).
Can you test with a higher chunk_fraction value, say 0.1?