Skip to content

Commit 21fa6af

Browse files
Merge pull request #365 from rust-lang/modules
Add num, ptr, and cmp modules
2 parents 3e4e13c + 596aabe commit 21fa6af

27 files changed

+104
-65
lines changed

crates/core_simd/examples/dot_product.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#![feature(slice_as_chunks)]
77
// Add these imports to use the stdsimd library
88
#![feature(portable_simd)]
9-
use core_simd::simd::*;
9+
use core_simd::simd::prelude::*;
1010

1111
// This is your barebones dot product implementation:
1212
// Take 2 vectors, multiply them element wise and *then*

crates/core_simd/examples/matrix_inversion.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
// Code ported from the `packed_simd` crate
33
// Run this code with `cargo test --example matrix_inversion`
44
#![feature(array_chunks, portable_simd)]
5-
use core_simd::simd::*;
6-
use Which::*;
5+
use core_simd::simd::{
6+
prelude::*,
7+
Which::{self, *},
8+
};
79

810
// Gotta define our own 4x4 matrix since Rust doesn't ship multidim arrays yet :^)
911
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]

crates/core_simd/examples/nbody.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern crate std_float;
55
/// Taken from the `packed_simd` crate
66
/// Run this benchmark with `cargo test --example nbody`
77
mod nbody {
8-
use core_simd::simd::*;
8+
use core_simd::simd::prelude::*;
99
#[allow(unused)] // False positive?
1010
use std_float::StdFloat;
1111

crates/core_simd/examples/spectral_norm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(portable_simd)]
22

3-
use core_simd::simd::*;
3+
use core_simd::simd::prelude::*;
44

55
fn a(i: usize, j: usize) -> f64 {
66
((i + j) * (i + j + 1) / 2 + i + 1) as f64

crates/core_simd/src/core_simd_docs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Instead, they map to a reasonable implementation of the operation for the target
3030

3131
Consistency between targets is not compromised to use faster or fewer instructions.
3232
In some cases, `std::arch` will provide a faster function that has slightly different behavior than the `std::simd` equivalent.
33-
For example, [`_mm_min_ps`](`core::arch::x86_64::_mm_min_ps`)[^1] can be slightly faster than [`SimdFloat::simd_min`], but does not conform to the IEEE standard also used by [`f32::min`].
33+
For example, [`_mm_min_ps`](`core::arch::x86_64::_mm_min_ps`)[^1] can be slightly faster than [`SimdFloat::simd_min`](`num::SimdFloat::simd_min`), but does not conform to the IEEE standard also used by [`f32::min`].
3434
When necessary, [`Simd<T, N>`] can be converted to the types provided by `std::arch` to make use of target-specific functions.
3535

3636
Many targets simply don't have SIMD, or don't support SIMD for a particular element type.

crates/core_simd/src/masks.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ mod mask_impl;
1515
mod to_bitmask;
1616
pub use to_bitmask::{ToBitMask, ToBitMaskArray};
1717

18-
use crate::simd::{intrinsics, LaneCount, Simd, SimdElement, SimdPartialEq, SupportedLaneCount};
18+
use crate::simd::{
19+
cmp::SimdPartialEq, intrinsics, LaneCount, Simd, SimdElement, SupportedLaneCount,
20+
};
1921
use core::cmp::Ordering;
2022
use core::{fmt, mem};
2123

crates/core_simd/src/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ pub(crate) mod intrinsics;
55

66
mod alias;
77
mod cast;
8-
mod elements;
9-
mod eq;
108
mod fmt;
119
mod iter;
1210
mod lane_count;
1311
mod masks;
1412
mod ops;
15-
mod ord;
1613
mod select;
1714
mod swizzle_dyn;
1815
mod to_bytes;
@@ -24,15 +21,18 @@ pub mod simd {
2421

2522
pub mod prelude;
2623

24+
pub mod num;
25+
26+
pub mod ptr;
27+
28+
pub mod cmp;
29+
2730
pub(crate) use crate::core_simd::intrinsics;
2831

2932
pub use crate::core_simd::alias::*;
3033
pub use crate::core_simd::cast::*;
31-
pub use crate::core_simd::elements::*;
32-
pub use crate::core_simd::eq::*;
3334
pub use crate::core_simd::lane_count::{LaneCount, SupportedLaneCount};
3435
pub use crate::core_simd::masks::*;
35-
pub use crate::core_simd::ord::*;
3636
pub use crate::core_simd::swizzle::*;
3737
pub use crate::core_simd::swizzle_dyn::*;
3838
pub use crate::core_simd::to_bytes::ToBytes;

crates/core_simd/src/ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::simd::{LaneCount, Simd, SimdElement, SimdPartialEq, SupportedLaneCount};
1+
use crate::simd::{cmp::SimdPartialEq, LaneCount, Simd, SimdElement, SupportedLaneCount};
22
use core::ops::{Add, Mul};
33
use core::ops::{BitAnd, BitOr, BitXor};
44
use core::ops::{Div, Rem, Sub};

crates/core_simd/src/simd/cmp.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//! Traits for comparing and ordering vectors.
2+
3+
mod eq;
4+
mod ord;
5+
6+
pub use eq::*;
7+
pub use ord::*;

crates/core_simd/src/eq.rs renamed to crates/core_simd/src/simd/cmp/eq.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use crate::simd::{
2-
intrinsics, LaneCount, Mask, Simd, SimdConstPtr, SimdElement, SimdMutPtr, SupportedLaneCount,
2+
intrinsics,
3+
ptr::{SimdConstPtr, SimdMutPtr},
4+
LaneCount, Mask, Simd, SimdElement, SupportedLaneCount,
35
};
46

57
/// Parallel `PartialEq`.

0 commit comments

Comments
 (0)