gecko-dev/third_party/rust/rayon
Kartikaya Gupta 868a8d8bd5 Bug 1438892 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel
MozReview-Commit-ID: wsncokjtul

--HG--
rename : third_party/rust/coco/LICENSE-APACHE => third_party/rust/crossbeam-deque/LICENSE-APACHE
rename : third_party/rust/coco/LICENSE-MIT => third_party/rust/crossbeam-deque/LICENSE-MIT
rename : third_party/rust/coco/LICENSE-APACHE => third_party/rust/crossbeam-epoch/LICENSE-APACHE
rename : third_party/rust/coco/LICENSE-MIT => third_party/rust/crossbeam-epoch/LICENSE-MIT
rename : third_party/rust/coco/LICENSE-APACHE => third_party/rust/crossbeam-utils/LICENSE-APACHE
rename : third_party/rust/coco/LICENSE-MIT => third_party/rust/crossbeam-utils/LICENSE-MIT
rename : third_party/rust/coco/LICENSE-APACHE => third_party/rust/rayon-0.8.2/LICENSE-APACHE
rename : third_party/rust/coco/LICENSE-MIT => third_party/rust/rayon-0.8.2/LICENSE-MIT
rename : third_party/rust/rayon/src/iter/README.md => third_party/rust/rayon-0.8.2/src/iter/README.md
rename : third_party/rust/rayon/src/iter/internal.rs => third_party/rust/rayon-0.8.2/src/iter/internal.rs
rename : third_party/rust/rayon/tests/compile-fail-unstable/future_escape.rs => third_party/rust/rayon-0.8.2/tests/compile-fail-unstable/future_escape.rs
rename : third_party/rust/rayon/tests/run-pass/sort-panic-safe.rs => third_party/rust/rayon-0.8.2/tests/run-pass/sort-panic-safe.rs
rename : third_party/rust/coco/LICENSE-APACHE => third_party/rust/rayon-core/LICENSE-APACHE
rename : third_party/rust/coco/LICENSE-MIT => third_party/rust/rayon-core/LICENSE-MIT
extra : rebase_source : fad67f2d82c7b49554ce9b03fb12da3d4b66a378
2018-02-20 09:05:08 -05:00
..
ci
examples Bug 1438892 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel 2018-02-20 09:05:08 -05:00
scripts
src Bug 1438892 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel 2018-02-20 09:05:08 -05:00
tests Bug 1438892 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel 2018-02-20 09:05:08 -05:00
.cargo-checksum.json Bug 1438892 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel 2018-02-20 09:05:08 -05:00
.travis.yml Bug 1438892 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel 2018-02-20 09:05:08 -05:00
Cargo.toml Bug 1438892 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel 2018-02-20 09:05:08 -05:00
FAQ.md Bug 1438892 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel 2018-02-20 09:05:08 -05:00
LICENSE-APACHE
LICENSE-MIT
README.md Bug 1438892 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel 2018-02-20 09:05:08 -05:00
RELEASES.md Bug 1438892 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel 2018-02-20 09:05:08 -05:00
appveyor.yml Bug 1438892 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel 2018-02-20 09:05:08 -05:00
bors.toml Bug 1438892 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel 2018-02-20 09:05:08 -05:00

README.md

Rayon

Rayon crate Rayon documentation Travis Status Appveyor status Join the chat at https://gitter.im/rayon-rs/Lobby

Rayon is a data-parallelism library for Rust. It is extremely lightweight and makes it easy to convert a sequential computation into a parallel one. It also guarantees data-race freedom. (You may also enjoy this blog post about Rayon, which gives more background and details about how it works, or this video, from the Rust Belt Rust conference.) Rayon is available on crates.io, and API Documentation is available on docs.rs.

Parallel iterators and more

Rayon makes it drop-dead simple to convert sequential iterators into parallel ones: usually, you just change your foo.iter() call into foo.par_iter(), and Rayon does the rest:

use rayon::prelude::*;
fn sum_of_squares(input: &[i32]) -> i32 {
    input.par_iter() // <-- just change that!
         .map(|&i| i * i)
         .sum()
}

Parallel iterators take care of deciding how to divide your data into tasks; it will dynamically adapt for maximum performance. If you need more flexibility than that, Rayon also offers the join and scope functions, which let you create parallel tasks on your own. For even more control, you can create custom threadpools rather than using Rayon's default, global threadpool.

No data races

You may have heard that parallel execution can produce all kinds of crazy bugs. Well, rest easy. Rayon's APIs all guarantee data-race freedom, which generally rules out most parallel bugs (though not all). In other words, if your code compiles, it typically does the same thing it did before.

For the most, parallel iterators in particular are guaranteed to produce the same results as their sequential counterparts. One caevat: If your iterator has side effects (for example, sending methods to other threads through a Rust channel or writing to disk), those side effects may occur in a different order. Note also that, in some cases, parallel iterators offer alternative versions of the sequential iterator methods that can have higher performance.

Using Rayon

Rayon is available on crates.io. The recommended way to use it is to add a line into your Cargo.toml such as:

[dependencies]
rayon = "1.0"

and then add the following to to your lib.rs:

extern crate rayon;

To use the Parallel Iterator APIs, a number of traits have to be in scope. The easiest way to bring those things into scope is to use the Rayon prelude. In each module where you would like to use the parallel iterator APIs, just add:

use rayon::prelude::*;

Rayon currently requires rustc 1.13.0 or greater.

Contribution

Rayon is an open source project! If you'd like to contribute to Rayon, check out the list of "help wanted" issues. These are all (or should be) issues that are suitable for getting started, and they generally include a detailed set of instructions for what to do. Please ask questions if anything is unclear! Also, check out the Guide to Development page on the wiki. Note that all code submitted in PRs to Rayon is assumed to be licensed under Rayon's dual MIT/Apache2 licensing.

Quick demo

To see Rayon in action, check out the rayon-demo directory, which includes a number of demos of code using Rayon. For example, run this command to get a visualization of an nbody simulation. To see the effect of using Rayon, press s to run sequentially and p to run in parallel.

> cd rayon-demo
> cargo +nightly run --release -- nbody visualize

For more information on demos, try:

> cd rayon-demo
> cargo +nightly run --release -- --help

Note: While Rayon is usable as a library with the stable compiler, running demos or executing tests requires nightly Rust.

Other questions?

See the Rayon FAQ.

License

Rayon is distributed under the terms of both the MIT license and the Apache License (Version 2.0). See LICENSE-APACHE and LICENSE-MIT for details. Opening a pull requests is assumed to signal agreement with these licensing terms.