Skip to content

Commit

Permalink
Fix some TinyASM types
Browse files Browse the repository at this point in the history
  • Loading branch information
JDBetteridge committed Jul 3, 2024
1 parent 12e2082 commit a0587a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
8 changes: 6 additions & 2 deletions tinyasm/matinvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@


PetscErrorCode mymatinvert(PetscInt* n, PetscScalar* mat, PetscInt* piv, PetscInt* info, PetscScalar* work) {
PetscCallBLAS("LAPACKgetrf",LAPACKgetrf_(n,n,mat,n,piv,info));
PetscCallBLAS("LAPACKgetri",LAPACKgetri_(n,mat, n, piv,work,n,info));
PetscBLASInt *n_blas, *piv_blas, *info_blas;
PetscCall(PetscBLASIntCast(*n, n_blas));
PetscCall(PetscBLASIntCast(*piv, piv_blas));
PetscCall(PetscBLASIntCast(*info, info_blas));
PetscCallBLAS("LAPACKgetrf",LAPACKgetrf_(n_blas, n_blas, mat, n_blas, piv_blas, info_blas));
PetscCallBLAS("LAPACKgetri",LAPACKgetri_(n_blas, mat, n_blas, piv_blas, work, n_blas, info_blas));
return 0;
}

13 changes: 7 additions & 6 deletions tinyasm/tinyasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class BlockJacobi {

int numBlocks = dofsPerBlock.size();
PetscInt dof;
int biggestBlock = 0;
PetscInt biggestBlock = 0;
for(int p=0; p<numBlocks; p++) {
dof = dofsPerBlock[p].size();
biggestBlock = max(biggestBlock, dof);
Expand Down Expand Up @@ -108,9 +108,10 @@ class BlockJacobi {


PetscInt solve(const PetscScalar* __restrict b, PetscScalar* __restrict x) {
PetscInt dof, ierr;
PetscBLASInt dof;
PetscInt ierr;
PetscScalar dOne = 1.0;
PetscInt one = 1;
PetscBLASInt one = 1;
PetscScalar dZero = 0.0;

const PetscScalar *matvalues;
Expand Down Expand Up @@ -324,9 +325,9 @@ PetscErrorCode PCView_TinyASM(PC pc, PetscViewer viewer) {
PetscInt biggestblock = *std::max_element(blocksizes.begin(), blocksizes.end());
PetscScalar avgblock = std::accumulate(blocksizes.begin(), blocksizes.end(), 0.)/nblocks;
ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
ierr = PetscViewerASCIIPrintf(viewer, "TinyASM (block Jacobi) preconditioner with %d blocks\n", nblocks);CHKERRQ(ierr);
ierr = PetscViewerASCIIPrintf(viewer, "TinyASM (block Jacobi) preconditioner with %" PetscInt_FMT " blocks\n", nblocks);CHKERRQ(ierr);
ierr = PetscViewerASCIIPrintf(viewer, "Average block size %f \n", avgblock);CHKERRQ(ierr);
ierr = PetscViewerASCIIPrintf(viewer, "Largest block size %d \n", biggestblock);CHKERRQ(ierr);
ierr = PetscViewerASCIIPrintf(viewer, "Largest block size %" PetscInt_FMT " \n", biggestblock);CHKERRQ(ierr);
ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
}
return 0;
Expand Down Expand Up @@ -428,6 +429,6 @@ PYBIND11_MODULE(_tinyasm, m) {
auto blockjacobi = new BlockJacobi(dofsPerBlock, globalDofsPerBlock, localsize, newsf);
pc->data = (void*)blockjacobi;
ierr = PetscLogEventEnd(PC_tinyasm_SetASMLocalSubdomains, pc, 0, 0, 0);CHKERRQ(ierr);
return ierr;
return (int) ierr;
});
}

0 comments on commit a0587a0

Please sign in to comment.