Issue 84180
Summary [OMPT] Cancelled tasks schedules
Labels new issue
Assignees
Reporter rpereira-dev
    Something seems wrong with the OMPT `task_schedule` event on tasks whose taskgroup had been cancelled, please see minimal example bellow

LLVM version
```bash
$ clang --version
clang version 19.0.0git (https://github.com/rpereira-dev/llvm-project a64975f9660e02f5f6688f8bcc55daf9eaa99fda)
Target: x86_64-unknown-linux-gnu
Thread model: posix
```

main.c
```C
# include <stdio.h>
# include <unistd.h>

# include <omp.h>

int main(void)
{
    # pragma omp parallel
    {
        # pragma omp single
        {
 # pragma omp taskgroup
            {
                # pragma omp task if(0) // A
                {
 puts("cancelling");
                    # pragma omp cancel taskgroup
                }

                # pragma omp task // B
                    puts("run");
            }
        }
 }
    return 0;
}
```

OMPT tool used
```bash
git clone -b llvm/untied-schedule https://github.com/rpereira-dev/ompt-dump.git
```

Compiled and run as
```
clang -Wall -Werror -Wextra -fopenmp main.c
OMP_CANCELLATION=1 OMP_NUM_THREADS=1 OMP_TOOL_LIBRARIES=path/to/libompt_dump.so ./a.out
```

Outputs
```
  1 [OMPT] [INFO] OMPT_DUMP: OpenMP 201611 and runtime LLVM OMP version: 5.0.20140926
  2 [OMPT] [INFO] Could not register callback 'ompt_callback_device_unload'
  3 [OMPT] [INFO] Could not register callback 'ompt_callback_target_map'
  4 [OMPT] [INFO] Could not register callback 'ompt_callback_target_map_emi'
  5 [OMPT] [INFO] ompt_callback_thread_begin
  6 [OMPT] [INFO] ompt_callback_implicit_task(task_data=0x55c84b0b1440)
  7 [OMPT] [INFO] ompt_callback_parallel_begin
  8 [OMPT] [INFO] ompt_callback_implicit_task(task_data=0x55c84b0b82c0)
  9 [OMPT] [INFO] ompt_callback_work
 10 [OMPT] [INFO] ompt_callback_sync_region
 11 [OMPT] [INFO] ompt_callback_task_create(encountering_task_data=0x55c84b0b82c0, new_task_data=0x55c84b1ba880)
 12 [OMPT] [INFO] ompt_callback_task_schedule(prior_task_data=0x55c84b0b82c0, prior_task_status=7, next_task_data=0x55c84b1ba880)
 13 cancelling
 14 [OMPT] [INFO] ompt_callback_cancel(task_data=0x55c84b1ba880, flags=24)
 15 [OMPT] [INFO] ompt_callback_task_schedule(prior_task_data=0x55c84b1ba880, prior_task_status=3, next_task_data=0x55c84b0b82c0)
 16 [OMPT] [INFO] ompt_callback_task_create(encountering_task_data=0x55c84b0b82c0, new_task_data=0x55c84b1ba880)
 17 [OMPT] [INFO] ompt_callback_cancel(task_data=0x55c84b1ba880, flags=72)
 18 [OMPT] [INFO] ompt_callback_task_schedule(prior_task_data=0x55c84b1ba880, prior_task_status=3, next_task_data=0x55c84b0b82c0)
 19 [OMPT] [INFO] ompt_callback_sync_region_wait
 20 [OMPT] [INFO] ompt_callback_sync_region_wait
 21 [OMPT] [INFO] ompt_callback_sync_region
 22 [OMPT] [INFO] ompt_callback_work
 23 [OMPT] [INFO] ompt_callback_sync_region
 24 [OMPT] [INFO] ompt_callback_sync_region_wait
 25 [OMPT] [INFO] ompt_callback_sync_region_wait
 26 [OMPT] [INFO] ompt_callback_sync_region
 27 [OMPT] [INFO] ompt_callback_implicit_task(task_data=0x55c84b0b82c0)
 28 [OMPT] [INFO] ompt_callback_parallel_end
 29 [OMPT] [INFO] ompt_callback_implicit_task(task_data=0x55c84b0b1440)
 30 [OMPT] [INFO] ompt_callback_thread_end
```

Event Line 12 - The thread switches from its implicit (parent) task `0x55a0067a5280` to the explicit task A `0x55a0068a7880`
Event Line 13-14 - The taskgroup is cancelled
Event Line 15 - The thread switches from the explicit task A `0x55a0068a7880` to its implicit (parent) task `0x55a0067a5280`
Event Line 16 - The thread create the task B `0x55a0068a7880`
Event Line 17 - The thread discards the task B `0x55a0068a7880`
Event Line 18 - The thread switches from the explicit task B `0x55a0068a7880` to its implicit (parent) task `0x55a0067a5280` - (**ERROR: the current task is `0x55a0067a5280`**) 
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to