openfoam: add 'precision' easyconfig param (DP/SP/SPDP) - #4189
Draft
hmeiland wants to merge 1 commit into
Draft
Conversation
Add a custom 'precision' easyconfig parameter (default 'DP') to the OpenFOAM easyblock so single- and mixed-precision builds can be produced from an easyconfig instead of a manual WM_PRECISION_OPTION override. OpenFOAM's etc/bashrc sets WM_PRECISION_OPTION=DP unconditionally, so a plain env var is clobbered when Allwmake sources bashrc. For SP/SPDP the easyblock now writes the sanctioned etc/prefs.sh override (sourced after the DP default and before WM_OPTIONS is computed), sets the build-time env var, threads the precision into the platform subdir name (linux64Gcc<PREC>Int32Opt), and exports WM_PRECISION_OPTION in the module. Default 'DP' reproduces the previous behaviour exactly: no prefs.sh is written, and the subdir/env values are identical to the prior hardcoded 'DP', so existing easyconfigs build unchanged.
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.
What
Adds a custom
precisioneasyconfig parameter to the OpenFOAM easyblock, so single-precision (SP) and mixed-precision (SPDP) OpenFOAM modules can be built directly from an easyconfig instead of a manualWM_PRECISION_OPTIONoverride.Why
OpenFOAM's
etc/bashrcsetsWM_PRECISION_OPTION=DPunconditionally, so simply exporting the env var is clobbered the momentAllwmakesourcesbashrc. The sanctioned override point isetc/prefs.sh(sourced after the DP default and beforeWM_OPTIONSis computed).For non-DP builds the easyblock now:
WM_PRECISION_OPTION=<prec>into the install'setc/prefs.sh(idempotent — only if not already present),linux64Gcc<PREC>Int32Opt),WM_PRECISION_OPTIONin the generated module.The concrete motivation is the
petsc4Foam(OpenFOAM external-solver) adapter linked against a single-precision PETSc (--with-precision=single), which requiresPetscScalar == Foam::solveScalar == float, i.e. anSPOpenFOAM.Backward compatibility
The parameter defaults to
'DP', which reproduces the previous behaviour exactly:self.wm_precision != 'DP'is false → noprefs.shis written,...DP...as the prior hardcoded literal,WM_PRECISION_OPTION=DPenv/module export matches what OpenFOAM's ownbashrcalready sets.So existing OpenFOAM easyconfigs (which never mention
precision) build unchanged.Testing
python -m py_compileclean.SPOpenFOAM v2506 (foss/2025a) module on AMD gfx1101, consumed by a single-precisionpetsc4Foamadapter; DP builds verified to produce byte-identicalpsubdir/module env vs. the stock easyblock.