Thyre wrote: Please note, that this solution is not perfect.
The general issue is that the OpenMP runtime is not able to provide a `dispatch` callback per OpenMP section, due to the way Clang and Flang rewrite the `sections` construct. Handling of individual `section` directives exists in `libomp`, implemented e.g. in [`__kmpc_next_section`](https://github.com/llvm/llvm-project/blob/b6059b6ce21886c3f8644355ae9017cf3ba04aad/openmp/runtime/src/kmp_dispatch.cpp#L2551). However, due to the transformation to a loop with a switch-case statement, this cannot really be used. The changes in this PR aim to provide a tool a meaningful event sequence. The dispatched events are, strictly spoken, not fully compliant with the OpenMP specification anymore, as we're using flags meant for loops, not for sections. Tools, which want to pinpoint performance bottlenecks of any individual `section` directive will also still not be able to do so with this change. However, as the prior handling was broken since the `dispatch` callback was implemented in LLVM 15, I consider this solution to be better than the currently implemented state. I see two more option on how one could handle this issue: - Drop the emitted callbacks for OpenMP `section` directives in `libomp`'s `__kmp_for_static_init`, and return `ompt_set_sometimes` as the registration result for the `dispatch` callback to reflect missing information. This would not require any change in the code generation of Clang, though Flang should then also properly communicate the `sections` construct and `section` directive. - Add a function or something to `libomp` to properly dispatch _section-begin_ events to a tool, and call this function as part of the worksharing loop generated for sections. This would also need to be adopted in Flang. The latter would certainly be preferred by tools, but might have overhead implications. Ideally, the OpenMP specification could be extended to include something like `ompt_dispatch_sections_chunk`. This would at least allow a tool to identify that a dispatched event is meant for multiple sections, though pin-pointing issues in an individual section would still be impossible. https://github.com/llvm/llvm-project/pull/210038 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
