Skip to content

[openmp][runtime][test] ompt test case failed occasionally #72231

@MANGOPIE3

Description

@MANGOPIE3

Hello, I find that there is a low probability that the openmp/runtime/test/ompt/tasks/explicit_task_thread_num.c fails.

// RUN: %libomp-compile-and-run | FileCheck %s // REQUIRES: ompt #include "callback.h" #include <omp.h> __attribute__ ((noinline)) // workaround for bug in icc void print_task_info_at(int ancestor_level, int id) { #pragma omp critical { int task_type; char buffer[2048]; ompt_data_t *parallel_data; ompt_data_t *task_data; int thread_num; ompt_get_task_info(ancestor_level, &task_type, &task_data, NULL, &parallel_data, &thread_num); format_task_type(task_type, buffer); printf("%" PRIu64 ": ancestor_level=%d id=%d task_type=%s=%d " "parallel_id=%" PRIu64 " task_id=%" PRIu64 " thread_num=%d\n", ompt_get_thread_data()->value, ancestor_level, id, buffer, task_type, parallel_data->value, task_data->value, thread_num); } }; int main() { #pragma omp parallel num_threads(2) { if (omp_get_thread_num() == 1) { // To assert that task is executed by the worker thread, // if(0) is used in order to ensure that the task is immediately // executed after its creation. #pragma omp task if(0) { // thread_num should be equal to 1 for both explicit and implicit task print_task_info_at(0, 1); print_task_info_at(1, 0); }; } } // Check if libomp supports the callbacks for this test. // CHECK-NOT: {{^}}0: Could not register callback 'ompt_event_parallel_begin' // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_create' // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_implicit_task' // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]] // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_initial_task_begin // parallel region used only to determine worker thread id // CHECK: {{^}}[[MASTER_ID]]: ompt_event_parallel_begin // CHECK-DAG: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin // CHECK-DAG: {{^}}[[WORKER_ID:[0-9]+]]: ompt_event_implicit_task_begin // thread_num must be equal to 1 for both explicit and the implicit tasks // CHECK: {{^}}[[WORKER_ID]]: ancestor_level=0 id=1 task_type=ompt_task_explicit // CHECK-SAME: thread_num=1 // CHECK: {{^}}[[WORKER_ID]]: ancestor_level=1 id=0 task_type=ompt_task_implicit // CHECK-SAME: thread_num=1 return 0; }

And error prompt

~/openmp/runtime/test/ompt/tasks/explicit_task_thread_num.c:62:12: error: CHECK: expected string not fou nd in input // CHECK: {{^}}[[WORKER_ID]]: ancestor_level=0 id=1 task_type=ompt_task_explicit ^ <stdin>:22:48: note: scanning from here 281474976710658: ompt_event_implicit_task_begin: parallel_id=281474976710661, task_id=281474976710662, team_size=2, thread_num=0 ^ <stdin>:22:48: note: with "WORKER_ID" equal to "562949953421313" 281474976710658: ompt_event_implicit_task_begin: parallel_id=281474976710661, task_id=281474976710662, team_size=2, thread_num=0 ^ <stdin>:24:98: note: possible intended match here 281474976710658: task level 0: parallel_id=281474976710661, task_id=281474976710662, exit_frame=(nil), reenter_frame=(nil), task_type=ompt _task_implicit|ompt_task_undeferred=134217730, thread_num=0 ^ Input file: <stdin> Check file: ~/openmp/runtime/test/ompt/tasks/explicit_task_thread_num.c -dump-input=help explains the following input dump. Input was: <<<<<< . . . 17: 562949953421313: ompt_event_task_schedule: first_task_id=562949953421315, second_task_id=562949953421314, prior_task_status =ompt_task_complete=1 18: 562949953421313: ompt_event_task_end: task_id=562949953421315 19: 562949953421313: ompt_event_barrier_begin: parallel_id=281474976710661, task_id=562949953421314, codeptr_ra=(nil) 20: 562949953421313: task level 0: parallel_id=281474976710661, task_id=562949953421314, exit_frame=(nil), reenter_frame=(nil), task_type=ompt_task_implicit|ompt_task_undeferred=134217730, thread_num=1 21: 562949953421313: ompt_event_wait_barrier_begin: parallel_id=281474976710661, task_id=562949953421314, codeptr_ra=(nil) 22: 281474976710658: ompt_event_implicit_task_begin: parallel_id=281474976710661, task_id=281474976710662, team_size=2, thread_ num=0 check:62'0 X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ error: no match found check:62'1 with "WORKER_ID" equal to "562949953421313" 23: 281474976710658: ompt_event_barrier_begin: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0xaaaabe68dd24 check:62'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 24: 281474976710658: task level 0: parallel_id=281474976710661, task_id=281474976710662, exit_frame=(nil), reenter_frame=(nil), task_type=ompt_task_implicit|ompt_task_undeferred=134217730, thread_num=0 check:62'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ check:62'2 ? possible intended match 25: 281474976710658: ompt_event_wait_barrier_begin: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0xaaaabe68 dd24 check:62'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ 26: 281474976710658: ompt_event_wait_barrier_end: parallel_id=0, task_id=281474976710662, codeptr_ra=0xaaaabe68dd24 check:62'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 27: 281474976710658: ompt_event_barrier_end: parallel_id=0, task_id=281474976710662, codeptr_ra=0xaaaabe68dd24 check:62'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 28: 281474976710658: ompt_event_implicit_task_end: parallel_id=0, task_id=281474976710662, team_size=2, thread_num=0 check:62'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 29: 281474976710658: ompt_event_parallel_end: parallel_id=281474976710661, task_id=281474976710659, invoker=2, codeptr_ra=0xaaa abe68dd24 check:62'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ . . . >>>>>> 

OpenMP does not guarantee the order in which the master(thread id=0) and worker(thread id =1) threads execute tasks.
So this test case uses CHECK-DAG.
The Successful output is below, (I remove some unrelated output, assume MASTER_ID=281474976710658, and WORKER_ID=562949953421313)

  1. MASTER thread ompt_event_implicit_task_begin before two 'ancestor_level=' check
0: NULL_POINTER=(nil) 281474976710658: ompt_event_thread_begin: thread_type=ompt_thread_initial=1, thread_id=281474976710658 281474976710658: ompt_event_initial_task_begin: parallel_id=281474976710660, task_id=281474976710659, actual_parallelism=1, index=1, flags=1 281474976710658: ompt_event_parallel_begin: parent_task_id=281474976710659, parent_task_frame.exit=(nil), parent_task_frame.reenter=0xffffce4d3310, parallel_id=281474976710661, requested_team_size=2, codeptr_ra=0xaaaabe68dd24, invoker=2 281474976710658: ompt_event_implicit_task_begin: parallel_id=281474976710661, task_id=281474976710662, team_size=2, thread_num=0 562949953421313: ompt_event_implicit_task_begin: parallel_id=281474976710661, task_id=562949953421314, team_size=2, thread_num=1 562949953421313: ancestor_level=0 id=1 task_type=ompt_task_explicit|ompt_task_undeferred=134217732 parallel_id=281474976710661 task_id=562949953421315 thread_num=1 562949953421313: ancestor_level=1 id=0 task_type=ompt_task_implicit|ompt_task_undeferred=134217730 parallel_id=281474976710661 task_id=562949953421314 thread_num=1 281474976710658: ompt_event_thread_end: thread_id=281474976710658 562949953421313: ompt_event_thread_end: thread_id=562949953421313 

but if MASTER thread ompt_event_implicit_task_begin after two 'ancestor_level=' check, the 'ancestor_level=' check will failed!

0: NULL_POINTER=(nil) 281474976710658: ompt_event_thread_begin: thread_type=ompt_thread_initial=1, thread_id=281474976710658 281474976710658: ompt_event_initial_task_begin: parallel_id=281474976710660, task_id=281474976710659, actual_parallelism=1, index=1, flags=1 281474976710658: ompt_event_parallel_begin: parent_task_id=281474976710659, parent_task_frame.exit=(nil), parent_task_frame.reenter=0xffffce4d3310, parallel_id=281474976710661, requested_team_size=2, codeptr_ra=0xaaaabe68dd24, invoker=2 562949953421313: ompt_event_implicit_task_begin: parallel_id=281474976710661, task_id=562949953421314, team_size=2, thread_num=1 562949953421313: ancestor_level=0 id=1 task_type=ompt_task_explicit|ompt_task_undeferred=134217732 parallel_id=281474976710661 task_id=562949953421315 thread_num=1 562949953421313: ancestor_level=1 id=0 task_type=ompt_task_implicit|ompt_task_undeferred=134217730 parallel_id=281474976710661 task_id=562949953421314 thread_num=1 281474976710658: ompt_event_implicit_task_begin: parallel_id=281474976710661, task_id=281474976710662, team_size=2, thread_num=0 281474976710658: ompt_event_thread_end: thread_id=281474976710658 562949953421313: ompt_event_thread_end: thread_id=562949953421313 0: ompt_event_runtime_shutdown 

Does openmp guarantee the master thread do task before woker thread ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions