Repository navigation
Fix PETSc integer-width mismatches in boundary registration and JIT callbacks - #813
Merged
lmoresi merged 4 commits intoOct 6, 2026
Conversation
Use the PETSc header's PetscInt rather than a private C int typedef. Allocate component and constraint-index arrays with PETSc.IntType and use PetscInt for boundary label storage and Cython component views, avoiding int32 buffers passed to an int64 PETSc API. Add Couette regression cases for inferred and legacy explicit component lists. Both fail on the published Gadi int64 image at the component dtype assertion and pass against the existing Mac int32 installation; isolated int64 rebuild validation follows. Underworld development team with AI support from Claude Code
Remove the generated callback header's private int32 PetscInt alias. Residual and Jacobian callbacks must use the same configured integer width as PETSc and the compiled Cython declarations. Underworld development team with AI support from Claude Code
Verify exact Couette flow for inferred and explicit Dirichlet components in two and three dimensions, and for natural traction conditions. All five baselines pass on the existing int32 installation; the int64 isolated build exercises the same cases. Underworld development team with AI support from Claude Code
The all-Dirichlet Couette problem has constant pressure. On four Gadi ranks the Schur right-hand side is about 5.6e-14; the default absolute tolerance of 1e-50 and relative tolerance of 1e-10 force an unattainable residual target and cause pressure divergence followed by NaN velocity subsolves. This also reproduces on unchanged upstream development with int32. Declare the constant-pressure nullspace and use a test-specific pressure-block absolute tolerance of 1e-12. Retain the original velocity accuracy, convergence, component-value and PETSc integer-width assertions. All five analytic regressions pass on four ranks with PETSc 3.25.4 int32 and int64 on Gadi. Production solver defaults are unchanged. Underworld development team with AI support from Claude Code
Member
Issues in this branch's territoryTerritory is
No open issue is against the integer-width mismatch itself; this is the first. |
lmoresi
approved these changes
Oct 6, 2026
lmoresi
left a comment
Member
There was a problem hiding this comment.
Approved. Integer-width correctness at the PETSc boundary, with tests/test_0764_petsc_index_boundary_conditions.py covering it. A 32/64-bit mismatch in boundary registration and JIT callbacks is silent until it is not.
This was referenced Oct 7, 2026
Contributor
Author
|
@jcgraciosa, this is the PR for int64 and int32 petsc. |
lmoresi
added a commit
to gthyagi/underworld3
that referenced
this pull request
Oct 12, 2026
underworldcode#813 made the generated callback header include <petscsystypes.h>, so callbacks use PETSc's configured integer width. The generated setup.py passes no PETSc include directory, so the build works only where PETSc's headers are on the compiler's default path: a conda-forge PETSc in the environment, as in CI. With a custom PETSc build every JIT compile failed with "'petscsystypes.h' file not found". _petsc_include_dirs() reads PETSC_DIR/PETSC_ARCH from petsc4py and adds $PETSC_DIR/include and $PETSC_DIR/$PETSC_ARCH/include (petscconf.h). test_0021 checks that the headers are found and that a JIT solve compiles. Underworld development team with AI support from Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A PETSc build with 64-bit indices reads a 32-bit boundary-component buffer
[0, 1]as4294967296, causing Stokes boundary registration to fail. Boundary label scalars and generated residual/Jacobian callback signatures also assumed 32-bit integers.This change uses the PETSc header declaration for
PetscInt, allocates component and constraint-index arrays withPETSc.IntType, and gives the Cython boundary views and label storage matching types. Generated JIT callback headers includepetscsystypes.hinstead of redefining PETSc types.The branch is based directly on upstream
developmentat1391e4aaand changes only four files. It includes no mantle-convection, SUPG, DG1/XDMF, container recipes or unrelated test-fixture changes.Validation
git diff --checkpassed; test discovery covers all 316 files, including the newtest_0764*file.34839d9d;391296aachanges only the regression fixture.1391e4aawith int32. The Schur RHS was approximately5.64e-14, while its relative tolerance was1e-10and absolute tolerance1e-50. The pressure block diverged (DIVERGED_DTOL), velocity subsolves encountered NaN/Inf, and SNES returnedDIVERGED_LINEAR_SOLVE. Enabling the pressure nullspace alone, changing coarse/pressure preconditioners, and increasing mesh resolution did not fix it. A pressure-block absolute tolerance of1e-12passes all five regressions on four ranks with both widths, with the original analytic velocity bounds unchanged.gthyagi:bugfix/constrained-traction-test-hierarchy(ee7e7e98) and is deliberately excluded from this PR.391296aapassed in Gadi job 180509622 (exit 0, 4m50s): 23 serial tests for each width, including the separately corrected constrained fixture; all five new regressions on two and four ranks for each width. The hierarchy fixture also passed against the unchanged upstream int32 library in 32.72 seconds. The 23-test serial set contains 22 focused/adjacent cases plus the separately corrected existing constrained test; that correction is not in this PR. GitHub CI is running on391296aa; its deprecated-pattern scan passed.Adversarial review
We checked the diff for remaining hard-coded
np.int32component arrays andintcomponent views in the affected solver module: none remain. Boundary data, solver settings and collective ordering are unchanged. The analytic velocity oracle checks the solve as well as dtype, so a buffer-only correction with mismatched callback signatures cannot satisfy the tests. Existing guide recommendations still hold because this is an ABI correction, with no public boundary-condition semantic change.We reviewed the regression correction again: the dtype assertions still run before the solve and still reject the old int64 component storage; the original analytic velocity bounds and positive-convergence assertions remain. The test-specific pressure absolute tolerance is smaller than the velocity error bound and does not change production defaults. No rank-dependent collective branch was introduced.
The new tests are reached by the existing
test_07*pyCI glob. Both integer-width builds must compile these changes; changing only the Python source cannot validate the Cython ABI. Complex scalar compatibility and empty-rank boundary behavior are not established by these new tests.Underworld development team with AI support from Claude Code