This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][libomp] Fix crash when LIBOMP_NUM_HIDDEN_HELPER_THREADS=1.
ClosedPublic

Authored by AndreyChurbanov on Feb 11 2022, 1:22 PM.

Details

Summary

It looks logical to treat user request for number of helper threads as
the number of threads doing actual job, excluding main thread of hidden helper team
which does not participate in tasks execution.

The increment also fixes the division by 0 caused by % operation:
#define KMP_GTID_TO_SHADOW_GTID(gtid) ((gtid) % (kmp_hidden_helper_threads_num - 1) + 2)
when
kmp_hidden_helper_threads_num == 1.

Diff Detail

Event Timeline

AndreyChurbanov requested review of this revision.Feb 11 2022, 1:22 PM

Thanks Andrey for the fix

openmp/runtime/src/kmp_settings.cpp
1249

once -> since

Addressed Ravi's comment.

AndreyChurbanov marked an inline comment as done.Feb 11 2022, 1:45 PM
tianshilei1992 accepted this revision.Feb 11 2022, 3:04 PM

Thanks for the fix. Can you mention "Fixes #48656" in the commit message as well such that #48656 can be closed automatically.

openmp/runtime/src/kmp_settings.cpp
1249
This revision is now accepted and ready to land.Feb 11 2022, 3:04 PM