Documentation
¶
Overview ¶
Package simd provides a SIMD abstraction layer for vector operations. This package supports runtime detection of SIMD capabilities and provides fallback implementations for systems without SIMD support.
NOTE: The codebase now uses github.com/zeebo/xxh3 for hashing, which already includes native ARM64 NEON and x86 SSE/AVX SIMD optimizations. This package remains for future SIMD operations beyond hashing.
PERFORMANCE: Do NOT replace xxh3 with cryptographic hashes (SHA-256, etc.). xxh3 is ~20x faster and is designed for deduplication, not security.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlignSlice ¶
AlignSlice ensures a slice is properly aligned for SIMD operations. It returns a new slice with appropriate alignment and padding.
func Available ¶
func Available() bool
Available returns true if SIMD operations are available and can be used. It performs runtime checks for:
- Architecture support (AMD64 or ARM64)
- SIMD instruction set availability
- Go version compatibility
Currently, this returns false on ARM64 systems (including Apple Silicon) as the simd/archsimd package is AMD64-only in Go 1.26.
func UnsafeBytes ¶
UnsafeBytes casts a byte slice to a specific type pointer for SIMD operations. This is a helper function for future SIMD implementations.
WARNING: This function uses unsafe operations and must be used carefully. The caller must ensure:
- The input slice has sufficient capacity
- The type T is appropriate for the data
- Alignment requirements are met
func UnsafeSlice ¶
UnsafeSlice casts a byte slice to a slice of a specific type. This is a helper function for future SIMD implementations.
WARNING: This function uses unsafe operations and must be used carefully.
func VectorSize ¶
func VectorSize() int
VectorSize returns the optimal vector size for SIMD operations on this system. This helps callers prepare data appropriately.
Types ¶
type Hasher ¶
type Hasher interface {
// Hash computes a hash of the input data using SIMD operations if available.
Hash(data []byte) []byte
// HashSlice computes hash for a slice of byte slices.
// This allows for batching multiple hash operations.
HashSlice(data [][]byte) [][]byte
}
Hasher interface defines operations for SIMD-optimized hashing. Implementations should use vector instructions when available.