From 0760e4d553e84cc495a3d6707f5bd206c41238fa Mon Sep 17 00:00:00 2001 From: sfilippone Date: Thu, 4 Apr 2024 10:53:20 +0200 Subject: [PATCH] Fix C function declarations for compilation with LLVM/clang in CUDA --- cuda/cuda_util.c | 14 ++++++++++++++ cuda/cuda_util.h | 1 + cuda/elldev.c | 2 +- cuda/elldev.h | 1 + cuda/fcusparse_fct.h | 2 +- 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cuda/cuda_util.c b/cuda/cuda_util.c index 3fe61cc0..b7d0199e 100644 --- a/cuda/cuda_util.c +++ b/cuda/cuda_util.c @@ -378,22 +378,36 @@ void cudaSync() { cudaError_t err; err = cudaDeviceSynchronize(); +#if 0 if (err == cudaSuccess) return SPGPU_SUCCESS; else { fprintf(stderr,"CUDA Error cudaSync: %s\n", cudaGetErrorString(err)); return SPGPU_UNSPECIFIED; } +#else + if (err != cudaSuccess) { + fprintf(stderr,"CUDA Error cudaSync: %s\n", cudaGetErrorString(err)); + } + return ; +#endif } void cudaReset() { cudaError_t err; err = cudaDeviceReset(); +#if 0 if (err != cudaSuccess) { fprintf(stderr,"CUDA Error Reset: %s\n", cudaGetErrorString(err)); return SPGPU_UNSPECIFIED; } +#else + if (err != cudaSuccess) { + fprintf(stderr,"CUDA Error Reset: %s\n", cudaGetErrorString(err)); + } + return ; +#endif } diff --git a/cuda/cuda_util.h b/cuda/cuda_util.h index 95c8d1dc..4eafb5bf 100644 --- a/cuda/cuda_util.h +++ b/cuda/cuda_util.h @@ -54,6 +54,7 @@ int freeRemoteBuffer(void* buffer); int gpuInit(int dev); int getDeviceCount(); int getDevice(); +int getDeviceHasUVA(); int setDevice(int dev); int getGPUMultiProcessors(); int getGPUMemoryBusWidth(); diff --git a/cuda/elldev.c b/cuda/elldev.c index 3b79a863..a5d893c1 100644 --- a/cuda/elldev.c +++ b/cuda/elldev.c @@ -112,7 +112,7 @@ void zeroEllDevice(void *remoteMatrix) else if (tmp->dataType == SPGPU_TYPE_COMPLEX_DOUBLE) cudaMemset((void *)tmp->cM, 0, tmp->allocsize*sizeof(cuDoubleComplex)); else - return SPGPU_UNSUPPORTED; // Unsupported params + return ; // Unsupported params //fprintf(stderr,"From allocEllDevice: %d %d %d %p %p %p\n",tmp->maxRowSize, // tmp->avgRowSize,tmp->allocsize,tmp->rS,tmp->rP,tmp->cM); diff --git a/cuda/elldev.h b/cuda/elldev.h index c1001439..5305057a 100644 --- a/cuda/elldev.h +++ b/cuda/elldev.h @@ -95,6 +95,7 @@ typedef struct EllDeviceParams unsigned int firstIndex; } EllDeviceParams; +int computeEllAllocPitch(int rowsCount); int FallocEllDevice(void** deviceMat, unsigned int rows, unsigned int maxRowSize, unsigned int nnzeros, unsigned int columns, unsigned int elementType, diff --git a/cuda/fcusparse_fct.h b/cuda/fcusparse_fct.h index 689bdc93..28d900da 100644 --- a/cuda/fcusparse_fct.h +++ b/cuda/fcusparse_fct.h @@ -320,7 +320,7 @@ int T_spsvCSRGDevice(T_Cmat *Matrix, TYPE alpha, void *deviceX, } #if CUDA_VERSION >= 11030 -T_CSRGCreateSpMVDescr(T_CSRGDeviceMat *cMat) +int T_CSRGCreateSpMVDescr(T_CSRGDeviceMat *cMat) { int64_t tr,tc,tz; tr = cMat->m;