Skip to content

Commit 5fadf44

Browse files
authored
Merge pull request #16 from cuviper/cherry-core
Cherry-pick changes from upstream rayon-core
2 parents b1174a4 + 92cc51d commit 5fadf44

File tree

19 files changed

+309
-833
lines changed

19 files changed

+309
-833
lines changed

rayon-core/Cargo.toml

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
22
name = "rustc-rayon-core"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
authors = ["Niko Matsakis <[email protected]>",
55
"Josh Stone <[email protected]>"]
66
description = "Core APIs for Rayon - fork for rustc"
77
license = "MIT OR Apache-2.0"
88
repository = "https://github.com/rust-lang/rustc-rayon"
99
documentation = "https://docs.rs/rustc-rayon-core/"
10-
rust-version = "1.59"
10+
rust-version = "1.63"
1111
edition = "2021"
1212
readme = "README.md"
1313
keywords = ["parallel", "thread", "concurrency", "join", "performance"]
@@ -18,14 +18,12 @@ name = "rayon_core"
1818

1919
# Some dependencies may not be their latest version, in order to support older rustc.
2020
[dependencies]
21-
num_cpus = "1.2"
22-
crossbeam-channel = "0.5.0"
2321
crossbeam-deque = "0.8.1"
2422
crossbeam-utils = "0.8.0"
2523

2624
[dev-dependencies]
27-
rand = "0.8"
28-
rand_xorshift = "0.3"
25+
rand = "0.9"
26+
rand_xorshift = "0.4"
2927
scoped-tls = "1.0"
3028

3129
[target.'cfg(unix)'.dev-dependencies]

rayon-core/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ Note: This is an unstable fork made for use in rustc
22

33
Rayon-core represents the "core, stable" APIs of Rayon: join, scope, and so forth, as well as the ability to create custom thread-pools with ThreadPool.
44

5-
Maybe worth mentioning: users are not necessarily intended to directly access rayon-core; all its APIs are mirror in the rayon crate. To that end, the examples in the docs use rayon::join and so forth rather than rayon_core::join.
5+
Maybe worth mentioning: users are not necessarily intended to directly access rayon-core; all its APIs are mirrored in the rayon crate. To that end, the examples in the docs use rayon::join and so forth rather than rayon_core::join.
66

77
rayon-core aims to never, or almost never, have a breaking change to its API, because each revision of rayon-core also houses the global thread-pool (and hence if you have two simultaneous versions of rayon-core, you have two thread-pools).
88

99
Please see [Rayon Docs] for details about using Rayon.
1010

1111
[Rayon Docs]: https://docs.rs/rayon/
1212

13-
Rayon-core currently requires `rustc 1.59.0` or greater.
13+
Rayon-core currently requires `rustc 1.63.0` or greater.

rayon-core/src/broadcast/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::job::{ArcJob, StackJob};
2-
use crate::latch::LatchRef;
2+
use crate::latch::{CountLatch, LatchRef};
33
use crate::registry::{Registry, WorkerThread};
4-
use crate::scope::ScopeLatch;
54
use std::fmt;
65
use std::marker::PhantomData;
76
use std::sync::Arc;
@@ -108,7 +107,7 @@ where
108107
let n_threads = registry.num_threads();
109108
let current_thread = WorkerThread::current().as_ref();
110109
let tlv = crate::tlv::get();
111-
let latch = ScopeLatch::with_count(n_threads, current_thread);
110+
let latch = CountLatch::with_count(n_threads, current_thread);
112111
let jobs: Vec<_> = (0..n_threads)
113112
.map(|_| StackJob::new(tlv, &f, LatchRef::new(&latch)))
114113
.collect();

rayon-core/src/broadcast/test.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use crate::ThreadPoolBuilder;
44
use std::sync::atomic::{AtomicUsize, Ordering};
5+
use std::sync::mpsc::channel;
56
use std::sync::Arc;
67
use std::{thread, time};
78

@@ -14,7 +15,7 @@ fn broadcast_global() {
1415
#[test]
1516
#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
1617
fn spawn_broadcast_global() {
17-
let (tx, rx) = crossbeam_channel::unbounded();
18+
let (tx, rx) = channel();
1819
crate::spawn_broadcast(move |ctx| tx.send(ctx.index()).unwrap());
1920

2021
let mut v: Vec<_> = rx.into_iter().collect();
@@ -33,7 +34,7 @@ fn broadcast_pool() {
3334
#[test]
3435
#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
3536
fn spawn_broadcast_pool() {
36-
let (tx, rx) = crossbeam_channel::unbounded();
37+
let (tx, rx) = channel();
3738
let pool = ThreadPoolBuilder::new().num_threads(7).build().unwrap();
3839
pool.spawn_broadcast(move |ctx| tx.send(ctx.index()).unwrap());
3940

@@ -53,7 +54,7 @@ fn broadcast_self() {
5354
#[test]
5455
#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
5556
fn spawn_broadcast_self() {
56-
let (tx, rx) = crossbeam_channel::unbounded();
57+
let (tx, rx) = channel();
5758
let pool = ThreadPoolBuilder::new().num_threads(7).build().unwrap();
5859
pool.spawn(|| crate::spawn_broadcast(move |ctx| tx.send(ctx.index()).unwrap()));
5960

@@ -81,7 +82,7 @@ fn broadcast_mutual() {
8182
#[test]
8283
#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
8384
fn spawn_broadcast_mutual() {
84-
let (tx, rx) = crossbeam_channel::unbounded();
85+
let (tx, rx) = channel();
8586
let pool1 = Arc::new(ThreadPoolBuilder::new().num_threads(3).build().unwrap());
8687
let pool2 = ThreadPoolBuilder::new().num_threads(7).build().unwrap();
8788
pool1.spawn({
@@ -118,7 +119,7 @@ fn broadcast_mutual_sleepy() {
118119
#[test]
119120
#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
120121
fn spawn_broadcast_mutual_sleepy() {
121-
let (tx, rx) = crossbeam_channel::unbounded();
122+
let (tx, rx) = channel();
122123
let pool1 = Arc::new(ThreadPoolBuilder::new().num_threads(3).build().unwrap());
123124
let pool2 = ThreadPoolBuilder::new().num_threads(7).build().unwrap();
124125
pool1.spawn({
@@ -158,8 +159,8 @@ fn broadcast_panic_one() {
158159
#[test]
159160
#[cfg_attr(not(panic = "unwind"), ignore)]
160161
fn spawn_broadcast_panic_one() {
161-
let (tx, rx) = crossbeam_channel::unbounded();
162-
let (panic_tx, panic_rx) = crossbeam_channel::unbounded();
162+
let (tx, rx) = channel();
163+
let (panic_tx, panic_rx) = channel();
163164
let pool = ThreadPoolBuilder::new()
164165
.num_threads(7)
165166
.panic_handler(move |e| panic_tx.send(e).unwrap())
@@ -196,8 +197,8 @@ fn broadcast_panic_many() {
196197
#[test]
197198
#[cfg_attr(not(panic = "unwind"), ignore)]
198199
fn spawn_broadcast_panic_many() {
199-
let (tx, rx) = crossbeam_channel::unbounded();
200-
let (panic_tx, panic_rx) = crossbeam_channel::unbounded();
200+
let (tx, rx) = channel();
201+
let (panic_tx, panic_rx) = channel();
201202
let pool = ThreadPoolBuilder::new()
202203
.num_threads(7)
203204
.panic_handler(move |e| panic_tx.send(e).unwrap())
@@ -231,7 +232,7 @@ fn broadcast_sleep_race() {
231232

232233
#[test]
233234
fn broadcast_after_spawn_broadcast() {
234-
let (tx, rx) = crossbeam_channel::unbounded();
235+
let (tx, rx) = channel();
235236

236237
// Queue a non-blocking spawn_broadcast.
237238
crate::spawn_broadcast(move |ctx| tx.send(ctx.index()).unwrap());
@@ -247,7 +248,7 @@ fn broadcast_after_spawn_broadcast() {
247248

248249
#[test]
249250
fn broadcast_after_spawn() {
250-
let (tx, rx) = crossbeam_channel::bounded(1);
251+
let (tx, rx) = channel();
251252

252253
// Queue a regular spawn on a thread-local deque.
253254
crate::registry::in_worker(move |_, _| {

rayon-core/src/join/test.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
//! Tests for the join code.
22
3-
use crate::join::*;
4-
use crate::unwind;
3+
use super::*;
54
use crate::ThreadPoolBuilder;
6-
use rand::distributions::Standard;
5+
use rand::distr::StandardUniform;
76
use rand::{Rng, SeedableRng};
87
use rand_xorshift::XorShiftRng;
98

@@ -39,7 +38,7 @@ fn seeded_rng() -> XorShiftRng {
3938
#[test]
4039
fn sort() {
4140
let rng = seeded_rng();
42-
let mut data: Vec<u32> = rng.sample_iter(&Standard).take(6 * 1024).collect();
41+
let mut data: Vec<u32> = rng.sample_iter(&StandardUniform).take(6 * 1024).collect();
4342
let mut sorted_data = data.clone();
4443
sorted_data.sort();
4544
quick_sort(&mut data);
@@ -50,7 +49,7 @@ fn sort() {
5049
#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
5150
fn sort_in_pool() {
5251
let rng = seeded_rng();
53-
let mut data: Vec<u32> = rng.sample_iter(&Standard).take(12 * 1024).collect();
52+
let mut data: Vec<u32> = rng.sample_iter(&StandardUniform).take(12 * 1024).collect();
5453

5554
let pool = ThreadPoolBuilder::new().build().unwrap();
5655
let mut sorted_data = data.clone();

0 commit comments

Comments
 (0)