1 | // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %s |
2 | // REQUIRES: ompt |
3 | // Current GOMP interface implements taskyield as stub |
4 | // XFAIL: gcc |
5 | |
6 | #include "callback.h" |
7 | #include <omp.h> |
8 | #include <unistd.h> |
9 | |
10 | int main() |
11 | { |
12 | int condition=0, x=0; |
13 | #pragma omp parallel num_threads(2) |
14 | { |
15 | #pragma omp master |
16 | { |
17 | #pragma omp task shared(condition) |
18 | { |
19 | OMPT_SIGNAL(condition); |
20 | OMPT_WAIT(condition,2); |
21 | } |
22 | OMPT_WAIT(condition,1); |
23 | #pragma omp task shared(x) |
24 | { |
25 | x++; |
26 | } |
27 | printf("%" PRIu64 ": before yield\n" , ompt_get_thread_data()->value); |
28 | #pragma omp taskyield |
29 | printf("%" PRIu64 ": after yield\n" , ompt_get_thread_data()->value); |
30 | OMPT_SIGNAL(condition); |
31 | } |
32 | } |
33 | |
34 | |
35 | // Check if libomp supports the callbacks for this test. |
36 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_create' |
37 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_schedule' |
38 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_implicit_task' |
39 | |
40 | |
41 | // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]] |
42 | |
43 | // make sure initial data pointers are null |
44 | // CHECK-NOT: 0: new_task_data initially not null |
45 | |
46 | // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_implicit_task_begin: parallel_id={{[0-9]+}}, task_id=[[IMPLICIT_TASK_ID:[0-9]+]], team_size={{[0-9]+}}, thread_num={{[0-9]+}} |
47 | |
48 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id={{[0-9]+}}, parent_task_frame.exit={{0x[0-f]+}}, parent_task_frame.reenter={{0x[0-f]+}}, new_task_id=[[WORKER_TASK:[0-9]+]], codeptr_ra={{0x[0-f]+}}, task_type=ompt_task_explicit=4, has_dependences=no |
49 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id={{[0-9]+}}, parent_task_frame.exit={{0x[0-f]+}}, parent_task_frame.reenter={{0x[0-f]+}}, new_task_id=[[MAIN_TASK:[0-9]+]], codeptr_ra={{0x[0-f]+}}, task_type=ompt_task_explicit=4, has_dependences=no |
50 | |
51 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[IMPLICIT_TASK_ID]], second_task_id=[[MAIN_TASK]], prior_task_status=ompt_task_yield=2 |
52 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[MAIN_TASK]], second_task_id=[[IMPLICIT_TASK_ID]], prior_task_status=ompt_task_complete=1 |
53 | |
54 | // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_task_schedule: first_task_id={{[0-9]+}}, second_task_id=[[WORKER_TASK]], prior_task_status=ompt_task_switch=7 |
55 | // CHECK: {{^}}[[THREAD_ID]]: ompt_event_task_schedule: first_task_id=[[WORKER_TASK]], second_task_id={{[0-9]+}}, prior_task_status=ompt_task_complete=1 |
56 | |
57 | |
58 | |
59 | |
60 | |
61 | return 0; |
62 | } |
63 | |