Skip to content

[OpenMP] Add num_threads clause list format and strict modifier support #85466

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

Merged
merged 10 commits into from
Jun 24, 2024

Conversation

TerryLWilmarth
Copy link
Contributor

Add support to the runtime for 6.0 spec features that allow num_threads clause to take a list, and also make use of the strict modifier. Provides new compiler interface functions for these features.

Add support to the runtime for 6.0 spec features that allow
num_threads clause to take a list, and also make use of the strict
modifier.  Provides new compiler interface functions for these
features.
@llvmbot llvmbot added the openmp:libomp OpenMP host runtime label Mar 15, 2024
@shiltian
Copy link
Contributor

Can we have tests?

@shiltian shiltian changed the title Add num_threads clause list format and strict modifier support [OpenMP] Add num_threads clause list format and strict modifier support Mar 27, 2024
Copy link

github-actions bot commented Mar 30, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Contributor

@shiltian shiltian left a comment

Choose a reason for hiding this comment

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

LGTM. Will the front end support be upstreamed as well?

@@ -1268,6 +1268,11 @@ kmp_set_disp_num_buffers 890
__kmpc_atomic_val_8_cas_cpt 2158
%endif

# No longer need to put ordinal numbers
Copy link
Contributor

Choose a reason for hiding this comment

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

This will not cause issue on Windows anymore?

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, you can add exported symbols just by name now. Older symbols keep their ordinal number.

Copy link
Contributor

@jpeyton52 jpeyton52 left a comment

Choose a reason for hiding this comment

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

LGTM

@TerryLWilmarth TerryLWilmarth merged commit d30b082 into llvm:main Jun 24, 2024
5 checks passed
@mstorsjo
Copy link
Member

This change causes failed tests on i386: https://github.com/mstorsjo/llvm-mingw/actions/runs/9654575386/job/26643787120

# .---command stderr------------
# | OMP: Error #137: Cannot create thread.
# | OMP: System error #8: (No system error message available)
# `-----------------------------
# error: command failed with exit status: 3

I presume the test spawns a very large number of threads? Can it be marked with UNSUPPORTED for 32 bit environments somehow?

@TerryLWilmarth
Copy link
Contributor Author

This change causes failed tests on i386: https://github.com/mstorsjo/llvm-mingw/actions/runs/9654575386/job/26643787120

# .---command stderr------------
# | OMP: Error #137: Cannot create thread.
# | OMP: System error #8: (No system error message available)
# `-----------------------------
# error: command failed with exit status: 3

I presume the test spawns a very large number of threads? Can it be marked with UNSUPPORTED for 32 bit environments somehow?

Yes, in the second to last case, the test uses a pretty deep level of nesting, and tests the num_threads clause list at two different nesting levels, so it will generate a lot of threads. We could modify the test so that the list used at the outer level is something like 3,1 and inner level is 3,1, which should create 9 threads at most. That should be adequate to show the feature is working correctly. Would that work for this system?

@mstorsjo
Copy link
Member

This change causes failed tests on i386: https://github.com/mstorsjo/llvm-mingw/actions/runs/9654575386/job/26643787120

# .---command stderr------------
# | OMP: Error #137: Cannot create thread.
# | OMP: System error #8: (No system error message available)
# `-----------------------------
# error: command failed with exit status: 3

I presume the test spawns a very large number of threads? Can it be marked with UNSUPPORTED for 32 bit environments somehow?

Yes, in the second to last case, the test uses a pretty deep level of nesting, and tests the num_threads clause list at two different nesting levels, so it will generate a lot of threads. We could modify the test so that the list used at the outer level is something like 3,1 and inner level is 3,1, which should create 9 threads at most. That should be adequate to show the feature is working correctly. Would that work for this system?

I'm pretty sure that 9 threads should be quite doable to spawn. If you put up a PR to do this modification, I might be able to test it.

@mstorsjo
Copy link
Member

Ping - can you post the change (or provide a link to it?) for reducing the number of threads here, to get the tests back to passing again?

@TerryLWilmarth
Copy link
Contributor Author

Working on it.

@TerryLWilmarth
Copy link
Contributor Author

Martin, will it work with 36 threads? I have a pull request for that change up now. Using 1 in the outer level list has exposed what appears to be a non-trivial bug. I'll work on that and add the triggering test case when fixed. Let me know if the 36 threads case will work for you for now. Thanks!

AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
…rt (llvm#85466)

Add support to the runtime for 6.0 spec features that allow num_threads
clause to take a list, and also make use of the strict modifier.
Provides new compiler interface functions for these features.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openmp:libomp OpenMP host runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants