Can't run Rayon demos

Hi all,

I'm testing Rayon for demoing its threading capabilities. But any branch of the rust-nursery fork of the repo won't let me run the demos.

I'm using these instructions, and this is my setup:

felix@felix-X550LD ~/D/P/R/r/rayon-demo> rustup --version
rustup 1.11.0 (e751ff9f8 2018-02-13)
felix@felix-X550LD ~/D/P/R/r/rayon-demo> rustc --version
rustc 1.26.2 (594fb253c 2018-06-01)
felix@felix-X550LD ~/D/P/R/r/rayon-demo> rustc +nightly --version
rustc 1.28.0-nightly (f28c7aef7 2018-06-19)
felix@felix-X550LD ~/D/P/R/r/rayon-demo> cargo --version
cargo 1.26.0 (0e7c5a931 2018-04-06)

The errors that I'm getting are these:

Fiber branch:

felix@felix-X550LD ~/D/P/R/r/rayon-demo> git checkout fiber 
Previous HEAD position was f541d2f... Add deadlock detection
Switched to branch 'fiber'
Your branch is up-to-date with 'origin/fiber'.
felix@felix-X550LD ~/D/P/R/r/rayon-demo> cargo +nightly run --release -- nbody visualize
error: current package believes it's in a workspace when it's not:
current:   /home/felix/Documents/Programming/Rust/rustc-rayon/rayon-demo/Cargo.toml
workspace: /home/felix/Documents/Programming/Rust/rustc-rayon/Cargo.toml

this may be fixable by adding `rayon-demo` to the `workspace.members` array of the manifest located at: /home/felix/Documents/Programming/Rust/rustc-rayon/Cargo.toml

After I follow the fixit idea, I get this:

felix@felix-X550LD ~/D/P/R/r/rayon-demo> cargo +nightly run --release -- nbody visualize
    Updating registry `https://github.com/rust-lang/crates.io-index`
    Updating git repository `https://github.com/Zoxc/context-rs.git`
error: no matching package named `rayon` found                                  
location searched: file:///home/felix/Documents/Programming/Rust/rustc-rayon
required by package `rayon-demo v0.0.0 (file:///home/felix/Documents/Programming/Rust/rustc-rayon/rayon-demo)`

Master branch

The master branch downloads all the dependencies from the outset, and it doesn't require me to change the Cargo.toml files. So far so good. But the compiler complains about the lifetime of a particular binding (is binding the word?):

felix@felix-X550LD ~/D/P/R/r/rayon-demo> cargo +nightly run --release -- nbody visualize
    Updating registry `https://github.com/rust-lang/crates.io-index`
    Updating git repository `https://github.com/Zoxc/scoped-tls.git`
   Compiling rayon-core v1.3.0 (file:///home/felix/Documents/Programming/Rust/rustc-rayon/rayon-core)
   Compiling rayon v0.9.0 (file:///home/felix/Documents/Programming/Rust/rustc-rayon)
   Compiling rayon-demo v0.0.0 (file:///home/felix/Documents/Programming/Rust/rustc-rayon/rayon-demo)
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
  --> rayon-demo/src/tsp/graph.rs:52:25
   |
52 |               .filter_map(move |target| {
   |  _________________________^
53 | |                 self.edge_weight(source, target)
54 | |                     .map(|weight| {
55 | |                         Edge {
...  |
60 | |                     })
61 | |             })
   | |_____________^
   |
note: first, the lifetime cannot outlive the lifetime 'a as defined on the method body at 50:5...
  --> rayon-demo/src/tsp/graph.rs:50:5
   |
50 |     pub fn edges<'a>(&'a self, source: Node) -> impl Iterator<Item=Edge> {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = note: ...so that the types are compatible:
           expected &tsp::graph::Graph
              found &'a tsp::graph::Graph
   = note: but, the lifetime must be valid for the static lifetime...
note: ...so that return value is valid for the call
  --> rayon-demo/src/tsp/graph.rs:50:49
   |
50 |     pub fn edges<'a>(&'a self, source: Node) -> impl Iterator<Item=Edge> {
   |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0495`.
error: Could not compile `rayon-demo`.

To learn more, run the command again with --verbose.

And after following its tips, this is what I get, which I really have no clue what it means (sorry):

For more information about this error, try `rustc --explain E0495`.
error: Could not compile `rayon-demo`.

Caused by:
  process didn't exit successfully: `rustc --crate-name rayon_demo rayon-demo/src/main.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C metadata=3ca8f7f3a5e10ea8 -C extra-filename=-3ca8f7f3a5e10ea8 --out-dir /home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps -L dependency=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps --extern cgmath=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps/libcgmath-d4024f67ab742796.rlib --extern docopt=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps/libdocopt-6ac12f383b0ebf5a.rlib --extern fixedbitset=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps/libfixedbitset-3ded117707d78a0b.rlib --extern glium=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps/libglium-3f4ee596e26be749.rlib --extern lazy_static=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps/liblazy_static-99513f7ff28cd35c.rlib --extern odds=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps/libodds-fe3ac71a556ccee0.rlib --extern rand=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps/librand-d932bed56d110733.rlib --extern rayon=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps/librayon-72e1f141ac560a3c.rlib --extern regex=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps/libregex-9873ddb303a9d5a0.rlib --extern serde=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps/libserde-7a58715653c3c6ff.rlib --extern serde_derive=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps/libserde_derive-16bd1771de89b3e0.so --extern time=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps/libtime-1064c29487e7524e.rlib -L native=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/build/backtrace-sys-26aa82fb9a8747d4/out` 
(exit code: 101)
felix@felix-X550LD ~/D/P/R/r/rayon-demo> rustc --explain E0495
error: no extended information for E0495

Other branches

rustc, crate, crate-0.1.0, staging, trying and v0.7 behave just like fiber

custom-scheduler, factor-out-futures and flat-combine behave like master

And seq-to-par-pipeline behaves a bit differently:

   Compiling rayon v0.7.0 (file:///home/felix/Documents/Programming/Rust/rustc-rayon)
     Running `rustc --crate-name rayon src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C metadata=c968bdbe82cd7d72 -C extra-filename=-c968bdbe82cd7d72 --out-dir /home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps -L dependency=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps --extern rayon_core=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps/librayon_core-1f8fe122c6748fd5.rlib`
error[E0432]: unresolved import `pipeline`
  --> src/prelude.rs:11:9
   |
11 | pub use pipeline::IntoParPipeline;
   |         ^^^^^^^^ Maybe a missing `extern crate pipeline;`?

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
error: Could not compile `rayon`.

Caused by:
  process didn't exit successfully: `rustc --crate-name rayon src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C metadata=c968bdbe82cd7d72 -C extra-filename=-c968bdbe82cd7d72 --out-dir /home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps -L dependency=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps --extern rayon_core=/home/felix/Documents/Programming/Rust/rustc-rayon/target/release/deps/librayon_core-1f8fe122c6748fd5.rlib` (exit code: 101)
warning: build failed, waiting for other jobs to finish...
error: build failed

What am I doing wrong? It feels like I should be using a different version of the compiler, maybe.

Sorry if the errors are obvious. I'm (very) new to Rust and am working on a presentation to show my HPC course partners what Rust can allow you to do :slight_smile:

Is there any particular reason you are using the nursery version? From the looks of it, you've stumbled on an experimental version that doesn't play nice with the current nightly.

The 'official' crates.io version links to the rayon-rs organisation, which seems to be both more active (last commit 6 days ago on master vs. 1 month ago on "obscure" branch 'fiber') and more geared to outside users (managed by bors, Rust's buildbot)

P.s. since your presentation is tomorrow, the rayon gitter chat may provide more speedy/interactive feedback

1 Like

Not at all! I just thought it would be the most up-to-date one :sweat_smile:

:smiley:! I will try that

Edit: it works! And oh wow, it's so much faster than the sequential version :D!

Thank youuuuuuuuuuuuu <3

2 Likes

:tada:

:notes:
tum. tum. tum. Another likes the Rust. And another one likes.. another one likes.. another one likes the Rust!

4 Likes

The official one is rayon-rs/rayon -- I'll ask the nursery folks to change their repo title. The rustc-rayon fork has some experimental features that @Zoxc developed to help parallelize rustc itself, but we haven't generalized / merged them into rayon proper yet. They also have a PR here:

3 Likes

Oh, very exciting! Especially since AMD has kicked of a new race for high-corecount CPUs!