This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Fix the issue where `num_threads` still takes effect incorrectly
ClosedPublic

Authored by tianshilei1992 on Jun 13 2023, 7:35 PM.

Details

Summary

This patch fixes the issue that, if we have a compile-time serialized parallel
region (such as if (0)) with num_threads, followed by a regular parallel
region, the regular parallel region will pick up the value set in the serialized
parallel region incorrectly. The reason is, in the front end, if we can prove a
parallel region has to serialized, instead of emitting __kmpc_fork_call, the
front end directly emits __kmpc_serialized_parallel, body, and __kmpc_end_serialized_parallel.
However, this "optimization" doesn't consider the case where num_threads is
used such that __kmpc_push_num_threads is still emitted. Since we don't reset
the value in __kmpc_serialized_parallel, it will affect the next parallel region
followed by it.

Fix #63197.

Diff Detail

Event Timeline

tianshilei1992 created this revision.Jun 13 2023, 7:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 7:35 PM
tianshilei1992 requested review of this revision.Jun 13 2023, 7:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 7:35 PM
This revision is now accepted and ready to land.Jun 14 2023, 7:55 AM