Newest 'rayon' Questions - Stack Overflow

Questions tagged [rayon]

A Rust data-parallelism library that makes it easy to convert sequential computations into parallel Rayon is lightweight and convenient for introducing parallelism into existing code. It guarantees data-race free executions and takes advantage of parallelism when sensible, based on work-load at runtime.

1
vote
1answer
51 views

Why rayon-based parallel processing takes more time than serial processing?

Learning Rayon, I wanted to compare the performace of parallel calculation and serial calculation of Fibonacci series. Here's my code: use rayon; use std::time::Instant; fn main() { let nth = 30;...
1
vote
1answer
55 views

Rayon find_any, and return the found item's value

Let's say I have a function f with signature fn f(a: u8) -> Result<bool, SomeError> {} Now I have a Vec<u8> and I wish to find if there's any element in this Vec whose value by f is ...
5
votes
3answers
112 views

Parallel access to arbitrary indices of a large vector that are guaranteed to be disjoint

Context I have a case where multiple threads must update objects stored in a shared vector. However, the vector is very large, and the number of elements to update is relatively small. Problem In a ...
1
vote
1answer
66 views

Calling `Arc::new()` Inside a Rayon Thread Results in Garbage Compiler Errors

I'm have a function that generates hashes from various inputs. One such hash I want to store as a Arc<[u8; 16]> so I can share it between threads and structs. Before, I was storing it as a Vec&...
1
vote
0answers
84 views

Is there a way to convert Select.rs's find iterator into a Rayon ParallelIterator?

I would like to convert Select.rs's Find-iterator into a Rayon ParallelIterator. I haven't been able to do this by simply mucking about with the API. I suspect I shall have to implement or extend a ...
2
votes
2answers
109 views

Will Rayon avoid spawning threads for a small amount of work?

I was thinking about using Rayon's parallel iterator feature, but I'm concerned about performance for iterating over small collections. Parallelism overhead sometimes can cause a slowdown on small ...
0
votes
1answer
98 views

Trying to collect into vector but failing with “a collection cannot be built over elements of type <…>”

I am trying to find the saddle points of a matrix, a borrowed array of vectors. For the purposes of this, a saddle point is an element of the matrix that is either the smallest in its column and the ...
0
votes
0answers
32 views

par_bridge().map() halts and consumes memory instead of iterating?

I'm trying to read a stream of JSON objects line-by-line from stdin and extract the "value" key from them as a string: use rayon::prelude::*; // 1.0.3 use serde_json::Value; // 1.0.37 use std::io::{...
1
vote
1answer
117 views

How does Rayon prevent the use of RefCell<T>, Cell<T> and Rc<T> between threads?

The Rayon documentation say it guarantees that using Rayon APIs will not introduce data races. How can the compiler know that the method called by the closures is not sharing mutable state, for ...
0
votes
1answer
47 views

How do I detect overflow on a sum of integers using Rayon?

Is there a way to detect an overflow in Rayon and force it to panic instead of having an infinite loop? extern crate rayon; use rayon::prelude::*; fn main() { let sample: Vec<u32> = (0.....
2
votes
1answer
209 views

Is there a way to directly consume a Rayon chain without collecting it first?

I am using Rayon to produce reasonably large return values. This uses a lot of memory when collecting all returned values into a Vec. Is there a way to avoid creating a Vec and directly consuming as ...
4
votes
1answer
195 views

Is it possible to combine Rayon and Faster?

Rayon looks great for algorithm parallelization of collections, and Faster is great for vectorization (SIMD) on the x86 platform for collections like Vec<f32>. I've tried to combine them and the ...
2
votes
1answer
123 views

Implement rayon `as_parallel_slice` using iterators

I have a small problem of my own: extern crate rayon; use rayon::prelude::*; #[derive(Debug)] struct Pixel { r: Vec<i8>, g: Vec<i8>, b: Vec<i8>, } #[derive(Debug)] ...
2
votes
3answers
323 views

How can I use Rayon to split a big range into chunks of ranges and have each thread find within a chunk?

I am making a program that brute forces a password by parallelization. At the moment the password to crack is already available as plain text, I'm just attempting to brute force it anyway. I have a ...
-1
votes
1answer
444 views

No method named `par_iter` found for type [closed]

I am trying to parallelize the following iter call using the rayon crate https://github.com/vishpat/stl/blob/master/src/lib.rs#L315 and replace the iter call with par_iter but get the following ...
5
votes
2answers
771 views

How do I use Rayon with an existing iterator?

I turn a regex into a HashSet after doing some filtering. I am trying to use it with Rayon, but I can't figure out how to make Rayon work with an existing iterator without converting it to a vector ...
2
votes
2answers
526 views

Replace iter() with par_iter(): cannot borrow data mutably in a captured outer variable in an `Fn` closure

I was hoping to replace an iter() with Rayon's par_iter() in a rather simple case like this, but I am failing to do so. The previous code: indexes_to_increment .iter() .for_each(|x| self....
0
votes
1answer
529 views

How to satisfy the Iterator trait bound in order to use Rayon here?

I'm attempting to parallelise the Ramer–Douglas-Peucker line simplification algorithm by using Rayon's par_iter instead of iter: extern crate num_traits; use num_traits::{Float, ToPrimitive}; extern ...
10
votes
1answer
468 views

Per-thread initialization in Rayon

I am trying to optimize my function using Rayon's par_iter(). The single threaded version is something like: fn verify_and_store(store: &mut Store, txs: Vec<Tx>) { let result = txs....
5
votes
1answer
2k views

How to use rayon's .par_iter() with a vector of generics?

This is a contrived example but I believe if I can get this working I can apply it to my specific case. extern crate num; extern crate rayon; use rayon::prelude::*; use num::Float; fn sqrts<T: ...
2
votes
1answer
621 views

Can't find crate for `rayon`

I am trying to find the diameter of a BST using parallelization: extern crate rayon; use std::cmp::Ordering::*; use std::ops::Index; use rayon::prelude::*; #[derive(Debug)] struct Node<K> { ...
2
votes
2answers
2k views

Cannot use Rayon's `.par_iter()`

I have a struct which implements Iterator and it works fine as an iterator. It produces values, and using .map(), I download each item from a local HTTP server and save the results. I now want to ...