Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(python): Specify tune-cpu & add more features #17615

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/release-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,22 @@ jobs:
# IMPORTANT: All features enabled here should also be included in py-polars/polars/_cpu_check.py
run: |
if [[ "$IS_LTS_CPU" = true ]]; then
FEATURES=+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt
elif [[ "$IS_MACOS" = true ]]; then
FEATURES=+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+fma,+pclmulqdq
TUNE_CPU=x86-64-v2
FEATURES=+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+cmpxchg16b
else
FEATURES=+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+avx2,+fma,+bmi1,+bmi2,+lzcnt,+pclmulqdq
TUNE_CPU=skylake
FEATURES=+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+cmpxchg16b,+avx,+avx2,+fma,+bmi1,+bmi2,+lzcnt,+pclmulqdq,+movbe
fi
echo "features=$FEATURES" >> $GITHUB_OUTPUT
echo "tune_cpu=$TUNE_CPU" >> $GITHUB_OUTPUT

- name: Set RUSTFLAGS for x86-64
if: matrix.architecture == 'x86-64'
env:
FEATURES: ${{ steps.features.outputs.features }}
TUNE_CPU: ${{ steps.features.outputs.tune_cpu }}
CFG: ${{ matrix.package == 'polars-lts-cpu' && '--cfg allocator="default"' || '' }}
run: echo "RUSTFLAGS=-C target-feature=${{ steps.features.outputs.features }} $CFG" >> $GITHUB_ENV
run: echo "RUSTFLAGS=-C target-feature=$FEATURES -Z tune-cpu=$TUNE_CPU $CFG" >> $GITHUB_ENV

- name: Set variables in CPU check module
run: |
Expand Down
2 changes: 2 additions & 0 deletions py-polars/polars/_cpu_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,10 @@ def _read_cpu_flags() -> dict[str, bool]:
"sse3": bool(cpuid1.ecx & (1 << 0)),
"ssse3": bool(cpuid1.ecx & (1 << 9)),
"fma": bool(cpuid1.ecx & (1 << 12)),
"cmpxchg16b": bool(cpuid1.ecx & (1 << 13)),
"sse4.1": bool(cpuid1.ecx & (1 << 19)),
"sse4.2": bool(cpuid1.ecx & (1 << 20)),
"movbe": bool(cpuid1.ecx & (1 << 22)),
"popcnt": bool(cpuid1.ecx & (1 << 23)),
"pclmulqdq": bool(cpuid1.ecx & (1 << 1)),
"avx": bool(cpuid1.ecx & (1 << 28)),
Expand Down