Single-precision (fp32) build support#5033
Draft
hardik-corintis wants to merge 16 commits intofiredrakeproject:mainfrom
Draft
Single-precision (fp32) build support#5033hardik-corintis wants to merge 16 commits intofiredrakeproject:mainfrom
hardik-corintis wants to merge 16 commits intofiredrakeproject:mainfrom
Conversation
…spatialindex float64 coercion
PCPatchSetComputeFunctionExteriorFacets was added in PETSc 3.25.0 and is required by firedrake/cython/patchimpl.pyx.
- mesh.py: clarify why PETSc.RealType is correct for plex_from_cell_list - mg/kernels.py: fix to_reference_coords_kernel signature (PetscScalar *X -> %(RealType)s *X) and add RealType to the template substitution dict - evaluate.h: comment explaining why int/double is intentional for evaluate() - test_stokes_mini.py: replace fp32 solver workaround with @pytest.mark.skipsingle; fieldsplit path needs a dedicated fp32 test - conftest.py: remove trailing blank line
…nd skip VertexOnlyMesh tests in fp32
Contributor
|
Thanks for this.
What about single+complex? Isn't that a valid configuration?
This isn't necessary. That's all going to be taken care of when I release the next major version in the next 24 hours.
Can you get this fixed upstream? Clearly Claude already knows what to do. |
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.
Description
partially fixes #3040
Adds single-precision (fp32) build support. Firedrake can now run on a PETSc installation compiled with
--with-precision=single. The approach mirrors complex mode: precision is detected at import time from PETSc's build variables and flows through from there.Changes
scripts/firedrake-configure: adds--arch single, passes--with-precision=singleto PETSc, excludesfftw/suitesparse(no fp32 support)tsfc/parameters.py,tsfc/loopy.py:scalar_type/scalar_type_cderived from PETSc precision at import time; constant initializers cast to kernel dtypedtype=intwithIntTypeinnumpy.prodcalls; replacesdouble/intwithPetscReal/PetscIntin C generated code (evaluate.h,locate.c,pointquery_utils.py,pointeval_utils.py,mg/kernels.py); updatesutility_meshes.pyvertex coordinates toPETSc.RealType; physical coordinate arrays (spatial index, swarm) stayfloat64as required by libspatialindex andDMSwarmPIC_coorsingle_modeflag tofiredrake/utils.py; adds@pytest.mark.skipsinglemarker for tests incompatible with fp32; skips VertexOnlyMesh tests (test_locate_cell,test_interpolate_cross_mesh[extrudedcube])PETSc version bump (v3.24.5 → v3.25.0)
PCPatchSetComputeFunctionExteriorFacetsused inpatchimpl.pyxwas added in PETSc 3.25.0. This bump is independent of the fp32 work — it was already required byorigin/mainand exposed when testing a clean install.Known limitations
VertexOnlyMeshis broken in fp32: petsc4py'sDMSwarm.getFielddoes not handlePETSC_DOUBLEfields (DMSwarmPIC_cooris alwaysPETSC_DOUBLEregardless of scalar precision), causing anAssertionError. Fix needed upstream in petsc4py:if ctype == PETSC_DOUBLE: typenum = NPY_DOUBLEinpetsc4py/PETSc/DMSwarm.pyx.