You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: SIMD compilation mode - CPU portable vs native mode selection (#67)
This pull request introduces a new SIMD mode configuration system for
the FastPFOR crate, allowing users to select between portable, native,
and runtime SIMD instruction sets for the C++ backend. The changes
improve build flexibility, CI reliability, and documentation clarity,
while updating the crate version and standardizing feature usage in
development scripts.
### SIMD Mode Configuration and Build System
* Added support for selecting SIMD mode (`portable`, `native`, or
`runtime`) via Cargo features and the `FASTPFOR_SIMD_MODE` environment
variable; the build script now warns if multiple SIMD features are
enabled and passes the selected mode to CMake. (`build.rs`,
`Cargo.toml`)
[[1]](diffhunk://#diff-d0d98998092552a1d3259338c2c71e118a5b8343dd4703c0c7f552ada7f9cb42L16-R59)
[[2]](diffhunk://#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542R28-R35)
* Updated GitHub Actions CI workflow to test all combinations of OS and
SIMD mode, and to cache builds separately for each SIMD mode.
(`.github/workflows/ci.yml`)
### Documentation Improvements
* Expanded `README.md` with a clear explanation of SIMD modes, their use
cases, and configuration recommendations for end users.
### Development Scripts and Testing
* Standardized the use of the `_all_compatible` feature group in the
`justfile` for building, testing, linting, and coverage, and added
recipes to test all SIMD modes.
[[1]](diffhunk://#diff-deb9bb56fb122db0b605aa5b63f95a4665c905b18dd670e1fa6c877576a94ff1L4-R30)
[[2]](diffhunk://#diff-deb9bb56fb122db0b605aa5b63f95a4665c905b18dd670e1fa6c877576a94ff1L51-R65)
[[3]](diffhunk://#diff-deb9bb56fb122db0b605aa5b63f95a4665c905b18dd670e1fa6c877576a94ff1L95-R130)
[[4]](diffhunk://#diff-deb9bb56fb122db0b605aa5b63f95a4665c905b18dd670e1fa6c877576a94ff1L130-R145)
* Improved installation logic in the `justfile` for development tools,
with clearer output and better CI compatibility.
### Version Update
* Bumped the crate version from `0.7.0` to `0.8.0` to reflect these
breaking and feature enhancements. (`Cargo.toml`)
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: README.md
+14-1Lines changed: 14 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,9 +48,22 @@ Unless otherwise specified, all codecs support `&[u32]` only.
48
48
## Usage
49
49
50
50
### Crate Features
51
-
*`cpp` - C++ implementation (default)
51
+
*`cpp` - C++ implementation (default, uses portable SIMD mode)
52
52
*`rust` - Rust implementation (work in progress, opt-in)
53
53
54
+
#### SIMD Mode Configuration
55
+
56
+
The C++ backend can be compiled with different SIMD instruction sets. Control this by enabling one of these features:
57
+
| Mode | Description |
58
+
|------|-------------|
59
+
|`cpp_portable`|**Default.** Uses SSE4.2 baseline only. Binaries run on any x86-64 CPU from ~2008+. Best for distributable libraries. |
60
+
|`cpp_native`| Uses `-march=native` to enable all SIMD instructions supported by the build machine (AVX, AVX2, etc.). Maximum performance but may crash on CPUs lacking those instructions. |
61
+
|`cpp_runtime`| Experimental. Reserved for future runtime CPU dispatch. |
62
+
63
+
Feature selection can be overridden with the `FASTPFOR_SIMD_MODE` environment variable set to "portable", "native", or "runtime".
64
+
65
+
**Recommendation:** Use `portable` (default) for libraries and distributed binaries. Use `native` only when building for a specific machine where you need maximum performance.
0 commit comments