94 lines · c
1// clang-format off2// RUN: %libomp-compile && env OMP_CANCELLATION=true %libomp-run | %sort-threads | FileCheck %s3// REQUIRES: ompt4// UNSUPPORTED: clang-3, clang-4.0.05// Current GOMP interface implementation does not support cancellation; icc 16 has a bug6// XFAIL: gcc, icc-167// clang-format on8 9#include "callback.h"10#include <unistd.h>11#include <stdio.h>12 13int main() {14 int condition = 0;15#pragma omp parallel num_threads(2)16 {}17 18 print_frame(0);19#pragma omp parallel num_threads(2)20 {21#pragma omp master22 {23#pragma omp taskgroup24 {25#pragma omp task shared(condition)26 {27 printf("start execute task 1\n");28 OMPT_SIGNAL(condition);29 OMPT_WAIT(condition, 2);30#pragma omp cancellation point taskgroup31 printf("end execute task 1\n");32 }33#pragma omp task shared(condition)34 {35 printf("start execute task 2\n");36 OMPT_SIGNAL(condition);37 OMPT_WAIT(condition, 2);38#pragma omp cancellation point taskgroup39 printf("end execute task 2\n");40 }41#pragma omp task shared(condition)42 {43 printf("start execute task 3\n");44 OMPT_SIGNAL(condition);45 OMPT_WAIT(condition, 2);46#pragma omp cancellation point taskgroup47 printf("end execute task 3\n");48 }49#pragma omp task if (0) shared(condition)50 {51 printf("start execute task 4\n");52 OMPT_WAIT(condition, 1);53#pragma omp cancel taskgroup54 printf("end execute task 4\n");55 }56 OMPT_SIGNAL(condition);57 }58 }59#pragma omp barrier60 }61 62 // clang-format off63 // Check if libomp supports the callbacks for this test.64 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_masked'65 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_create'66 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_schedule' 67 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_cancel' 68 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_thread_begin'69 70 // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]71 // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_masked_begin:72 // CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-f]+]],73 // CHECK-SAME: task_id=[[PARENT_TASK_ID:[0-f]+]],74 // CHECK-SAME: codeptr_ra={{(0x)?[0-f]*}}75 76 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{(0x)?[0-f]*}}, parent_task_frame.reenter={{(0x)?[0-f]*}}, new_task_id=[[FIRST_TASK_ID:[0-f]+]], codeptr_ra={{(0x)?[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no77 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{(0x)?[0-f]*}}, parent_task_frame.reenter={{(0x)?[0-f]*}}, new_task_id=[[SECOND_TASK_ID:[0-f]+]], codeptr_ra={{(0x)?[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no78 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{(0x)?[0-f]*}}, parent_task_frame.reenter={{(0x)?[0-f]*}}, new_task_id=[[THIRD_TASK_ID:[0-f]+]], codeptr_ra={{(0x)?[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no79 80 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{(0x)?[0-f]*}}, parent_task_frame.reenter={{(0x)?[0-f]*}}, new_task_id=[[CANCEL_TASK_ID:[0-f]+]], codeptr_ra={{(0x)?[0-f]*}}, task_type=ompt_task_explicit|ompt_task_undeferred=134217732, has_dependences=no81 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[PARENT_TASK_ID]], second_task_id=[[CANCEL_TASK_ID]], prior_task_status=ompt_task_switch=782 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_id=[[CANCEL_TASK_ID]], flags=ompt_cancel_taskgroup|ompt_cancel_activated=24, codeptr_ra={{(0x)?[0-f]*}}83 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[CANCEL_TASK_ID]], second_task_id=[[PARENT_TASK_ID]], prior_task_status=ompt_task_cancel=384 85 // CHECK-DAG: {{^}}{{[0-9]+}}: ompt_event_cancel: task_id={{[0-f]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_discarded_task=72, codeptr_ra=[[NULL]]86 // CHECK-DAG: {{^}}{{[0-9]+}}: ompt_event_cancel: task_id={{[0-f]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_discarded_task=72, codeptr_ra=[[NULL]]87 88 // CHECK-DAG: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_thread_begin: thread_type=ompt_thread_worker=2, thread_id=[[THREAD_ID]]89 // CHECK-DAG: {{^}}[[THREAD_ID]]: ompt_event_cancel: task_id={{[0-f]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_detected=40, codeptr_ra={{(0x)?[0-f]*}}90 // clang-format on91 92 return 0;93}94