Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIMD docs and SIMD Show #14379

Merged
merged 5 commits into from
May 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libcore/finally.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ also be used. See that function for more details.
# Example

```
use std::unstable::finally::Finally;
use std::finally::Finally;

(|| {
// ...
Expand Down Expand Up @@ -75,7 +75,7 @@ impl<T> Finally<T> for fn() -> T {
* # Example
*
* ```
* use std::unstable::finally::try_finally;
* use std::finally::try_finally;
*
* struct State<'a> { buffer: &'a mut [u8], len: uint }
* # let mut buf = [];
Expand Down
3 changes: 2 additions & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
html_root_url = "http://doc.rust-lang.org/")]

#![no_std]
#![feature(globs, macro_rules, managed_boxes, phase)]
#![feature(globs, macro_rules, managed_boxes, phase, simd)]
#![deny(missing_doc)]

#[cfg(test)] extern crate realcore = "core";
Expand Down Expand Up @@ -124,6 +124,7 @@ pub mod iter;
pub mod option;
pub mod raw;
pub mod result;
pub mod simd;
pub mod slice;
pub mod str;
pub mod tuple;
Expand Down
37 changes: 36 additions & 1 deletion src/libstd/unstable/simd.rs → src/libcore/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,89 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! SIMD vectors
//! SIMD vectors.
//!
//! These types can be used for accessing basic SIMD operations. Each of them
//! implements the standard arithmetic operator traits (Add, Sub, Mul, Div,
//! Rem, Shl, Shr) through compiler magic, rather than explicitly. Currently
//! comparison operators are not implemented. To use SSE3+, you must enable
//! the features, like `-C target-feature=sse3,sse4.1,sse4.2`, or a more
//! specific `target-cpu`. No other SIMD intrinsics or high-level wrappers are
//! provided beyond this module.
//!
//! ```rust
//! #[allow(experimental)];
//!
//! fn main() {
//! use std::simd::f32x4;
//! let a = f32x4(40.0, 41.0, 42.0, 43.0);
//! let b = f32x4(1.0, 1.1, 3.4, 9.8);
//! println!("{}", a + b);
//! }
//! ```
//!
//! ## Stability Note
//!
//! These are all experimental. The inferface may change entirely, without
//! warning.

#![allow(non_camel_case_types)]
#![allow(missing_doc)]

#[experimental]
#[simd]
#[deriving(Show)]
pub struct i8x16(pub i8, pub i8, pub i8, pub i8,
pub i8, pub i8, pub i8, pub i8,
pub i8, pub i8, pub i8, pub i8,
pub i8, pub i8, pub i8, pub i8);

#[experimental]
#[simd]
#[deriving(Show)]
pub struct i16x8(pub i16, pub i16, pub i16, pub i16,
pub i16, pub i16, pub i16, pub i16);

#[experimental]
#[simd]
#[deriving(Show)]
pub struct i32x4(pub i32, pub i32, pub i32, pub i32);

#[experimental]
#[simd]
#[deriving(Show)]
pub struct i64x2(pub i64, pub i64);

#[experimental]
#[simd]
#[deriving(Show)]
pub struct u8x16(pub u8, pub u8, pub u8, pub u8,
pub u8, pub u8, pub u8, pub u8,
pub u8, pub u8, pub u8, pub u8,
pub u8, pub u8, pub u8, pub u8);

#[experimental]
#[simd]
#[deriving(Show)]
pub struct u16x8(pub u16, pub u16, pub u16, pub u16,
pub u16, pub u16, pub u16, pub u16);

#[experimental]
#[simd]
#[deriving(Show)]
pub struct u32x4(pub u32, pub u32, pub u32, pub u32);

#[experimental]
#[simd]
#[deriving(Show)]
pub struct u64x2(pub u64, pub u64);

#[experimental]
#[simd]
#[deriving(Show)]
pub struct f32x4(pub f32, pub f32, pub f32, pub f32);

#[experimental]
#[simd]
#[deriving(Show)]
pub struct f64x2(pub f64, pub f64);
2 changes: 1 addition & 1 deletion src/libstd/io/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ macro_rules! iotest (
use io::net::unix::*;
use io::timer::*;
use io::process::*;
use unstable::running_on_valgrind;
use rt::running_on_valgrind;
use str;

fn f() $b
Expand Down
4 changes: 3 additions & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/")]
#![feature(macro_rules, globs, asm, managed_boxes, thread_local, link_args,
simd, linkage, default_type_params, phase, concat_idents, quad_precision_float)]
linkage, default_type_params, phase, concat_idents, quad_precision_float)]

// Don't link to std. We are std.
#![no_std]
Expand Down Expand Up @@ -144,13 +144,15 @@ pub use core::clone;
#[cfg(not(test))] pub use core::cmp;
pub use core::container;
pub use core::default;
pub use core::finally;
pub use core::intrinsics;
pub use core::iter;
#[cfg(not(test))] pub use core::kinds;
pub use core::mem;
#[cfg(not(test))] pub use core::ops;
pub use core::ptr;
pub use core::raw;
pub use core::simd;
pub use core::tuple;
#[cfg(not(test))] pub use core::ty;
pub use core::result;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/rt/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ mod imp {
mod tests {
use prelude::*;
use super::*;
use unstable::finally::Finally;
use finally::Finally;

#[test]
fn smoke_test() {
Expand Down
4 changes: 4 additions & 0 deletions src/libstd/rt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ pub use self::util::{Stdio, Stdout, Stderr};

pub use alloc::{heap, libc_heap};

// Used by I/O tests
#[experimental]
pub use self::util::running_on_valgrind;

// FIXME: these probably shouldn't be public...
#[doc(hidden)]
pub mod shouldnt_be_public {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/rt/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use rt::unwind::Unwinder;
use str::SendStr;
use sync::atomics::{AtomicUint, SeqCst};
use task::{TaskResult, TaskOpts};
use unstable::finally::Finally;
use finally::Finally;

/// The Task struct represents all state associated with a rust
/// task. There are at this point two primary "subtypes" of task,
Expand Down
14 changes: 13 additions & 1 deletion src/libstd/rt/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ use io::IoResult;
use io;
use iter::Iterator;
use libc;
use libc::uintptr_t;
use option::{Some, None, Option};
use os;
use result::Ok;
use str::{Str, StrSlice};
use unstable::running_on_valgrind;
use slice::ImmutableVector;

// Indicates whether we should perform expensive sanity checks, including rtassert!
Expand Down Expand Up @@ -162,3 +162,15 @@ memory and partly incapable of presentation to others.",
unsafe { intrinsics::abort() }
}
}

/// Dynamically inquire about whether we're running under V.
/// You should usually not use this unless your test definitely
/// can't run correctly un-altered. Valgrind is there to help
/// you notice weirdness in normal, un-doctored code paths!
pub fn running_on_valgrind() -> bool {
unsafe { rust_running_on_valgrind() != 0 }
}

extern {
fn rust_running_on_valgrind() -> uintptr_t;
}
2 changes: 1 addition & 1 deletion src/libstd/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ use option::{None, Option, Some};
use ptr::RawPtr;
use ptr;
use rt::heap::{allocate, deallocate};
use unstable::finally::try_finally;
use finally::try_finally;
use vec::Vec;

pub use core::slice::{ref_slice, mut_ref_slice, Splits, Windows};
Expand Down
16 changes: 0 additions & 16 deletions src/libstd/unstable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,8 @@

#![doc(hidden)]

use libc::uintptr_t;

pub use core::finally;

pub mod dynamic_lib;

pub mod simd;
pub mod sync;
pub mod mutex;

/// Dynamically inquire about whether we're running under V.
/// You should usually not use this unless your test definitely
/// can't run correctly un-altered. Valgrind is there to help
/// you notice weirdness in normal, un-doctored code paths!
pub fn running_on_valgrind() -> bool {
unsafe { rust_running_on_valgrind() != 0 }
}

extern {
fn rust_running_on_valgrind() -> uintptr_t;
}
2 changes: 1 addition & 1 deletion src/libsync/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use std::kinds::marker;
use std::mem;
use std::sync::atomics;
use std::unstable::finally::Finally;
use std::finally::Finally;

use mutex;

Expand Down
2 changes: 1 addition & 1 deletion src/test/bench/shootout-mandelbrot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extern crate sync;

use std::io;
use std::os;
use std::unstable::simd::f64x2;
use std::simd::f64x2;
use sync::Future;
use sync::Arc;

Expand Down
14 changes: 7 additions & 7 deletions src/test/compile-fail/simd-binop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@

#![allow(experimental)]

use std::unstable::simd::f32x4;
use std::simd::f32x4;

fn main() {

let _ = f32x4(0.0, 0.0, 0.0, 0.0) == f32x4(0.0, 0.0, 0.0, 0.0);
//~^ ERROR binary comparison operation `==` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
//~^ ERROR binary comparison operation `==` not supported for floating point SIMD vector `core::simd::f32x4`

let _ = f32x4(0.0, 0.0, 0.0, 0.0) != f32x4(0.0, 0.0, 0.0, 0.0);
//~^ ERROR binary comparison operation `!=` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
//~^ ERROR binary comparison operation `!=` not supported for floating point SIMD vector `core::simd::f32x4`

let _ = f32x4(0.0, 0.0, 0.0, 0.0) < f32x4(0.0, 0.0, 0.0, 0.0);
//~^ ERROR binary comparison operation `<` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
//~^ ERROR binary comparison operation `<` not supported for floating point SIMD vector `core::simd::f32x4`

let _ = f32x4(0.0, 0.0, 0.0, 0.0) <= f32x4(0.0, 0.0, 0.0, 0.0);
//~^ ERROR binary comparison operation `<=` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
//~^ ERROR binary comparison operation `<=` not supported for floating point SIMD vector `core::simd::f32x4`

let _ = f32x4(0.0, 0.0, 0.0, 0.0) >= f32x4(0.0, 0.0, 0.0, 0.0);
//~^ ERROR binary comparison operation `>=` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
//~^ ERROR binary comparison operation `>=` not supported for floating point SIMD vector `core::simd::f32x4`

let _ = f32x4(0.0, 0.0, 0.0, 0.0) > f32x4(0.0, 0.0, 0.0, 0.0);
//~^ ERROR binary comparison operation `>` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
//~^ ERROR binary comparison operation `>` not supported for floating point SIMD vector `core::simd::f32x4`

}
2 changes: 1 addition & 1 deletion src/test/compile-fail/simd-experimental.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#![deny(experimental)]

use std::unstable::simd;
use std::simd;

fn main() {
let _ = simd::i64x2(0, 0); //~ ERROR: experimental
Expand Down
2 changes: 1 addition & 1 deletion src/test/debuginfo/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#![allow(experimental)]
#![allow(unused_variable)]

use std::unstable::simd::{i8x16, i16x8,i32x4,i64x2,u8x16,u16x8,u32x4,u64x2,f32x4,f64x2};
use std::simd::{i8x16, i16x8,i32x4,i64x2,u8x16,u16x8,u32x4,u64x2,f32x4,f64x2};

fn main() {

Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern crate native;

use std::os;
use std::io::process::Command;
use std::unstable::finally::Finally;
use std::finally::Finally;
use std::str;

#[start]
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/simd-binop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#![allow(experimental)]

use std::unstable::simd::{i32x4, f32x4, u32x4};
use std::simd::{i32x4, f32x4, u32x4};

fn eq_u32x4(u32x4(x0, x1, x2, x3): u32x4, u32x4(y0, y1, y2, y3): u32x4) -> bool {
(x0 == y0) && (x1 == y1) && (x2 == y2) && (x3 == y3)
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/simd-issue-10604.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
#![feature(simd)]

pub fn main() {
let _o = None::<std::unstable::simd::i32x4>;
let _o = None::<std::simd::i32x4>;
}