Skip to content

Limiting parallelism for certain map operations in a Rayon parallel computation #1193

Answered by bradlarsen
bradlarsen asked this question in Q&A
Discussion options

You must be logged in to vote

What I have ended up doing is using multiple Rayon pools, connected with a pair of crossbeam channels. The output elements of the first Rayon pool get written to the channel; the second Rayon pool reads from the channel using par_bridge().

This has worked well. This also allows, for example, to initialize thread-local state (such as GPU contexts) on each worker of a particular Rayon thread pool.

Surely there is room to do better in terms of efficiency and parallel scalability for connecting the two Rayon thread pools. In particular, instead of using a single shared pair of crossbeam channels to connect the two, it might be possible to directly multiplex the outputs of the first pool to th…

Replies: 3 comments 7 replies

Comment options

You must be logged in to vote
4 replies
@bradlarsen
Comment options

@bradlarsen
Comment options

@cuviper
Comment options

@bradlarsen
Comment options

Comment options

You must be logged in to vote
1 reply
@adamreichold
Comment options

Comment options

You must be logged in to vote
2 replies
@adamreichold
Comment options

@bradlarsen
Comment options

Answer selected by bradlarsen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants