recon_surf.pin_cpu_dispatch

Pin which vectorised kernels numpy and OpenBLAS select, for steps that have to reproduce.

Both read their setting once, at import, so a caller in Python must pin before importing numpy and a caller in shell must pin before starting the process. Run as a script this prints the assignments for the shell form:

eval “$(python3 recon_surf/pin_cpu_dispatch.py)”

Used by the spherical projection and by talairach-reg.sh. Those are the steps where a kernel difference has been measured to survive into the output: both end in a decomposition, which turns a last-bit difference in the input into a visible one in the result.

recon_surf.pin_cpu_dispatch.enabled_simd_features(python)[source]

Ask a numpy which SIMD extensions it would dispatch to.

In a throwaway process, because the answer has to be known before this one imports numpy. Read rather than hardcoded: the names differ by numpy version and platform, unknown ones are ignored, but disabling a baseline feature raises.

Parameters:
pythonstr

The interpreter to ask, normally sys.executable.

Returns:
list[str], None

The dispatchable features this numpy has enabled. An empty list means there are none to disable, which is a pinned state rather than a failure. None means the list could not be read at all, so nothing can be pinned.

recon_surf.pin_cpu_dispatch.pin_cpu_dispatch(env, python)[source]

Pin which vectorised kernels numpy and OpenBLAS choose.

Both read their setting once, when they are imported, so this has to run before numpy reaches the interpreter. Without it the same wheel computes slightly different numbers on different machines.

A value already in env is left alone. An explicitly set variable should take effect, and it is the only escape hatch: forcing a core type the CPU cannot execute faults rather than falling back, so someone on unusual hardware needs a way to override this. Such a value may well be reproducible, it is simply not the one tested here, hence a note about the condition rather than a prediction of trouble.

Parameters:
envMutableMapping[str, str]

The environment to pin, normally os.environ.

pythonstr

The interpreter whose numpy decides the feature list, normally sys.executable.

recon_surf.pin_cpu_dispatch.pins_for(python)[source]

The variables to pin, and a warning if the numpy half could not be worked out.

Parameters:
pythonstr

The interpreter whose numpy decides the feature list, normally sys.executable.

Returns:
dict[str, str]

Variable names and the values to pin them to.

str, None

A warning to show the user, or None when there is nothing to report.