66 lines · c
1// clang-format off2// RUN: %libomp-compile && env OMP_CANCELLATION=true %libomp-run | %sort-threads | FileCheck %s3// REQUIRES: ompt4// Current GOMP interface implementation does not support cancellation; icc 16 does not distinguish between sections and loops5// XFAIL: icc-166// clang-format on7 8#include "callback.h"9#include <unistd.h>10 11int main() {12 int condition = 0;13#pragma omp parallel num_threads(2)14 {15 int x = 0;16 int i;17#pragma omp for18 for (i = 0; i < 2; i++) {19 if (i == 0) {20 x++;21 OMPT_SIGNAL(condition);22#pragma omp cancel for23 } else {24 x++;25 OMPT_WAIT(condition, 1);26 delay(10000);27#pragma omp cancellation point for28 }29 }30 }31#pragma omp parallel num_threads(2)32 {33#pragma omp sections34 {35#pragma omp section36 {37 OMPT_SIGNAL(condition);38#pragma omp cancel sections39 }40#pragma omp section41 {42 OMPT_WAIT(condition, 2);43 delay(10000);44#pragma omp cancellation point sections45 }46 }47 }48 49 // clang-format off50 // Check if libomp supports the callbacks for this test.51 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_implicit_task'52 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_cancel'53 54 // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]55 // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_initial_task_begin: parallel_id={{[0-f]+}}, task_id={{[0-f]+}}, actual_parallelism=1, index=1, flags=156 57 // cancel for and sections58 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_id=[[TASK_ID:[0-f]+]], flags=ompt_cancel_loop|ompt_cancel_activated=20, codeptr_ra={{(0x)?[0-f]*}}59 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_id=[[TASK_ID:[0-f]+]], flags=ompt_cancel_sections|ompt_cancel_{{activated=18|detected=34}}, codeptr_ra={{(0x)?[0-f]*}}60 // CHECK: {{^}}[[OTHER_THREAD_ID:[0-9]+]]: ompt_event_cancel: task_id=[[TASK_ID:[0-f]+]], flags=ompt_cancel_loop|ompt_cancel_detected=36, codeptr_ra={{(0x)?[0-f]*}}61 // CHECK: {{^}}[[OTHER_THREAD_ID:[0-9]+]]: ompt_event_cancel: task_id=[[TASK_ID:[0-f]+]], flags=ompt_cancel_sections|ompt_cancel_{{activated=18|detected=34}}, codeptr_ra={{(0x)?[0-f]*}}62 // clang-format on63 64 return 0;65}66