Skip to content

Feature Request: OpenMP/TBB like Parallel For Loops #859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
steveklabnik opened this issue Feb 15, 2015 · 6 comments
Closed

Feature Request: OpenMP/TBB like Parallel For Loops #859

steveklabnik opened this issue Feb 15, 2015 · 6 comments
Labels
A-community-library Area: The RFC is related to a community library. T-libs-api Relevant to the library API team, which will review and decide on the RFC.

Comments

@steveklabnik
Copy link
Member

Issue by siavashserver
Friday Feb 28, 2014 at 11:14 GMT

For earlier discussion, see rust-lang/rust#12619

This issue was labelled with: A-libs in the Rust repository


Is it possible to have some easy to use parallel for loops like OpenMP or Intel TBB in Rust? As far as I know their parallel for loops divide the range by CPU cores (or specified worker threads), then every worker thread will access a sequential stream of data in memory (better CPU cache utilization) and idle worker threads are also able to steal tasks from busy ones to balance the load (which is optional in OMP, and the default for the TBB).

Serial code:

void SerialApplyFoo( float b[], const float a[], size_t n ){
    for( size_t i=0; i<n; ++i )
        b[i] = Foo(a[i]);
}

Intel TBB example:

void ParallelApplyFoo (float b[], const float a[], size_t n){
    tbb::parallel_for (size_t(0), n, [=](size_t i) {
        b[i] = Foo(a[i]);
    });
}

OpenMP example:

void ParallelApplyFoo( float b[], const float a[], size_t n ){
    #pragma omp parallel for
    for( size_t i=0; i<n; ++i )
        b[i] = Foo(a[i]);
}
@Ericson2314
Copy link
Contributor

New Send should make this easy to do out of tree.

@aturon
Copy link
Member

aturon commented Sep 11, 2015

cc @alexcrichton

@jnicholls
Copy link

This is possible with scoped threads, so probably already satisfied with simple_parallel + crossbeam no?

Would love to see more things enter into std.

@kamalmarhubi
Copy link
Contributor

Also relevant is @nikomatsakis' rayon:

Rayon is a data-parallelism library for Rust. It is extremely lightweight and makes it easy to convert a sequential computation into a parallel one. It also guarantees data-race freedom.

Recent blog post: http://smallcultfollowing.com/babysteps/blog/2015/12/18/rayon-data-parallelism-in-rust/

@petrochenkov petrochenkov added T-libs-api Relevant to the library API team, which will review and decide on the RFC. and removed A-libs labels Jan 29, 2018
@JayKickliter
Copy link

@steveklabnik can this be closed?

@steveklabnik
Copy link
Member Author

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-community-library Area: The RFC is related to a community library. T-libs-api Relevant to the library API team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests

7 participants