From 4daf3102b7cd3527eac2c4ad9929aace8364bb98 Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Thu, 9 Jan 2025 15:26:18 +0000 Subject: [PATCH] Use right PETSc bits and pieces, pip install appears to work locally --- tinyasm/matinvert.cpp | 2 +- tinyasm/tinyasm.cpp | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tinyasm/matinvert.cpp b/tinyasm/matinvert.cpp index 0c1e7025c2..525dcefbd0 100644 --- a/tinyasm/matinvert.cpp +++ b/tinyasm/matinvert.cpp @@ -6,6 +6,6 @@ PetscErrorCode mymatinvert(PetscBLASInt* n, PetscScalar* mat, PetscBLASInt* piv, PetscCheck(!(*info), PETSC_COMM_SELF, PETSC_ERR_LIB, "TinyASM error calling ?getrf in mymatinvert"); PetscCallBLAS("LAPACKgetri", LAPACKgetri_(n, mat, n, piv, work, n, info)); PetscCheck(!(*info), PETSC_COMM_SELF, PETSC_ERR_LIB, "TinyASM error calling ?getri in mymatinvert"); - return PETSC_SUCCESS; + PetscFunctionReturn(PETSC_SUCCESS); } diff --git a/tinyasm/tinyasm.cpp b/tinyasm/tinyasm.cpp index cf583a6fc8..ea2edef496 100644 --- a/tinyasm/tinyasm.cpp +++ b/tinyasm/tinyasm.cpp @@ -63,28 +63,28 @@ class BlockJacobi { fwork = vector(biggestBlock, 0.); localmats_aij = NULL; dofis = vector(numBlocks); - PetscMalloc1(numBlocks, &localmats); + PetscCallVoid(PetscMalloc1(numBlocks, &localmats)); for(int p=0; p& sf, const std } /* Offsets are the offsets on the current process of the * global dof numbering for the subspaces. */ - PetscCall(MPI_Type_contiguous(n, MPIU_INT, &contig)); - PetscCall(MPI_Type_commit(&contig)); + MPI_Type_contiguous(n, MPIU_INT, &contig); + MPI_Type_commit(&contig); #if MY_PETSC_VERSION_LT(3, 14, 4) PetscCall(PetscSFBcastBegin(rankSF, contig, offsets, remoteOffsets)); @@ -221,7 +221,7 @@ PetscErrorCode CreateCombinedSF(PC pc, const std::vector& sf, const std PetscCall(PetscSFBcastBegin(rankSF, contig, offsets, remoteOffsets, MPI_REPLACE)); PetscCall(PetscSFBcastEnd(rankSF, contig, offsets, remoteOffsets, MPI_REPLACE)); #endif - PetscCall(MPI_Type_free(&contig)); + MPI_Type_free(&contig); PetscCall(PetscFree(offsets)); PetscCall(PetscSFDestroy(&rankSF)); /* Now remoteOffsets contains the offsets on the remote @@ -256,7 +256,7 @@ PetscErrorCode CreateCombinedSF(PC pc, const std::vector& sf, const std PetscCall(PetscSFCreate(PetscObjectComm((PetscObject)pc), newsf)); PetscCall(PetscSFSetGraph(*newsf, allRoots, allLeaves, ilocal, PETSC_OWN_POINTER, iremote, PETSC_OWN_POINTER)); } - PetscFunctionReturn(0); + PetscFunctionReturn(PETSC_SUCCESS); } @@ -266,7 +266,7 @@ PetscErrorCode PCSetup_TinyASM(PC pc) { auto blockjacobi = (BlockJacobi *)pc->data; blockjacobi -> updateValuesPerBlock(P); PetscCall(PetscLogEventEnd(PC_tinyasm_setup, pc, 0, 0, 0)); - return 0; + PetscFunctionReturn(PETSC_SUCCESS); } PetscErrorCode PCApply_TinyASM(PC pc, Vec b, Vec x) { @@ -295,13 +295,13 @@ PetscErrorCode PCApply_TinyASM(PC pc, Vec b, Vec x) { PetscCall(PetscSFReduceEnd(blockjacobi->sf, MPIU_SCALAR, &(blockjacobi->localx[0]), globalx, MPI_SUM)); PetscCall(VecRestoreArray(x, &globalx)); PetscCall(PetscLogEventEnd(PC_tinyasm_apply, pc, 0, 0, 0)); - return 0; + PetscFunctionReturn(PETSC_SUCCESS); } PetscErrorCode PCDestroy_TinyASM(PC pc) { if(pc->data) delete (BlockJacobi *)pc->data; - return 0; + PetscFunctionReturn(PETSC_SUCCESS); } PetscErrorCode PCView_TinyASM(PC pc, PetscViewer viewer) { @@ -320,7 +320,7 @@ PetscErrorCode PCView_TinyASM(PC pc, PetscViewer viewer) { PetscCall(PetscViewerASCIIPrintf(viewer, "Largest block size %" PetscInt_FMT " \n", biggestblock)); PetscCall(PetscViewerASCIIPopTab(viewer)); } - return 0; + PetscFunctionReturn(PETSC_SUCCESS); } PetscErrorCode PCCreate_TinyASM(PC pc) { @@ -329,7 +329,7 @@ PetscErrorCode PCCreate_TinyASM(PC pc) { pc->ops->setup = PCSetup_TinyASM; pc->ops->destroy = PCDestroy_TinyASM; pc->ops->view = PCView_TinyASM; - return 0; + PetscFunctionReturn(PETSC_SUCCESS); } // pybind11 casters for PETSc/petsc4py objects, copied from dolfinx repo // Import petsc4py on demand @@ -419,6 +419,6 @@ PYBIND11_MODULE(_tinyasm, m) { auto blockjacobi = new BlockJacobi(dofsPerBlock, globalDofsPerBlock, localsize, newsf); pc->data = (void*)blockjacobi; PetscCall(PetscLogEventEnd(PC_tinyasm_SetASMLocalSubdomains, pc, 0, 0, 0)); - return 0; + PetscFunctionReturn(PETSC_SUCCESS); }); }