-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[OpenMP] Remove optimization skipping reduction struct initialization #65697
[OpenMP] Remove optimization skipping reduction struct initialization #65697
Conversation
@@ -2512,11 +2512,6 @@ void *__kmp_task_reduction_init(int gtid, int num, T *data) { | |||
KMP_ASSERT(tg != NULL); | |||
KMP_ASSERT(data != NULL); | |||
KMP_ASSERT(num > 0); | |||
if (nth == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of completely removing the branch, it might be better to check if HHT is enabled. If no, then we can safely return here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how important single threaded reduction costs really are, but sure.
This commit ensures the initialization of the reduction struct in task loops, even when the number of threads in a team is 1, provided that hidden helper threads are active. Previously, an optimization skipped this initialization in cases where there was only a single thread in the team, which led to a bug. The bug behavior resulted in a segmentation fault when hidden helper threads were active. This occurred because the reduction struct was not initialized when the task group was created by a team with only one thread, causing the hidden helper thread to encounter issues when accessing the reduction data. In addition to this fix, a LIT test for issue llvm#57522 is included to validate the resolution and prevent any regressions. Fixes: llvm#57522
35dd2e8
to
225afe4
Compare
Squashed and updated the commit message.
|
…llvm#65697) This commit removes an optimization that skips the initialization of the reduction struct if the number of threads in a team is 1. This optimization caused a bug with Hidden Helper Threads. When the task group is initially initialized by the master thread but a Hidden Helper Thread executes a target nowait region, it requires the reduction struct initialization to properly accumulate the data. This commit also adds a LIT test for issue llvm#57522 to ensure that the issue is properly addressed and that the optimization removal does not introduce any regressions. Fixes: llvm#57522
This commit removes an optimization that skips the initialization of the
reduction struct if the number of threads in a team is 1. This optimization
caused a bug with Hidden Helper Threads. When the task group is initially
initialized by the master thread but a Hidden Helper Thread executes a target
nowait region, it requires the reduction struct initialization to properly
accumulate the data.
This commit also adds a LIT test for issue #57522 to ensure that the issue is
properly addressed and that the optimization removal does not introduce any
regressions.
Fixes: #57522