Skip to content

ENH: Add an "opt-in" feature in NumPy for CPU features, NPY_ENABLE_CPU_FEATURES #22058

@magsol

Description

@magsol

Proposed new feature or change:

This is a "mirror image" feature of the NPY_DISABLE_CPU_FEATURES SIMD flag, which allows users to opt out of certain CPU features.

This new feature would add a second environment variable, NPY_ENABLE_CPU_FEATURES, which functions in the opposite way: NumPy would default to the baseline features it is compiled with, and then it will check any dispatch options listed in NPY_ENABLE_CPU_FEATURES and, if they are detected, enable them. This creates an "opt-in" deviation from baseline.

The motivation for this comes from wanting to enable a homogeneous set of CPU features in NumPy across a heterogeneous set of computer architectures; e.g., some machines support AVX512 and some do not. Setting NPY_DISABLE_CPU_FEATURES can work, but gets painful to set many different times in many different configurations to address the hardware variety. Instead, setting NPY_ENABLE_CPU_FEATURES once and identically for every machine would dramatically reduce overhead.

For the problem of having both NPY_DISABLE_* and NPY_ENABLE_* set: it could simply throw an error. Otherwise, if NPY_DISABLE_* is set, all the listed dispatch features become opt-out; if NPY_ENABLE_* is set, all the listed dispatch features become opt-in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions