Skip to content

Commit 48f4db0

Browse files
authored
Compile examples on CI (#329)
Make sure the top-level `examples` folder is registered with the `stdsimd` crate!
1 parent 5bea452 commit 48f4db0

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

crates/stdsimd/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,11 @@ strict = [ "coresimd/strict" ]
3535
# Internal-usage only: enables only those intrinsics supported by Intel's
3636
# Software Development Environment (SDE).
3737
intel_sde = [ "coresimd/intel_sde" ]
38+
39+
[[example]]
40+
name = "hex"
41+
path = "../../examples/hex.rs"
42+
43+
[[example]]
44+
name = "nbody"
45+
path = "../../examples/nbody.rs"

examples/hex.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@
88
//!
99
//! You can test out this program via:
1010
//!
11-
//! echo test | cargo +nightly run --release --example hex
11+
//! echo test | cargo +nightly run --release --example hex -p stdsimd
1212
//!
1313
//! and you should see `746573740a` get printed out.
1414
15-
#![feature(cfg_target_feature, target_feature)]
15+
#![feature(cfg_target_feature, target_feature, stdsimd)]
1616
#![cfg_attr(test, feature(test))]
17-
#![cfg_attr(feature = "cargo-clippy",
18-
allow(result_unwrap_used, option_unwrap_used, print_stdout,
19-
missing_docs_in_private_items, shadow_reuse,
20-
cast_possible_wrap, cast_sign_loss))]
2117

2218
#[macro_use]
2319
extern crate stdsimd;
@@ -29,7 +25,10 @@ extern crate quickcheck;
2925
use std::str;
3026
use std::io::{self, Read};
3127

32-
use stdsimd::vendor::*;
28+
#[cfg(target_arch = "x86")]
29+
use stdsimd::arch::x86::*;
30+
#[cfg(target_arch = "x86_64")]
31+
use stdsimd::arch::x86_64::*;
3332

3433
fn main() {
3534
let mut input = Vec::new();
@@ -175,7 +174,7 @@ fn hex_encode_fallback<'a>(
175174
unsafe { Ok(str::from_utf8_unchecked(&dst[..src.len() * 2])) }
176175
}
177176

178-
// Run these with `cargo +nightly test --example hex`
177+
// Run these with `cargo +nightly test --example hex -p stdsimd`
179178
#[cfg(test)]
180179
mod tests {
181180
use std::iter;
@@ -281,7 +280,7 @@ mod tests {
281280
}
282281
}
283282

284-
// Run these with `cargo +nightly bench --example hex`
283+
// Run these with `cargo +nightly bench --example hex -p stdsimd`
285284
#[cfg(test)]
286285
mod benches {
287286
extern crate rand;

examples/nbody.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! html#nbody
55
66
#![cfg_attr(feature = "strict", deny(warnings))]
7-
#![feature(cfg_target_feature)]
7+
#![feature(cfg_target_feature, stdsimd)]
88
#![feature(target_feature)]
99
#![cfg_attr(feature = "cargo-clippy",
1010
allow(similar_names, missing_docs_in_private_items,
@@ -27,7 +27,10 @@ impl Frsqrt for f64x2 {
2727
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"),
2828
target_feature = "sse"))]
2929
{
30-
use stdsimd::vendor::*;
30+
#[cfg(target_arch = "x86")]
31+
use stdsimd::arch::x86::*;
32+
#[cfg(target_arch = "x86_64")]
33+
use stdsimd::arch::x86_64::*;
3134

3235
let t = self.as_f32x2();
3336

@@ -45,8 +48,12 @@ impl Frsqrt for f64x2 {
4548
#[cfg(all(any(target_arch = "arm", target_arch = "aarch64"),
4649
target_feature = "neon"))]
4750
{
48-
use self::stdsimd::vendor;
49-
unsafe { vendor::vrsqrte_f32(self.as_f32x2()).as_f64x2() }
51+
#[cfg(target_arch = "arm")]
52+
use stdsimd::arch::arm::*;
53+
#[cfg(target_arch = "aarch64")]
54+
use stdsimd::arch::aarch64::*;
55+
56+
unsafe { vrsqrte_f32(self.as_f32x2()).as_f64x2() }
5057
}
5158
#[cfg(not(any(all(any(target_arch = "x86",
5259
target_arch = "x86_64"),

0 commit comments

Comments
 (0)