In page 110 of cusparse document, the following piece of code is provided.
int nnzC;
int *nnzTotalDevHostPtr = &nnzC;
......
cusparseXcsrgemm2Nnz(..., nnzTotalDevHostPtr, ...);
if (NULL != nnzTotalDevHostPtr){
nnzC = *nnzTotalDevHostPtr;
} else {
......
}
where the declaration of cusparseXcsrgemm2Nnz is as follows:
cusparseStatus_t
cusparseXcsrgemm2Nnz(..., int* nnzTotalDevHostPtr, ...)
If I understand correctly, nnzTotalDevHostPtr
points to nnzC
in the host. Then why the if
in the first piece of code? Isn’t nnzC = *nnzTotalDevHostPtr
redundant?