Skip to content

A portable Rust SIMD vector library providing architecture-optimized operations

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

FastestMolasses/simd_vector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simd_vector

simd_vector::Vector<T> represents an immutable vector with a size that's automatically determined by your CPU architecture and is designed as a building block for vectorizing large algorithms.

Features

  • 📦 Built on Rust's portable_simd
  • 🚀 Automatic selection of optimal SIMD lane count based on hardware architecture
  • 🔒 Type-safe operations with compile-time size checking
  • ⚡ Zero-cost abstractions over hardware SIMD instructions
  • 💪 Support for common numeric types (f32, f64, i8, i16, i32, i64, u8, u16, u32, u64)
  • 🔄 Cross-platform support (x86_64, aarch64)

Installation

Add this to your Cargo.toml:

[dependencies]
simd_vector = "0.1.0"

⚠️ Note: This crate requires a nightly Rust compiler due to the use of portable_simd.

rustup override set nightly  # Set nightly for this project
# or
rustup default nightly      # Set nightly as your default toolchain

Usage

use simd_vector::Vector;

// Create vectors
let a = Vector::<f32>::new(1.0);
let b = Vector::<f32>::new(2.0);

// Basic arithmetic
let sum = a + b;
let diff = a - b;
let product = a * b;
let quotient = a / b;

// Reduction operations
let total = sum.reduce_sum();

// Element-wise operations
let abs_values = a.abs();
let min_values = Vector::min(a, b);
let max_values = Vector::max(a, b);

Lane Counts

The number of lanes in a vector depends on both the data type and the target architecture.

Type x86_64 (256-bit AVX) aarch64 (128-bit NEON) Other (128-bit)
f32 8 lanes 4 lanes 4 lanes
f64 4 lanes 2 lanes 2 lanes
i8 32 lanes 16 lanes 16 lanes
i16 16 lanes 8 lanes 8 lanes
i32 8 lanes 4 lanes 4 lanes
i64 4 lanes 2 lanes 2 lanes
u8 32 lanes 16 lanes 16 lanes
u16 16 lanes 8 lanes 8 lanes
u32 8 lanes 4 lanes 4 lanes
u64 4 lanes 2 lanes 2 lanes

Contributing

  1. Fork the Repository: Start by forking the repository to your own GitHub account.
  2. Clone the Forked Repository: Clone the fork to your local machine.
  3. Create a New Branch: Always create a new branch for your changes.
  4. Make Your Changes: Implement your changes.
  5. Run Tests: Make sure to test your changes locally.
  6. Submit a Pull Request: Commit and push your changes, then create a pull request against the main branch.

About

A portable Rust SIMD vector library providing architecture-optimized operations

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages