Skip to content

Commit 283183c

Browse files
committed
Fix build on x86 and bump cargo doc version as packed_simd fails on docs.rs version
1 parent 935405c commit 283183c

File tree

5 files changed

+32
-31
lines changed

5 files changed

+32
-31
lines changed

Cargo.toml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = ["Alec Mocatta <[email protected]>"]
66
categories = ["data-structures","algorithms","science"]
77
keywords = ["streaming-algorithm","probabilistic","sketch","data-structure","hyperloglog"]
88
description = """
9-
Performant implementations of various streaming algorithms, including Count–min sketch; Top k; HyperLogLog; Reservoir sampling.
9+
SIMD-accelerated implementations of various streaming algorithms, including Count–min sketch, Top k, HyperLogLog, Reservoir sampling.
1010
"""
1111
repository = "https://github.com/alecmocatta/streaming_algorithms"
1212
homepage = "https://github.com/alecmocatta/streaming_algorithms"
@@ -26,17 +26,4 @@ twox-hash = "1.1"
2626
serde_derive = "1.0"
2727
serde = "1.0"
2828
rand = "0.5"
29-
bytecount = "0.3"
30-
# faster = { git = "https://github.com/alecmocatta/faster" } #"0.5"
31-
# faster = { path = "./faster" } #"0.5"
3229
packed_simd = { version = "0.3", features = ["into_bits"] }
33-
34-
[features]
35-
avx-accel = ["bytecount/avx-accel"]
36-
simd-accel = ["bytecount/simd-accel"]
37-
38-
# [replace]
39-
# "vektor:0.2.0" = { git = "https://github.com/alecmocatta/vektor" }
40-
41-
[profile.release]
42-
debug = 2

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
[Docs](https://docs.rs/streaming_algorithms/0.1.0)
1010

11-
Performant implementations of various [streaming algorithms](https://en.wikipedia.org/wiki/Streaming_algorithm).
11+
SIMD-accelerated implementations of various [streaming algorithms](https://en.wikipedia.org/wiki/Streaming_algorithm).
1212

1313
This library is a work in progress. PRs are very welcome! Currently implemented algorithms include:
1414

@@ -17,7 +17,13 @@ This library is a work in progress. PRs are very welcome! Currently implemented
1717
* HyperLogLog
1818
* Reservoir sampling
1919

20-
A goal of this library is to enable composition of these algorithms; for example Top k + HyperLogLog to enable roughly `SELECT key FROM table GROUP BY key ORDER BY COUNT(DISTINCT value) DESC LIMIT k`.
20+
A goal of this library is to enable composition of these algorithms; for example Top k + HyperLogLog to enable an approximate version of something akin to `SELECT key FROM table GROUP BY key ORDER BY COUNT(DISTINCT value) DESC LIMIT k`.
21+
22+
Run your application with `RUSTFLAGS="-C target-cpu=native"` to benefit from the SIMD-acceleration like so:
23+
24+
```bash
25+
RUSTFLAGS="-C target-cpu=native" cargo run --release
26+
```
2127

2228
See [this gist](https://gist.github.com/debasishg/8172796) for a good list of further algorithms to be implemented. Other resources are [Probabilistic data structures – Wikipedia](https://en.wikipedia.org/wiki/Category:Probabilistic_data_structures), [DataSketches – A similar Java library originating at Yahoo](https://datasketches.github.io/), and [Algebird – A similar Java library originating at Twitter](https://github.com/twitter/algebird).
2329

src/distinct.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -392,29 +392,33 @@ mod simd_types {
392392
use self::simd_types::*;
393393

394394
struct Sad<X>(PhantomData<fn(X)>);
395+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
396+
mod x86 {
397+
#[cfg(target_arch = "x86")]
398+
pub use std::arch::x86::*;
399+
#[cfg(target_arch = "x86_64")]
400+
pub use std::arch::x86_64::*;
401+
}
395402
// TODO
396403
// #[cfg(target_feature = "avx512bw")]
397404
// impl Sad<packed_simd::u8x64> {
398405
// #[inline]
399406
// #[target_feature(enable = "avx512bw")]
400407
// unsafe fn sad(a: packed_simd::u8x64, b: packed_simd::u8x64) -> packed_simd::u64x8 {
401-
// use std::{arch::x86_64::_mm512_sad_epu8, mem::transmute};
402-
// packed_simd::Simd(transmute(_mm512_sad_epu8(transmute(a.0), transmute(b.0))))
408+
// use std::mem::transmute;
409+
// packed_simd::Simd(transmute(x86::_mm512_sad_epu8(transmute(a.0), transmute(b.0))))
403410
// }
404411
// }
405-
mod x86 {
406-
#[cfg(target_arch = "x86")]
407-
pub use std::arch::x86::*;
408-
#[cfg(target_arch = "x86_64")]
409-
pub use std::arch::x86_64::*;
410-
}
411412
#[cfg(target_feature = "avx2")]
412413
impl Sad<packed_simd::u8x32> {
413414
#[inline]
414415
#[target_feature(enable = "avx2")]
415416
unsafe fn sad(a: packed_simd::u8x32, b: packed_simd::u8x32) -> packed_simd::u64x4 {
416417
use std::mem::transmute;
417-
packed_simd::Simd(transmute(x86::_mm256_sad_epu8(transmute(a.0), transmute(b.0))))
418+
packed_simd::Simd(transmute(x86::_mm256_sad_epu8(
419+
transmute(a.0),
420+
transmute(b.0),
421+
)))
418422
}
419423
}
420424
#[cfg(target_feature = "sse2")]

src/lib.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Performant implementations of various [streaming algorithms](https://en.wikipedia.org/wiki/Streaming_algorithm).
1+
//! SIMD-accelerated implementations of various [streaming algorithms](https://en.wikipedia.org/wiki/Streaming_algorithm).
22
//!
33
//! **[Crates.io](https://crates.io/crates/streaming_algorithms) │ [Repo](https://github.com/alecmocatta/streaming_algorithms)**
44
//!
@@ -9,7 +9,13 @@
99
//! * HyperLogLog
1010
//! * Reservoir sampling
1111
//!
12-
//! A goal of this library is to enable composition of these algorithms; for example Top k + HyperLogLog to enable roughly `SELECT key FROM table GROUP BY key ORDER BY COUNT(DISTINCT value) DESC LIMIT k`.
12+
//! A goal of this library is to enable composition of these algorithms; for example Top k + HyperLogLog to enable an approximate version of something akin to `SELECT key FROM table GROUP BY key ORDER BY COUNT(DISTINCT value) DESC LIMIT k`.
13+
//!
14+
//! Run your application with `RUSTFLAGS="-C target-cpu=native"` to benefit from the SIMD-acceleration like so:
15+
//!
16+
//! ```bash
17+
//! RUSTFLAGS="-C target-cpu=native" cargo run --release
18+
//! ```
1319
//!
1420
//! See [this gist](https://gist.github.com/debasishg/8172796) for a good list of further algorithms to be implemented. Other resources are [Probabilistic data structures – Wikipedia](https://en.wikipedia.org/wiki/Category:Probabilistic_data_structures), [DataSketches – A similar Java library originating at Yahoo](https://datasketches.github.io/), and [Algebird – A similar Java library originating at Twitter](https://github.com/twitter/algebird).
1521
//!
@@ -54,11 +60,9 @@
5460
extern crate twox_hash;
5561
#[macro_use]
5662
extern crate serde_derive;
57-
// extern crate bytecount;
63+
extern crate packed_simd;
5864
extern crate rand;
5965
extern crate serde;
60-
// extern crate faster;
61-
extern crate packed_simd;
6266

6367
mod count_min;
6468
mod distinct;

src/top.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ mod test {
354354
// println!("{:#?}", x);
355355
}
356356

357-
// #[ignore] // takes too long on CI
357+
#[ignore] // takes too long on CI
358358
#[test]
359359
fn many() {
360360
let start = time::Instant::now();

0 commit comments

Comments
 (0)