Skip to content
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

[Support] Add parallel_for_dynamic with dynamic schedules #9056

Merged
merged 3 commits into from
Sep 22, 2021
Merged

[Support] Add parallel_for_dynamic with dynamic schedules #9056

merged 3 commits into from
Sep 22, 2021

Conversation

junrushao
Copy link
Member

This PR introduces an API parallel_for_dynamic which is analogous to OpenMP's dynamic scheduling below:

#pragma omp parallel for schedule(dynamic) num_threads(num_threads)
for (int i = 0; i < 10; i++) {
    a[i] = i;
}

CC: @jcf94 @zxybazh @comaniac

@junrushao junrushao changed the title [Support] Add Paralel-For with dynamic schedules [Support] Add parallel_for_dynamic with dynamic schedules Sep 20, 2021
try {
worker(0);
} catch (const std::exception& e) {
for (auto&& thread : threads) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a C++ noob question: may I ask why using the auto&& r-value reference for thread?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks for the pointer! :)

Copy link
Contributor

@YuchenJin YuchenJin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @junrushao1994 for adding dynamic scheduling support!

Copy link
Member

@zxybazh zxybazh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick, otherwise LGTM.

src/support/parallel_for.cc Outdated Show resolved Hide resolved
Copy link
Member

@Hzfengsy Hzfengsy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @junrushao1994

@Hzfengsy Hzfengsy merged commit ae3c5d6 into apache:main Sep 22, 2021
ylc pushed a commit to ylc/tvm that referenced this pull request Sep 29, 2021
)

* [Support] Add parallel_for_dynamic with dynamic schedules

* Update parallel_for.cc

* Update parallel_for.cc
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 13, 2022
)

* [Support] Add parallel_for_dynamic with dynamic schedules

* Update parallel_for.cc

* Update parallel_for.cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants