61 lines · c
1// clang-format off2// RUN: %libomp-compile-and-run | %sort-threads | FileCheck %s3// REQUIRES: ompt4// Current GOMP interface implements taskyield as stub5// XFAIL: gcc6// clang-format on7 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 master17 {18#pragma omp task shared(condition)19 {20 OMPT_SIGNAL(condition);21 OMPT_WAIT(condition, 2);22 }23 OMPT_WAIT(condition, 1);24#pragma omp task shared(x)25 {26 x++;27 }28 printf("%" PRIu64 ": before yield\n", ompt_get_thread_data()->value);29#pragma omp taskyield30 printf("%" PRIu64 ": after yield\n", ompt_get_thread_data()->value);31 OMPT_SIGNAL(condition);32 }33 }34 35 // clang-format off36 // 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 null45 // CHECK-NOT: 0: new_task_data initially not null46 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=no50 // 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=no51 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=253 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[MAIN_TASK]], second_task_id=[[IMPLICIT_TASK_ID]], prior_task_status=ompt_task_complete=154 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=756 // CHECK: {{^}}[[THREAD_ID]]: ompt_event_task_schedule: first_task_id=[[WORKER_TASK]], second_task_id={{[0-f]+}}, prior_task_status=ompt_task_complete=157 // clang-format on58 59 return 0;60}61