Skip to content

Load only one PetscInt width of PETSc_jll per process#241

Open
ViralBShah wants to merge 1 commit into
mainfrom
vs/single-int-width
Open

Load only one PetscInt width of PETSc_jll per process#241
ViralBShah wants to merge 1 commit into
mainfrom
vs/single-int-width

Conversation

@ViralBShah

Copy link
Copy Markdown
Member

The Int64 and Int32 libpetsc variants in the upcoming PETSc_jll 3.24 (JuliaPackaging/Yggdrasil#13691) link external packages — hypre and SuperLU_DIST — that export identical symbols with different integer ABIs (libHYPRE64 vs libHYPRE, libsuperlu_dist_Int64 vs _Int32). Loading both widths into one process cross-binds those symbols on platforms with a flat dynamic-linker namespace (Linux ELF), silently corrupting whichever width loses the load-order race.

This PR makes the libs tuple register a single width per process: Int64 by default, Int32 via the new "PetscInt" preference / set_petscint!(Int32) (takes effect after a Julia restart, standard Preferences.jl recompilation). The companion JLL change marks all libpetsc products dont_dlopen so using PETSc_jll doesn't eagerly load anything.

Also included are robustness fixes for configurations with fewer than eight libraries (single-width JLL mode and the set_library! custom mode):

  • the petsclibs[1:2] / [1:4] test loops are clamped to the available libraries
  • the second-library access in the set_petsclib test is guarded
  • examples/ex19.jl falls back to any available Float64 library when Float64/Int32 isn't loaded

Validated against locally-built PETSc 3.24.6 binaries (full test suite green in custom-library mode, including the 4-rank MPI tests; all five built variants initialize and report the right version).

🤖 Generated with Claude Code

The Int64 and Int32 libpetsc variants link external packages (hypre,
SuperLU_DIST) that export identical symbols with different integer
ABIs.  Loading both widths into one process cross-binds those symbols
on platforms with a flat dynamic-linker namespace (Linux ELF), so the
`libs` tuple now registers a single width: Int64 by default, Int32 via
the new "PetscInt" preference / `set_petscint!(Int32)` (one Julia
restart, standard Preferences.jl recompilation).

Related robustness fixes for configurations with fewer than eight
libraries (single-width JLL mode and set_library! custom mode):
- clamp the petsclibs[1:2]/[1:4] loops in the tests
- guard the second-library access in the set_petsclib test
- examples/ex19.jl falls back to any available Float64 library when
  the Float64/Int32 combination is not loaded

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ViralBShah

Copy link
Copy Markdown
Member Author

@boriskaus I believe it is best to allow only one combination of PetSc integer type to be loaded in a process. That way only one set of libraries and dependencies are opened.

@ViralBShah

Copy link
Copy Markdown
Member Author

We'll need the test harness to test all the different PetSc variants (rather than cycle through them in the same Julia process).

Is this reasonable - or do people link to more than one variant in a typical PetSc process?

@boriskaus

boriskaus commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

I think this is very reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants