xref: /llvm-project/openmp/runtime/test/ompt/worksharing/single.c (revision a707d0883b5ab9de6a0a864df614ef14909a4de1)
182e94a59SJoachim Protze // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %s
282e94a59SJoachim Protze // REQUIRES: ompt
382e94a59SJoachim Protze // GCC generates code that does not call the runtime for the single construct
482e94a59SJoachim Protze // XFAIL: gcc
582e94a59SJoachim Protze 
682e94a59SJoachim Protze #include "callback.h"
782e94a59SJoachim Protze #include <omp.h>
882e94a59SJoachim Protze 
main()982e94a59SJoachim Protze int main()
1082e94a59SJoachim Protze {
1182e94a59SJoachim Protze   int x = 0;
1282e94a59SJoachim Protze   #pragma omp parallel num_threads(2)
1382e94a59SJoachim Protze   {
1482e94a59SJoachim Protze     #pragma omp single
1582e94a59SJoachim Protze     {
160924094eSJonas Hahnfeld       printf("%" PRIu64 ": in single\n", ompt_get_thread_data()->value);
1782e94a59SJoachim Protze       x++;
1882e94a59SJoachim Protze     }
1982e94a59SJoachim Protze   }
2082e94a59SJoachim Protze 
2182e94a59SJoachim Protze   printf("x=%d\n", x);
2282e94a59SJoachim Protze 
23*a707d088SJoachim   // clang-format off
2482e94a59SJoachim Protze   // Check if libomp supports the callbacks for this test.
2582e94a59SJoachim Protze   // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_work'
2682e94a59SJoachim Protze 
2782e94a59SJoachim Protze   // CHECK: 0: NULL_POINTER=[[NULL:.*$]]
2882e94a59SJoachim Protze 
29*a707d088SJoachim   // CHECK-DAG: {{^}}[[THREAD_ID_1:[0-9]+]]: ompt_event_single_in_block_begin: parallel_id=[[PARALLEL_ID:[0-9]+]], task_id=[[TASK_ID:[0-9]+]], codeptr_ra={{0x[0-f]+}}, count=1
300924094eSJonas Hahnfeld   // CHECK-DAG: {{^}}[[THREAD_ID_1]]: in single
310924094eSJonas Hahnfeld   // CHECK-DAG: {{^}}[[THREAD_ID_1]]: ompt_event_single_in_block_end: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID]], codeptr_ra={{0x[0-f]+}}, count=1
3282e94a59SJoachim Protze 
330924094eSJonas Hahnfeld   // CHECK-DAG: {{^}}[[THREAD_ID_2:[0-9]+]]: ompt_event_single_others_begin: parallel_id=[[PARALLEL_ID:[0-9]+]], task_id=[[TASK_ID:[0-9]+]], codeptr_ra={{0x[0-f]+}}, count=1
340924094eSJonas Hahnfeld   // CHECK-DAG: {{^}}[[THREAD_ID_2]]: ompt_event_single_others_end: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID]], codeptr_ra={{0x[0-f]+}}, count=1
35*a707d088SJoachim   // clang-format on
3682e94a59SJoachim Protze 
3782e94a59SJoachim Protze   return 0;
3882e94a59SJoachim Protze }
39