xref: /llvm-project/openmp/libompd/test/openmp_examples/example_1.c (revision 1099498e3f35b2ad4b021ba3888b590259124e74)
1 // RUN: %gdb-compile-and-run 2>&1 | tee %t.out | FileCheck %s
2 
3 #include "../ompt_plugin.h"
4 #include <omp.h>
5 #include <pthread.h>
6 #include <stdio.h>
7 #include <unistd.h>
8 
createPthreads()9 void createPthreads() {
10   int numThreads = 2;
11   pthread_t threads[numThreads];
12   int i;
13   for (i = 0; i < numThreads; ++i)
14     pthread_create(&threads[i], NULL, ompd_tool_break, NULL);
15 
16   for (i = 0; i < numThreads; ++i)
17     pthread_join(threads[i], NULL);
18 }
19 
main()20 int main() {
21   omp_set_num_threads(4);
22   printf("Application: Process %d started.\n", getpid());
23   createPthreads(); // thread_data is set to 0x0 if called
24 
25 // Parallel region 1
26 #pragma omp parallel
27   { ompd_tool_test(0); }
28 
29   return 0;
30 }
31 
32 // CHECK-NOT: OMPT-OMPD mismatch
33 // CHECK-NOT: Python Exception
34 // CHECK-NOT: The program is not being run.
35