Skip to content

perf: avoid hardware pext/pdep on pre-zen3 amd cpus #9114

Description

@m7kss1

hardware pext/pdep can in some cases be slower than a software fallback. so the fact that bmi2 instruction set is supported does not always mean that using pext/pdep is profitable. it might be reasonable to add separate check which excludes amd cpus before zen3 to use this instruction

this is how it is currently done, it always selects _pext_u64, even though there is already a fallback implementation nearby:

https://github.com/vortex-data/vortex/blob/develop/vortex-array/src/arrays/bool/compute/filter.rs#L93-L100
https://github.com/vortex-data/vortex/blob/develop/vortex-array/src/arrays/bool/compute/filter.rs#L103-L119

there is similar dispatch in the fastlanes bit transpose code and in several places using pdep:
https://github.com/vortex-data/vortex/blob/develop/encodings/fastlanes/src/bit_transpose/x86.rs#L25-L30
https://github.com/vortex-data/vortex/blob/develop/vortex-mask/src/intersect_by_rank.rs#L393-L431

note: i didn't do any benchmarks yet, but this is source of truth about the performance of these instructions i checked before opening this issue:

https://uops.info/html-instr/PEXT_R32_R32_M32.html
https://uops.info/html-instr/PEXT_R64_R64_R64.html
https://docs.rs/succinctly/latest/src/succinctly/json/simd/bmi2.rs.html#1-16

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions