xref: /llvm-project/openmp/runtime/test/ompt/tasks/task_late_fulfill.c (revision c46ccb8538c5c0b4724a842e110ad46d7e1b107a)
1*c46ccb85SJoachim Protze // RUN: %libomp-compile && env OMP_NUM_THREADS='3' \
210995c77SJoachim Protze // RUN:    %libomp-run | %sort-threads | FileCheck %s
3617787eaSAndreyChurbanov // REQUIRES: ompt
410995c77SJoachim Protze 
56d9626d2SJoachim Protze // Checked gcc 10.1 still does not support detach clause on task construct.
66d9626d2SJoachim Protze // UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7, gcc-8, gcc-9, gcc-10
7*c46ccb85SJoachim Protze // gcc 11 introduced detach clause, but gomp interface in libomp has no support
8*c46ccb85SJoachim Protze // XFAIL: gcc-11, gcc-12
910995c77SJoachim Protze // clang supports detach clause since version 11.
1010995c77SJoachim Protze // UNSUPPORTED: clang-10, clang-9, clang-8, clang-7
1110995c77SJoachim Protze // icc compiler does not support detach clause.
1210995c77SJoachim Protze // UNSUPPORTED: icc
1310995c77SJoachim Protze 
1410995c77SJoachim Protze #include "callback.h"
1510995c77SJoachim Protze #include <omp.h>
1610995c77SJoachim Protze 
main()1710995c77SJoachim Protze int main() {
1810995c77SJoachim Protze #pragma omp parallel
1910995c77SJoachim Protze #pragma omp master
2010995c77SJoachim Protze   {
2110995c77SJoachim Protze     omp_event_handle_t event;
2210995c77SJoachim Protze     omp_event_handle_t *f_event;
2310995c77SJoachim Protze #pragma omp task detach(event) depend(out : f_event) shared(f_event) if (0)
2410995c77SJoachim Protze     {
2510995c77SJoachim Protze       printf("task 1\n");
2610995c77SJoachim Protze       f_event = &event;
2710995c77SJoachim Protze     }
2810995c77SJoachim Protze #pragma omp task depend(in : f_event)
2910995c77SJoachim Protze     { printf("task 2\n"); }
3010995c77SJoachim Protze     printf("calling omp_fulfill_event\n");
3110995c77SJoachim Protze     omp_fulfill_event(*f_event);
3210995c77SJoachim Protze #pragma omp taskwait
3310995c77SJoachim Protze   }
3410995c77SJoachim Protze   return 0;
3510995c77SJoachim Protze }
3610995c77SJoachim Protze 
3710995c77SJoachim Protze // Check if libomp supports the callbacks for this test.
3810995c77SJoachim Protze // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_create'
3910995c77SJoachim Protze // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_schedule'
4010995c77SJoachim Protze // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_parallel_begin'
4110995c77SJoachim Protze // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_parallel_end'
4210995c77SJoachim Protze // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_implicit_task'
4310995c77SJoachim Protze // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_mutex_acquire'
4410995c77SJoachim Protze // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_mutex_acquired'
4510995c77SJoachim Protze // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_mutex_released'
4610995c77SJoachim Protze 
4710995c77SJoachim Protze // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
4810995c77SJoachim Protze 
4910995c77SJoachim Protze // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_parallel_begin:
5010995c77SJoachim Protze // CHECK-SAME: parent_task_id=[[PARENT_TASK_ID:[0-9]+]],
5110995c77SJoachim Protze // CHECK-SAME: parent_task_frame.exit=[[NULL]],
5210995c77SJoachim Protze // CHECK-SAME: parent_task_frame.reenter=0x{{[0-f]+}},
5310995c77SJoachim Protze // CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]],
5410995c77SJoachim Protze // CHECK-SAME: requested_team_size=3,
5510995c77SJoachim Protze 
5610995c77SJoachim Protze // CHECK: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin:
5710995c77SJoachim Protze // CHECK-SAME: parallel_id=[[PARALLEL_ID]],
5810995c77SJoachim Protze // CHECK-SAME: task_id=[[IMPLICIT_TASK_ID:[0-9]+]]
5910995c77SJoachim Protze 
6047cb8a0fSJoachim Protze // The following is to match the taskwait task created in __kmpc_omp_wait_deps
6147cb8a0fSJoachim Protze // this should go away, once codegen for "detached if(0)" is fixed
6247cb8a0fSJoachim Protze 
6347cb8a0fSJoachim Protze // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create:
6447cb8a0fSJoachim Protze // CHECK-SAME: parent_task_id=[[IMPLICIT_TASK_ID]],
6547cb8a0fSJoachim Protze // CHECK-SAME: has_dependences=yes
6647cb8a0fSJoachim Protze 
6710995c77SJoachim Protze // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create:
6810995c77SJoachim Protze // CHECK-SAME: parent_task_id=[[IMPLICIT_TASK_ID]],
6910995c77SJoachim Protze // CHECK-SAME: parent_task_frame.exit=0x{{[0-f]+}},
7010995c77SJoachim Protze // CHECK-SAME: parent_task_frame.reenter=0x{{[0-f]+}},
7110995c77SJoachim Protze // CHECK-SAME: new_task_id=[[TASK_ID:[0-9]+]],
7210995c77SJoachim Protze 
7310995c77SJoachim Protze // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_task_schedule:
7410995c77SJoachim Protze // CHECK-SAME: first_task_id=[[IMPLICIT_TASK_ID]],
7510995c77SJoachim Protze // CHECK-SAME: second_task_id=[[TASK_ID]],
7610995c77SJoachim Protze // CHECK-SAME: prior_task_status=ompt_task_switch=7
7710995c77SJoachim Protze 
7810995c77SJoachim Protze // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_task_schedule:
7910995c77SJoachim Protze // CHECK-SAME: first_task_id=[[TASK_ID]],
8010995c77SJoachim Protze // CHECK-SAME: second_task_id=[[IMPLICIT_TASK_ID]],
8110995c77SJoachim Protze // CHECK-SAME: prior_task_status=ompt_task_detach=4
8210995c77SJoachim Protze 
8310995c77SJoachim Protze // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_task_schedule:
8410995c77SJoachim Protze // CHECK-SAME: first_task_id=[[TASK_ID]],
8510995c77SJoachim Protze // CHECK-SAME: second_task_id=18446744073709551615,
8610995c77SJoachim Protze // CHECK-SAME: prior_task_status=ompt_task_late_fulfill=6
87