================

----------------
Thyre wrote:

Thanks a lot for taking a look at the PR. Unfortunately, I don't quite get your 
comment, but I'll try to give a bit more context anyway.

The changes in this test reflect the consequence of changing the ident flags in 
the Clang code gen. Since we're switching from `OMP_IDENT_WORK_SECTIONS` to 
`OMP_IDENT_WORK_LOOP`, the OpenMP runtime will dispatch the work callback with 
`ompt_work_loop_static` instead of `ompt_work_sections`. The flag is mapped via 
the ident flags (see 
[here](https://github.com/llvm/llvm-project/blob/f04bf4791ae6d56b822f9bca6eb82ce4adccb989/openmp/runtime/src/kmp_sched.cpp#L115)).
A similar change happens for the dispatch callback.

The main benefit for an attached tool comes from the `ptr` argument of the 
dispatch callback.
For a section directive, the argument should point to the code address of the 
structured block.
For loops, the arguments points to a struct, which contains the number of 
iterations for the chunk, and its start index. With this, an attached tool can 
find out the actual number of section directives being executed, and if all 
threads of a team are involved or not.

This is a significant improvement compared to the state reported in 
https://github.com/llvm/llvm-project/issues/207746, where a tool had no way of 
finding out how many section directives exist, and which threads are executing 
any of them.

The same behavior can be seen with Flang already:
```
[...]
281474976710658: ompt_event_loop_static_begin: parallel_id=1000000000005, 
task_id=1000000000006, codeptr_ra=0x560acecf4431, count=2
281474976710658: ompt_event_ws_loop_chunk_begin: parallel_id=1000000000005, 
task_id=1000000000006, codeptr_ra=(nil), chunk_start=0, chunk_iterations=1
281474976710658: ompt_event_loop_static_end: parallel_id=1000000000005, 
task_id=1000000000006, codeptr_ra=0x560acecf4466, count=0
[...]
562949953421313: ompt_event_loop_static_begin: parallel_id=1000000000005, 
task_id=2000000000002, codeptr_ra=0x560acecf4431, count=2
562949953421313: ompt_event_ws_loop_chunk_begin: parallel_id=1000000000005, 
task_id=2000000000002, codeptr_ra=(nil), chunk_start=1, chunk_iterations=1
562949953421313: ompt_event_loop_static_end: parallel_id=1000000000005, 
task_id=2000000000002, codeptr_ra=0x560acecf4466, count=0
[...]
```

This PR is basically aligning Clang and Flang, while improving the situation 
for tools a bit.

https://github.com/llvm/llvm-project/pull/210038
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to