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.

See the official documentation for more information.

123 questions
0
votes
0 answers

Function using too much memory despite using references

I have a function (method to be accurate) that's primary purpose is to zip multiple vectors (similar to the zip function in Python). Both vectors of the windows variable are extremely large but considering that these are vectors of references, I…
Shane
  • 103
  • 1
  • 6
0
votes
1 answer

Summing successes inside of a Rayon Parallelized for loop in Rust

I was having trouble understanding the monty hall problem so I put together some Rust. I have a function which determines whether or not a participant wins a game show. If they win the game show then the function returns true, otherwise it returns…
0
votes
1 answer

Parallel sampling from a random distribution in Rust?

I need to generate huge random vectors of f32s multiple times in my program, so I am looking for ways to make it parallel and efficient. I have made some progress with using Rayon's into_par_iter but I haven't found a way around having to initialize…
AmanKP
  • 95
  • 8
0
votes
1 answer

How to make par_bridge() work for a BufReader?

I wanted to use rayon's par_bridge() to parallelize an Iterator, but I could not because of the error "the method par_bridge exists for struct MyReader, but its trait bounds were not satisfied the following trait bounds were not satisfied: MyReader:…
foehn
  • 431
  • 4
  • 13
0
votes
1 answer

Passing in an async function into the closure that returns a Result which rayon::IntoParallelIterator.map accepts

I have these async functions, add_two_num, check_num: use anyhow::{Error, Result, Ok}; use rayon::prelude::*; pub async fn add_two_num(num_one: u64, num_two: u64) -> Result { check_num(num_one).await?; // calls another async function that…
Jim
  • 450
  • 2
  • 10
0
votes
1 answer

How to use a dyn Trait and still keep parallel performance in Rust?

To practice Rust I'm implementing a raytracer. First step I only implemented it only using spheres. I would loop over a Vector of Sphere structs. I could easily increase performance using rayon by doing into_iter_par. Now I'm trying to add cubes.…
nicekloki
  • 11
  • 3
0
votes
1 answer

Parallel computation of values for `ndarray` `Array2` in Rust

I am trying to speed up my calculations and I am not sure, how to best use .into_par_iter() or some of the Zip:: options from the ndarray crate in order to "correctly" parallelize the computation to speed up things. I have tried 2 ways, but I think…
0
votes
1 answer

I am unable to update to different mutable arrays while processing a big array using par_iter()

A large array of structs to be processed and two different mutable arrays should hold the values. I used par_iter and got the following error: fn par_calculate_depreciation_for_assets(assets_to_depreciate: &Vec) -> Result<(), Ferror>…
Padma
  • 37
  • 5
0
votes
2 answers

In Rust, how do you pass a function with a mutable parameter to be used in parllel?

I've been playing around with collision detection, and I've been working on a function that collides two sets of objects with each other. To allow it to be run in parallel, only the first set is mutable, and the elements of the first set are…
Kenkron
  • 573
  • 1
  • 3
  • 15
0
votes
1 answer

Rust multithread intensive methods which need to access same set of data with Rayon

I use Rayons par_iter()to iterate over different variations of the expensive method I need to run. These runs need to access the same set of checked usizes because they all need to add to it and check it from time to time. I also need them all to…
MikiS
  • 11
  • 4
0
votes
1 answer

How to use rayon to update a personal struct containing an Array in Rust

CONTEXT General overview (Here is the github page with the minimal example of my problem, and the page of my whole project) I'm very new to rust and I'm trying to simulate the behavior of a fluid in Rust. This is easy: computing large arrays with…
payasson
  • 3
  • 3
0
votes
0 answers

filter multiple vectors in a Struct of Arrays with rayon

I have a Struct of Vectors that I'm trying to filter based off precomputed indices of out-of-scope particles for a particle-in-cell program. each index will be filtered as a group, so each resulting array will be exactly the same length…
0
votes
0 answers

How to take only positive elements for decreasing parallel iterator in Rayon

I have a Rayon parallel iterator that generates a decreasing sequence of i32 values. At some moment values in this iterator becomes negative. I want to stop iteration at this point and minimize the amount of needless computations. Since rayon uses…
Dimitrius
  • 564
  • 6
  • 21
0
votes
1 answer

Rust - Parallel string builder - errors with borrow checker

I have built a password generator whilst learning the basics of the Rust programming language, but I have hit a problem. I cannot seem to parallelise the concatenation of strings in the generate_password function with Rayon. Everytime I try to do…
0
votes
0 answers

Which Generic Types are allowed in the `Vec` implementation of `ParallelExtend`

I am new to Rust and I am writing a recursive directory traversal program. This project is just an opportunity to learn Rust and parallelism with Rayon. This question is a continuation of this question which @KevinReid helped out a lot with. Below…
1 2 3
8 9