LLVM OpenMP 22.0.0git
taskyield.c
Go to the documentation of this file.
1// clang-format off
2// RUN: %libomp-compile-and-run | %sort-threads | FileCheck %s
3// REQUIRES: ompt
4// Current GOMP interface implements taskyield as stub
5// XFAIL: gcc
6// clang-format on
7
8#include "callback.h"
9#include <omp.h>
10#include <unistd.h>
11
12int main() {
13 int condition = 0, x = 0;
14#pragma omp parallel num_threads(2)
15 {
16#pragma omp master
17 {
18#pragma omp task shared(condition)
19 {
22 }
24#pragma omp task shared(x)
25 {
26 x++;
27 }
28 printf("%" PRIu64 ": before yield\n", ompt_get_thread_data()->value);
29#pragma omp taskyield
30 printf("%" PRIu64 ": after yield\n", ompt_get_thread_data()->value);
32 }
33 }
34
35 // clang-format off
36 // Check if libomp supports the callbacks for this test.
37 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_create'
38 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_schedule'
39 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_implicit_task'
40
41
42 // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
43
44 // make sure initial data pointers are null
45 // CHECK-NOT: 0: new_task_data initially not null
46
47 // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_implicit_task_begin: parallel_id={{[0-f]+}}, task_id=[[IMPLICIT_TASK_ID:[0-f]+]], team_size={{[0-9]+}}, thread_num={{[0-9]+}}
48
49 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id={{[0-f]+}}, 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
50 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id={{[0-f]+}}, 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
51
52 // 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
53 // 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
54
55 // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_task_schedule: first_task_id={{[0-f]+}}, second_task_id=[[WORKER_TASK]], prior_task_status=ompt_task_switch=7
56 // CHECK: {{^}}[[THREAD_ID]]: ompt_event_task_schedule: first_task_id=[[WORKER_TASK]], second_task_id={{[0-f]+}}, prior_task_status=ompt_task_complete=1
57 // clang-format on
58
59 return 0;
60}
static ompt_get_thread_data_t ompt_get_thread_data
Definition callback.h:158
int condition
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value
#define OMPT_WAIT(s, v)
Definition ompt-signal.h:20
#define OMPT_SIGNAL(s)
Definition ompt-signal.h:13
int main()
Definition taskyield.c:12