SIMDNoise
Super fast SIMD noise library for Rust. PRs welcome!
Available on crates.io.
Documentation.
Features
- SSE2, SSE41, and AVX2 instruction sets, along with non SIMD fallback
- AVX2 version also leverages FMA3
- Runtime detection picks the best available instruction set
- Simplex noise, fractal brownian motion, turbulence, and ridge
- 1D, 2D, 3D, and 4D
Benchmarks
Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz Single Threaded
1D 100,000 points of FBM Noise, 3 Octaves
- scalar ... bench: 1,694,281 ns/iter (+/- 51,360)
- sse2 ... bench: 829,633 ns/iter (+/- 41,989)
- sse41 ... bench: 657,276 ns/iter (+/- 14,358)
- avx2 ... bench: 294,431 ns/iter (+/- 10,268)
2D 1000x1000 FBM Noise, 3 Octaves
- scalar ... bench: 74,686,044 ns/iter (+/- 3,053,838)
- sse2 ... bench: 23,619,783 ns/iter (+/- 1,008,879)
- sse41 ... bench: 21,847,769 ns/iter (+/- 914,364)
- avx2 ... bench: 11,791,738 ns/iter (+/- 446,718)
3D 64x64x64 FBM Noise, 3 Octaves
- scalar ... bench: 22,219,344 ns/iter (+/- 817,769)
- sse2 ... bench: 10,331,856 ns/iter (+/- 450,920)
- sse41 ... bench: 9,766,523 ns/iter (+/- 604,034)
- avx2 ... bench: 5,566,535 ns/iter (+/- 181,791)
4D 24x24x24x24 FBM Noise, 3 Octaves
- scalar ... bench: 48,324,536 ns/iter (+/- 1,813,984)
- sse2 ... bench: 26,955,224 ns/iter (+/- 1,253,751)
- sse41 ... bench: 25,792,680 ns/iter (+/- 749,234)
- avx2 ... bench: 13,080,348 ns/iter (+/- 491,006)
Todo
- AVX512 support
- ARM NEON support
- Voroni, Cell, and other noise types
Get a block of noise with runtime SIMD detection
The library will, at runtime, pick the fastest available options between SSE2, SSE41, and AVX2
use *;
// Set up noise type and parameters
let noise_type = FBM ;
// Get a block of 2d 800x600 noise, with no scaling of resulting values
// min and max values are returned so you can apply your own scaling
let = get_2d_noise;
// Get a block of 200x200x200 3d noise
let = get_3d_noise;
// Get a block of noise scaled between -1 and 1
let an_f32_vec = get_2d_scaled_noise;
Call noise functions directly
Sometimes you need something other than a block, like the points on the surface of a sphere. Sometimes you may want to use SSE41 even with AVX2 is available
// get a block of 100x100 sse41 noise, skip runtime detection
let = get_2d_noise;
// send your own SIMD x,y values to the noise functions directly
unsafe