xref: /llvm-project/openmp/libompd/test/openmp_examples/example_5.c (revision 1099498e3f35b2ad4b021ba3888b590259124e74)
1 // RUN: %gdb-compile 2>&1 | tee %t.compile
2 // RUN: env OMP_SCHEDULE=guided %gdb-run 2>&1 | tee %t.out | FileCheck %s
3 
4 #include "../ompt_plugin.h"
5 #include <omp.h>
6 #include <pthread.h>
7 #include <stdio.h>
8 #include <unistd.h>
9 
main()10 int main() {
11   printf("Application: Process %d started.\n", getpid());
12 
13   omp_set_num_threads(3);
14   omp_set_max_active_levels(10);
15 
16 #pragma omp parallel // parallel region begins
17   {
18     printf("Outer region - thread_ID: %d\n", omp_get_thread_num());
19 
20 #pragma omp parallel num_threads(1) // nested parallel region 1
21     {
22       printf("Inner region - thread_ID: %d\n", omp_get_thread_num());
23 
24 #pragma omp parallel num_threads(2) // nested parallel region 2
25       {
26         int i;
27 #pragma omp for
28         for (i = 0; i < 15; i++)
29           ompd_tool_test(0);
30       }
31     }
32   }
33 
34   return 0;
35 }
36 
37 // CHECK-NOT: OMPT-OMPD mismatch
38 // CHECK-NOT: Python Exception
39 // CHECK-NOT: The program is not being run.
40