From e41456adba818278f20b7a071949195a043d0c57 Mon Sep 17 00:00:00 2001 From: Cody Balos Date: Tue, 12 Dec 2023 14:48:49 -0800 Subject: [PATCH] Apply suggestions from code review Co-authored-by: David Gardner --- doc/shared/sunmatrix/SUNMatrix_MagmaDense.rst | 4 ++-- doc/shared/sunmatrix/SUNMatrix_OneMklDense.rst | 4 ++-- include/sunmatrix/sunmatrix_cusparse.h | 4 ++-- include/sunmatrix/sunmatrix_magmadense.h | 4 ++-- src/sunmatrix/sparse/sunmatrix_sparse.c | 6 ++++-- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/doc/shared/sunmatrix/SUNMatrix_MagmaDense.rst b/doc/shared/sunmatrix/SUNMatrix_MagmaDense.rst index ffea7dda05..e53fc5437b 100644 --- a/doc/shared/sunmatrix/SUNMatrix_MagmaDense.rst +++ b/doc/shared/sunmatrix/SUNMatrix_MagmaDense.rst @@ -284,7 +284,7 @@ implementation specific functions: **Return value:** * ``SUN_SUCCESS`` -- if the copy is successful. - * ``SUN_ERR_ARG_INCOMPATIBLE`` -- if either the ``SUNMatrix`` is not a + * ``SUN_ERR_ARG_INCOMPATIBLE`` -- if the ``SUNMatrix`` is not a ``SUNMATRIX_MAGMADENSE`` matrix. * ``SUN_ERR_MEM_FAIL`` -- if the copy fails. @@ -300,7 +300,7 @@ implementation specific functions: **Return value:** * ``SUN_SUCCESS`` -- if the copy is successful. - * ``SUN_ERR_ARG_INCOMPATIBLE`` -- if either the ``SUNMatrix`` is not a + * ``SUN_ERR_ARG_INCOMPATIBLE`` -- if the ``SUNMatrix`` is not a ``SUNMATRIX_MAGMADENSE`` matrix. * ``SUN_ERR_MEM_FAIL`` -- if the copy fails. diff --git a/doc/shared/sunmatrix/SUNMatrix_OneMklDense.rst b/doc/shared/sunmatrix/SUNMatrix_OneMklDense.rst index 2e521f413e..799139704d 100644 --- a/doc/shared/sunmatrix/SUNMatrix_OneMklDense.rst +++ b/doc/shared/sunmatrix/SUNMatrix_OneMklDense.rst @@ -314,7 +314,7 @@ Copy Data **Return value:** * ``SUN_SUCCESS`` -- if the copy is successful. - * ``SUN_ERR_ARG_INCOMPATIBLE`` -- if either the ``SUNMatrix`` is not a + * ``SUN_ERR_ARG_INCOMPATIBLE`` -- if the ``SUNMatrix`` is not a ``SUNMATRIX_ONEMKLDENSE`` matrix. * ``SUN_ERR_MEM_FAIL`` -- if the copy fails. @@ -330,7 +330,7 @@ Copy Data **Return value:** * ``SUN_SUCCESS`` -- if the copy is successful. - * ``SUN_ERR_ARG_INCOMPATIBLE`` -- if either the ``SUNMatrix`` is not a + * ``SUN_ERR_ARG_INCOMPATIBLE`` -- if the ``SUNMatrix`` is not a ``SUNMATRIX_ONEMKLDENSE`` matrix. * ``SUN_ERR_MEM_FAIL`` -- if the copy fails. diff --git a/include/sunmatrix/sunmatrix_cusparse.h b/include/sunmatrix/sunmatrix_cusparse.h index 5a19eb6236..d4c786de6a 100644 --- a/include/sunmatrix/sunmatrix_cusparse.h +++ b/include/sunmatrix/sunmatrix_cusparse.h @@ -99,8 +99,8 @@ SUNDIALS_EXPORT int* SUNMatrix_cuSparse_IndexPointers(SUNMatrix A); SUNDIALS_EXPORT int* SUNMatrix_cuSparse_IndexValues(SUNMatrix A); SUNDIALS_EXPORT sunrealtype* SUNMatrix_cuSparse_Data(SUNMatrix A); -SUNDIALS_EXPORT SUNErrCode -SUNMatrix_cuSparse_SetFixedPattern(SUNMatrix A, sunbooleantype yesno); +SUNDIALS_EXPORT +SUNErrCode SUNMatrix_cuSparse_SetFixedPattern(SUNMatrix A, sunbooleantype yesno); SUNDIALS_EXPORT SUNErrCode SUNMatrix_cuSparse_SetKernelExecPolicy( SUNMatrix A, SUNCudaExecPolicy* exec_policy); SUNDIALS_EXPORT int SUNMatrix_cuSparse_NumBlocks(SUNMatrix A); diff --git a/include/sunmatrix/sunmatrix_magmadense.h b/include/sunmatrix/sunmatrix_magmadense.h index 39852cc199..d25284dc3f 100644 --- a/include/sunmatrix/sunmatrix_magmadense.h +++ b/include/sunmatrix/sunmatrix_magmadense.h @@ -76,8 +76,8 @@ SUNDIALS_EXPORT sunindextype SUNMatrix_MagmaDense_NumBlocks(SUNMatrix A); SUNDIALS_EXPORT sunrealtype** SUNMatrix_MagmaDense_BlockData(SUNMatrix A); SUNDIALS_EXPORT SUNErrCode SUNMatrix_MagmaDense_CopyToDevice(SUNMatrix A, sunrealtype* h_data); -SUNDIALS_EXPORT SUNErrCode -SUNMatrix_MagmaDense_CopyFromDevice(SUNMatrix A, sunrealtype* h_data); +SUNDIALS_EXPORT +SUNErrCode SUNMatrix_MagmaDense_CopyFromDevice(SUNMatrix A, sunrealtype* h_data); SUNDIALS_STATIC_INLINE sunrealtype* SUNMatrix_MagmaDense_Block(SUNMatrix Amat, sunindextype k) diff --git a/src/sunmatrix/sparse/sunmatrix_sparse.c b/src/sunmatrix/sparse/sunmatrix_sparse.c index 619024fdd8..41148724c0 100644 --- a/src/sunmatrix/sparse/sunmatrix_sparse.c +++ b/src/sunmatrix/sparse/sunmatrix_sparse.c @@ -147,7 +147,7 @@ SUNMatrix SUNSparseFromDenseMatrix(SUNMatrix Ad, sunrealtype droptol, sunindextype M, N; SUNMatrix As; - SUNAssertNull(SUNMatGetID(Ad) == SUNMATRIX_DENSE, SUN_ERR_ARG_OUTOFRANGE); + SUNAssertNull(SUNMatGetID(Ad) == SUNMATRIX_DENSE, SUN_ERR_ARG_WRONGTYPE); SUNAssertNull(sparsetype == CSC_MAT || sparsetype == CSR_MAT, SUN_ERR_ARG_OUTOFRANGE); SUNAssertNull(droptol >= ZERO, SUN_ERR_ARG_OUTOFRANGE); @@ -223,7 +223,7 @@ SUNMatrix SUNSparseFromBandMatrix(SUNMatrix Ab, sunrealtype droptol, sunindextype M, N; SUNMatrix As; - SUNAssertNull(SUNMatGetID(Ab) == SUNMATRIX_BAND, SUN_ERR_ARG_OUTOFRANGE); + SUNAssertNull(SUNMatGetID(Ab) == SUNMATRIX_BAND, SUN_ERR_ARG_WRONGTYPE); SUNAssertNull(sparsetype == CSC_MAT || sparsetype == CSR_MAT, SUN_ERR_ARG_OUTOFRANGE); SUNAssertNull(droptol >= ZERO, SUN_ERR_ARG_OUTOFRANGE); @@ -681,7 +681,9 @@ SUNErrCode SUNMatScaleAddI_Sparse(sunrealtype c, SUNMatrix A) /* create work arrays for nonzero row (column) indices and values in a * single column (row) */ w = (sunindextype*)malloc(M * sizeof(sunindextype)); + SUNAssert(w, SUN_ERR_MALLOC_FAIL); x = (sunrealtype*)malloc(M * sizeof(sunrealtype)); + SUNAssert(x, SUN_ERR_MALLOC_FAIL); /* determine storage location where last column (row) should end */ nz = Ap[N] + newvals;