Issue 89398
Summary [OMPT] Detecting undeferred task
Labels new issue
Assignees
Reporter rpereira-dev
    ### Standard
The standard 5.2 specifies
> When an if clause is present on a task construct and the if clause _expression_ evaluates to false, an undeferred task is generated, and the encountering thread must suspend the current task region, for which execution cannot be resumed until execution of the structured block that is associated with the generated task is completed. [...]
> [...]
> When an if clause is present and the if clause _expression_ evaluates to false, undeferred tasks are generated. [...]

I read it as "the implementation is free to make any tasks `undeferred` if it pleases".

Regarding OMPT, a tool can detect whether a task is `undeferred` using the `task-create` event callback
```C++
void ompt_callback_task_create(
        ompt_data_t * encountering_task_data,
        const ompt_frame_t * encountering_task_frame,
        ompt_data_t * new_task_data,
 int flags,   // if undeferred, then flags & ompt_task_undeferred evaluates to true
        int has_dependences,
        const void *codeptr_ra
);
```

### Implementation
LLVM's OpenMP may *serialize* tasks in different scenarios (i.e. blocks the current thread execution until the task completion), see https://github.com/llvm/llvm-project/blob/4ea24946e356be31446fc30ca3d11cc5783ba2a6/openmp/runtime/src/kmp_tasking.cpp#L1621-L1623

The `ompt_task_undeferred` bit-flag is set for any *serialized*-tasks to OMPT, see https://github.com/llvm/llvm-project/blob/4ea24946e356be31446fc30ca3d11cc5783ba2a6/openmp/runtime/src/ompt-internal.h#L47-L53


### The issue
OMPT-based tools cannot currently detects whether a task is `undeferred` due to
- (1) programmers' code - `pragma omp task if(0)` or child of a `final` task, `mergeable` or included ...
- (2) or to an implementation serialization decision - for instance, LLVM serializes if `OMP_NUM_THREADS=1` or when a throttling criteria is met

I suggest that `flags & ompt_task_undeferred` evaluates to true only in the case (1) and not in (2) - programmers code matter.    
We could also add an LLVM-specific `ompt_task_serialized` if detecting (2) matters to anyone.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to