Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
971 changes: 459 additions & 512 deletions openmp/runtime/test/ompt/callback.h

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions openmp/runtime/test/ompt/cancel/cancel_parallel.c
Original file line number Diff line number Diff line change
@@ -1,40 +1,46 @@
// clang-format off
// RUN: %libomp-compile && env OMP_CANCELLATION=true %libomp-run | %sort-threads | FileCheck %s
// REQUIRES: ompt
// Current GOMP interface implementation does not support cancellation
// XFAIL: gcc
// clang-format on

#include "callback.h"
#include "omp.h"

int main() {
#pragma omp parallel num_threads(2)
#pragma omp parallel num_threads(2)
{
if (omp_get_thread_num() == 0) {
print_fuzzy_address_blocks(get_ompt_label_address(1));
#pragma omp cancel parallel
#pragma omp cancel parallel
define_ompt_label(1);
// We cannot print at this location because the parallel region is cancelled!
// We cannot print at this location because the parallel region is
// cancelled!
} else {
delay(100);
print_fuzzy_address_blocks(get_ompt_label_address(2));
#pragma omp cancellation point parallel
#pragma omp cancellation point parallel
define_ompt_label(2);
// We cannot print at this location because the parallel region is cancelled!
// We cannot print at this location because the parallel region is
// cancelled!
}
}

// clang-format off
// Check if libomp supports the callbacks for this test.
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_implicit_task'
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_cancel'

// CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_initial_task_begin: parallel_id={{[0-9]+}}, task_id={{[0-9]+}}, actual_parallelism=1, index=1, flags=1
// CHECK-DAG: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_data=[[TASK_ID:[0-9]+]], flags=ompt_cancel_parallel|ompt_cancel_activated=17, codeptr_ra=[[RETURN_ADDRESS:(0x)?[0-f]+]]{{[0-f][0-f]}}
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_initial_task_begin: parallel_id={{[0-f]+}}, task_id={{[0-f]+}}, actual_parallelism=1, index=1, flags=1
// CHECK-DAG: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_id=[[TASK_ID:[0-f]+]], flags=ompt_cancel_parallel|ompt_cancel_activated=17, codeptr_ra=[[RETURN_ADDRESS:(0x)?[0-f]+]]{{[0-f][0-f]}}
// CHECK-DAG: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]]

// CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_implicit_task_begin
// CHECK-DAG: {{^}}[[THREAD_ID]]: ompt_event_cancel: task_data=[[TASK_ID:[0-9]+]], flags=ompt_cancel_parallel|ompt_cancel_detected=33, codeptr_ra=[[OTHER_RETURN_ADDRESS:(0x)?[0-f]+]]{{[0-f][0-f]}}
// CHECK-DAG: {{^}}[[THREAD_ID]]: ompt_event_cancel: task_id=[[TASK_ID:[0-f]+]], flags=ompt_cancel_parallel|ompt_cancel_detected=33, codeptr_ra=[[OTHER_RETURN_ADDRESS:(0x)?[0-f]+]]{{[0-f][0-f]}}
// CHECK-DAG: {{^}}[[THREAD_ID]]: fuzzy_address={{.*}}[[OTHER_RETURN_ADDRESS]]
// clang-format on

return 0;
}
65 changes: 34 additions & 31 deletions openmp/runtime/test/ompt/cancel/cancel_taskgroup.c
Original file line number Diff line number Diff line change
@@ -1,63 +1,65 @@
// clang-format off
// RUN: %libomp-compile && env OMP_CANCELLATION=true %libomp-run | %sort-threads | FileCheck %s
// REQUIRES: ompt
// UNSUPPORTED: clang-3, clang-4.0.0
// Current GOMP interface implementation does not support cancellation; icc 16 has a bug
// XFAIL: gcc, icc-16
// clang-format on

#include "callback.h"
#include <unistd.h>
#include <unistd.h>
#include <stdio.h>

int main()
{
int condition=0;
#pragma omp parallel num_threads(2)
int main() {
int condition = 0;
#pragma omp parallel num_threads(2)
{}

print_frame(0);
#pragma omp parallel num_threads(2)
#pragma omp parallel num_threads(2)
{
#pragma omp master
#pragma omp master
{
#pragma omp taskgroup
#pragma omp taskgroup
{
#pragma omp task shared(condition)
#pragma omp task shared(condition)
{
printf("start execute task 1\n");
OMPT_SIGNAL(condition);
OMPT_WAIT(condition,2);
#pragma omp cancellation point taskgroup
OMPT_WAIT(condition, 2);
#pragma omp cancellation point taskgroup
printf("end execute task 1\n");
}
#pragma omp task shared(condition)
#pragma omp task shared(condition)
{
printf("start execute task 2\n");
OMPT_SIGNAL(condition);
OMPT_WAIT(condition,2);
#pragma omp cancellation point taskgroup
OMPT_WAIT(condition, 2);
#pragma omp cancellation point taskgroup
printf("end execute task 2\n");
}
#pragma omp task shared(condition)
#pragma omp task shared(condition)
{
printf("start execute task 3\n");
OMPT_SIGNAL(condition);
OMPT_WAIT(condition,2);
#pragma omp cancellation point taskgroup
OMPT_WAIT(condition, 2);
#pragma omp cancellation point taskgroup
printf("end execute task 3\n");
}
#pragma omp task if(0) shared(condition)
#pragma omp task if (0) shared(condition)
{
printf("start execute task 4\n");
OMPT_WAIT(condition,1);
#pragma omp cancel taskgroup
OMPT_WAIT(condition, 1);
#pragma omp cancel taskgroup
printf("end execute task 4\n");
}
OMPT_SIGNAL(condition);
}
}
#pragma omp barrier
#pragma omp barrier
}

// clang-format off
// Check if libomp supports the callbacks for this test.
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_masked'
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_create'
Expand All @@ -67,24 +69,25 @@ int main()

// CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_masked_begin:
// CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]],
// CHECK-SAME: task_id=[[PARENT_TASK_ID:[0-9]+]],
// CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-f]+]],
// CHECK-SAME: task_id=[[PARENT_TASK_ID:[0-f]+]],
// CHECK-SAME: codeptr_ra={{(0x)?[0-f]*}}

// 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-9]+]], codeptr_ra={{(0x)?[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no
// 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-9]+]], codeptr_ra={{(0x)?[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no
// 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-9]+]], codeptr_ra={{(0x)?[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no
// 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=no
// 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=no
// 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=no

// 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-9]+]], codeptr_ra={{(0x)?[0-f]*}}, task_type=ompt_task_explicit|ompt_task_undeferred=134217732, has_dependences=no
// 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=no
// 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=7
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_data=[[CANCEL_TASK_ID]], flags=ompt_cancel_taskgroup|ompt_cancel_activated=24, codeptr_ra={{(0x)?[0-f]*}}
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_id=[[CANCEL_TASK_ID]], flags=ompt_cancel_taskgroup|ompt_cancel_activated=24, codeptr_ra={{(0x)?[0-f]*}}
// 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=3

// CHECK-DAG: {{^}}{{[0-9]+}}: ompt_event_cancel: task_data={{[0-9]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_discarded_task=72, codeptr_ra=[[NULL]]
// CHECK-DAG: {{^}}{{[0-9]+}}: ompt_event_cancel: task_data={{[0-9]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_discarded_task=72, codeptr_ra=[[NULL]]
// CHECK-DAG: {{^}}{{[0-9]+}}: ompt_event_cancel: task_id={{[0-f]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_discarded_task=72, codeptr_ra=[[NULL]]
// CHECK-DAG: {{^}}{{[0-9]+}}: ompt_event_cancel: task_id={{[0-f]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_discarded_task=72, codeptr_ra=[[NULL]]

// CHECK-DAG: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_thread_begin: thread_type=ompt_thread_worker=2, thread_id=[[THREAD_ID]]
// CHECK-DAG: {{^}}[[THREAD_ID]]: ompt_event_cancel: task_data={{[0-9]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_detected=40, codeptr_ra={{(0x)?[0-f]*}}
// CHECK-DAG: {{^}}[[THREAD_ID]]: ompt_event_cancel: task_id={{[0-f]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_detected=40, codeptr_ra={{(0x)?[0-f]*}}
// clang-format on

return 0;
}
54 changes: 26 additions & 28 deletions openmp/runtime/test/ompt/cancel/cancel_worksharing.c
Original file line number Diff line number Diff line change
@@ -1,67 +1,65 @@
// clang-format off
// RUN: %libomp-compile && env OMP_CANCELLATION=true %libomp-run | %sort-threads | FileCheck %s
// REQUIRES: ompt
// Current GOMP interface implementation does not support cancellation; icc 16 does not distinguish between sections and loops
// XFAIL: icc-16
// clang-format on

#include "callback.h"
#include <unistd.h>

int main()
{
int condition=0;
#pragma omp parallel num_threads(2)
int main() {
int condition = 0;
#pragma omp parallel num_threads(2)
{
int x = 0;
int i;
#pragma omp for
for(i = 0; i < 2; i++)
{
if(i == 0)
{
#pragma omp for
for (i = 0; i < 2; i++) {
if (i == 0) {
x++;
OMPT_SIGNAL(condition);
#pragma omp cancel for
}
else
{
#pragma omp cancel for
} else {
x++;
OMPT_WAIT(condition,1);
OMPT_WAIT(condition, 1);
delay(10000);
#pragma omp cancellation point for
#pragma omp cancellation point for
}
}
}
#pragma omp parallel num_threads(2)
#pragma omp parallel num_threads(2)
{
#pragma omp sections
#pragma omp sections
{
#pragma omp section
#pragma omp section
{
OMPT_SIGNAL(condition);
#pragma omp cancel sections
#pragma omp cancel sections
}
#pragma omp section
#pragma omp section
{
OMPT_WAIT(condition,2);
OMPT_WAIT(condition, 2);
delay(10000);
#pragma omp cancellation point sections
#pragma omp cancellation point sections
}
}
}


// clang-format off
// Check if libomp supports the callbacks for this test.
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_implicit_task'
// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_cancel'

// CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_initial_task_begin: parallel_id={{[0-9]+}}, task_id={{[0-9]+}}, actual_parallelism=1, index=1, flags=1
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_initial_task_begin: parallel_id={{[0-f]+}}, task_id={{[0-f]+}}, actual_parallelism=1, index=1, flags=1

// cancel for and sections
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_data=[[TASK_ID:[0-9]+]], flags=ompt_cancel_loop|ompt_cancel_activated=20, codeptr_ra={{(0x)?[0-f]*}}
// CHECK: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_data=[[TASK_ID:[0-9]+]], flags=ompt_cancel_sections|ompt_cancel_{{activated=18|detected=34}}, codeptr_ra={{(0x)?[0-f]*}}
// CHECK: {{^}}[[OTHER_THREAD_ID:[0-9]+]]: ompt_event_cancel: task_data=[[TASK_ID:[0-9]+]], flags=ompt_cancel_loop|ompt_cancel_detected=36, codeptr_ra={{(0x)?[0-f]*}}
// CHECK: {{^}}[[OTHER_THREAD_ID:[0-9]+]]: ompt_event_cancel: task_data=[[TASK_ID:[0-9]+]], flags=ompt_cancel_sections|ompt_cancel_{{activated=18|detected=34}}, codeptr_ra={{(0x)?[0-f]*}}
// 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]*}}
// 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]*}}
// 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]*}}
// 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]*}}
// clang-format on

return 0;
}
27 changes: 15 additions & 12 deletions openmp/runtime/test/ompt/loadtool/tool_available.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
// The OpenMP standard defines 3 ways of providing ompt_start_tool:

// RUN: mkdir -p %t.tool_dir
Expand Down Expand Up @@ -74,6 +75,7 @@


// REQUIRES: ompt
// clang-format on

/*
* This file contains code for an OMPT shared library tool to be
Expand All @@ -82,6 +84,7 @@
* -DCODE enables the code for the executable during compilation
*/

// clang-format off
// Check if libomp supports the callbacks for this test.
// CHECK-NOT: {{^}}0: Could not register callback

Expand All @@ -99,21 +102,23 @@
// TOOLLIB-SAME: [[PARENTPATH]]/tool.so... Success.
// TOOLLIB-NEXT: Tool was started and is using the OMPT interface.
// TOOLLIB-NEXT: ----- END LOGGING OF TOOL REGISTRATION -----
// clang-format on

#ifdef CODE
#include "omp.h"

int main()
{
#pragma omp parallel num_threads(2)
int main() {
#pragma omp parallel num_threads(2)
{
}

// clang-format off
// CHECK-NOT: ----- START LOGGING OF TOOL REGISTRATION -----
// CHECK-NOT: ----- END LOGGING OF TOOL REGISTRATION -----

// CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
// CHECK: {{^}}0: ompt_event_runtime_shutdown
// clang-format on

return 0;
}
Expand All @@ -127,20 +132,18 @@ int main()

int ompt_initialize(ompt_function_lookup_t lookup, int initial_device_num,
ompt_data_t *tool_data) {
printf("0: NULL_POINTER=%p\n", (void*)NULL);
return 1; //success
printf("0: NULL_POINTER=%p\n", (void *)NULL);
return 1; // success
}

void ompt_finalize(ompt_data_t* tool_data)
{
void ompt_finalize(ompt_data_t *tool_data) {
printf("0: ompt_event_runtime_shutdown\n");
}

ompt_start_tool_result_t* ompt_start_tool(
unsigned int omp_version,
const char *runtime_version)
{
static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize,&ompt_finalize, 0};
ompt_start_tool_result_t *ompt_start_tool(unsigned int omp_version,
const char *runtime_version) {
static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize,
&ompt_finalize, 0};
return &ompt_start_tool_result;
}
#endif /* TOOL */
Loading
Loading