To get this repository to work, I have to make graphnn work with CUDA 11.3.
cusparseScsrmm (and the D variant) were both deprecated in version 11, so I need to replace them with the more modern functions in this file
inline void Cuda_CSRMM(
cusparseHandle_t& handle,
cusparseOperation_t transA,
int m, int n, int k, int nnz,
const float *alpha,
const float *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const float *B,
int ldb,
const float *beta,
float *C,
int ldc)
{
// cusparseMatDescr_t descrA;
// cusparseCreateMatDescr(&descrA);
// cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL);
// cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ZERO);
// cusparseScsrmm(handle, transA, m, n, k, nnz, alpha, descrA, csrValA, csrRowPtrA, csrColIndA, B, ldb, beta, C, ldc);
// We will convert from the arrays to proper matrices
int mA = m,
kA = k;
//if (transA != CUSPARSE_OPERATION_NON_TRANSPOSE) {
// std::swap(mA, kA);}
cusparseSpMatDescr_t matA;
cusparseCreateCsr(&matA, mA, kA, nnz, const_cast<int *>(csrRowPtrA),
const_cast<int *>(csrColIndA),
const_cast<float *>(csrValA),
CUSPARSE_INDEX_32I, CUSPARSE_INDEX_32I, CUSPARSE_INDEX_BASE_ZERO, CUDA_R_32F);
cusparseDnMatDescr_t matB, matC;
cusparseCreateDnMat(&matB, k, n, ldb, const_cast<float *>(B), CUDA_R_32F, CUSPARSE_ORDER_COL);
cusparseCreateDnMat(&matC, m, n, ldc, C, CUDA_R_32F, CUSPARSE_ORDER_COL);
// Prepare the buffer
void *externalBuffer = NULL;
size_t bufferSize = 0;
cusparseSpMM_bufferSize(handle, transA, CUSPARSE_OPERATION_NON_TRANSPOSE, alpha,
matA, matB, beta, matC, CUDA_R_32F,
CUSPARSE_CSRMM_ALG1,
//CUSPARSE_MM_ALG_DEFAULT,
&bufferSize);
cudaMalloc(&externalBuffer, bufferSize);
// Perform the multiplication
cusparseSpMM(
handle, // handle
transA, // opA
CUSPARSE_OPERATION_NON_TRANSPOSE, // opB
alpha, // alpha
matA, // matA
matB, // matB
beta, // beta
matC, // matC
CUDA_R_32F, // computeType
CUSPARSE_CSRMM_ALG1,
//CUSPARSE_MM_ALG_DEFAULT, // alg
externalBuffer // externalBuffer
);
}
inline void Cuda_CSRMM(
cusparseHandle_t& handle,
cusparseOperation_t transA,
int m, int n, int k, int nnz,
const double *alpha,
const double *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const double *B,
int ldb,
const double *beta,
double *C,
int ldc)
{
// cusparseMatDescr_t descrA;
// cusparseCreateMatDescr(&descrA);
// cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL);
// cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ZERO);
// cusparseDcsrmm(handle, transA, m, n, k, nnz, alpha, descrA, csrValA, csrRowPtrA, csrColIndA, B, ldb, beta, C, ldc);
// We will convert from the arrays to proper matrices
int mA = m,
kA = k;
//if (transA != CUSPARSE_OPERATION_NON_TRANSPOSE) {
// std::swap(mA, kA);}
cusparseSpMatDescr_t matA;
cusparseCreateCsr(&matA, mA, kA, nnz, const_cast<int *>(csrRowPtrA),
const_cast<int *>(csrColIndA),
const_cast<double *>(csrValA),
CUSPARSE_INDEX_64I, CUSPARSE_INDEX_64I, CUSPARSE_INDEX_BASE_ZERO, CUDA_R_64F);
cusparseDnMatDescr_t matB, matC;
// if (n == 1) {
// ldc = m;
// ldb = k;
// }
cusparseCreateDnMat(&matB, k, n, ldb, const_cast<double *>(B), CUDA_R_64F, CUSPARSE_ORDER_COL);
cusparseCreateDnMat(&matC, m, n, ldc, C, CUDA_R_64F, CUSPARSE_ORDER_COL);
// Prepare the buffer
void *externalBuffer = NULL;
size_t bufferSize = 0;
cusparseSpMM_bufferSize(handle, transA, CUSPARSE_OPERATION_NON_TRANSPOSE, alpha,
matA, matB, beta, matC, CUDA_R_64F,
CUSPARSE_MM_ALG_DEFAULT, &bufferSize);
cudaMalloc(&externalBuffer, bufferSize);
// Perform the multiplication
cusparseSpMM(
handle, // handle
transA, // opA
CUSPARSE_OPERATION_NON_TRANSPOSE, // opB
alpha, // alpha
matA, // matA
matB, // matB
beta, // beta
matC, // matC
CUDA_R_64F, // computeType
CUSPARSE_MM_ALG_DEFAULT, // alg
externalBuffer // externalBuffer
);
}
is my attempt to replace them, unfortunately when running the code I receive the following error messages:
[...]
** On entry to cusparseCreateDnMat(): dimension mismatch, ld (64) < rows (647)
** On entry to cusparseSpMM_bufferSize() parameter number 6 (matB) had an illegal value: bad initialization or already destroyed
** On entry to cusparseSpMM() parameter number 6 (matB) had an illegal value: bad initialization or already destroyed
[...]
I was wondering if I could have some help with the upgrading? I’ve not been able to find information online on how to do it.