llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.58k stars 11.34k forks source link

[OMPT] Untied tasks schedules #83883

Open rpereira-dev opened 5 months ago

rpereira-dev commented 5 months ago

Something seems wrong with the OMPT task_schedule event on untied tasks, please see minimal example bellow

LLVM version

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

main.c

int main(void)
{
    # pragma omp parallel
    {   
        # pragma omp single
        {
            # pragma omp task untied
            {}
        }
    }   
    return 0;
}

OMPT tool used

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_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=0x55c7bf5da440)
  7 [OMPT] [INFO] ompt_callback_parallel_begin
  8 [OMPT] [INFO] ompt_callback_implicit_task(task_data=0x55c7bf5e1280)
  9 [OMPT] [INFO] ompt_callback_work
 10 [OMPT] [INFO] ompt_callback_task_create(encountering_task_data=0x55c7bf5e1280, new_task_data=0x55c7bf6e3900)
 11 [OMPT] [INFO] ompt_callback_task_schedule(prior_task_data=0x55c7bf5e1280, prior_task_status=7, next_task_data=0x55c7bf6e3900)
 12 [OMPT] [INFO] ompt_callback_task_schedule(prior_task_data=0x55c7bf6e3900, prior_task_status=7, next_task_data=0x55c7bf5e1280)
 13 [OMPT] [INFO] ompt_callback_task_schedule(prior_task_data=0x55c7bf6e3900, prior_task_status=7, next_task_data=0x55c7bf6e3900)
 14 [OMPT] [INFO] ompt_callback_task_schedule(prior_task_data=0x55c7bf6e3900, prior_task_status=1, next_task_data=0x55c7bf5e1280)
 15 [OMPT] [INFO] ompt_callback_work
 16 [OMPT] [INFO] ompt_callback_sync_region
 17 [OMPT] [INFO] ompt_callback_sync_region_wait
 18 [OMPT] [INFO] ompt_callback_sync_region_wait
 19 [OMPT] [INFO] ompt_callback_sync_region
 20 [OMPT] [INFO] ompt_callback_implicit_task(task_data=0x55c7bf5e1280)
 21 [OMPT] [INFO] ompt_callback_parallel_end
 22 [OMPT] [INFO] ompt_callback_implicit_task(task_data=0x55c7bf5da440)
 23 [OMPT] [INFO] ompt_callback_thread_end

Event Line 11 - The thread switches from its implicit (parent) task 0x55c7bf5e1280 to the untied task 0x55c7bf6e3900 Event Line 12 - The thread switches from the untied task 0x55c7bf6e3900 to its implicit (parent) task 0x55c7bf5e1280 Event Line 13 - The thread switches from the untied task 0x55c7bf6e3900 to the same untied task 0x55c7bf5e1280 with the same status - (ERROR: the current task is 0x55c7bf5e1280) Event Line 14 - [...]

Removing the untied clause removes events line 13 and 14, which is what we should expect even with untied I believe ?

llvmbot commented 5 months ago

@llvm/issue-subscribers-openmp

Author: PEREIRA Romain (rpereira-dev)

Something seems wrong with the OMPT `task_schedule` event on untied tasks, please see minimal example bellow LLVM version ```bash $ clang --version clang version 19.0.0git (https://github.com/rpereira-dev/llvm-project ed327625cc1de7f0f71c63f3ae59b6ac621e2c76) Target: x86_64-unknown-linux-gnu Thread model: posix ``` main.c ```C int main(void) { # pragma omp parallel { # pragma omp single { # pragma omp task untied {} } } 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_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=0x55c7bf5da440) 7 [OMPT] [INFO] ompt_callback_parallel_begin 8 [OMPT] [INFO] ompt_callback_implicit_task(task_data=0x55c7bf5e1280) 9 [OMPT] [INFO] ompt_callback_work 10 [OMPT] [INFO] ompt_callback_task_create(encountering_task_data=0x55c7bf5e1280, new_task_data=0x55c7bf6e3900) 11 [OMPT] [INFO] ompt_callback_task_schedule(prior_task_data=0x55c7bf5e1280, prior_task_status=7, next_task_data=0x55c7bf6e3900) 12 [OMPT] [INFO] ompt_callback_task_schedule(prior_task_data=0x55c7bf6e3900, prior_task_status=7, next_task_data=0x55c7bf5e1280) 13 [OMPT] [INFO] ompt_callback_task_schedule(prior_task_data=0x55c7bf6e3900, prior_task_status=7, next_task_data=0x55c7bf6e3900) 14 [OMPT] [INFO] ompt_callback_task_schedule(prior_task_data=0x55c7bf6e3900, prior_task_status=1, next_task_data=0x55c7bf5e1280) 15 [OMPT] [INFO] ompt_callback_work 16 [OMPT] [INFO] ompt_callback_sync_region 17 [OMPT] [INFO] ompt_callback_sync_region_wait 18 [OMPT] [INFO] ompt_callback_sync_region_wait 19 [OMPT] [INFO] ompt_callback_sync_region 20 [OMPT] [INFO] ompt_callback_implicit_task(task_data=0x55c7bf5e1280) 21 [OMPT] [INFO] ompt_callback_parallel_end 22 [OMPT] [INFO] ompt_callback_implicit_task(task_data=0x55c7bf5da440) 23 [OMPT] [INFO] ompt_callback_thread_end ``` Event Line 11 - The thread switches from its implicit (parent) task `0x55c7bf5e1280` to the untied task `0x55c7bf6e3900` Event Line 12 - The thread switches from the untied task `0x55c7bf6e3900` to its implicit (parent) task `0x55c7bf5e1280` Event Line 13 - The thread switches from the untied task `0x55c7bf6e3900` to the same untied task `0x55c7bf5e1280` with the same status - (**ERROR: the current task is `0x55c7bf5e1280`**) Event Line 14 - [...] Removing the `untied` clause produces removes events line 13 and 14, which is what we should expect even with `untied` I believe ?