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 <stdio.h>
6#include <stdlib.h>
7
8int fib(int n) {
9 int i, j;
10 if (n < 2) {
11 ompd_tool_test(n: 0);
12 return n;
13 } else {
14#pragma omp task shared(i)
15 i = fib(n: n - 1);
16#pragma omp task shared(j)
17 j = fib(n: n - 2);
18#pragma omp taskwait
19 return i + j;
20 }
21}
22
23int main(int argc, char **argv) {
24 int n = 5;
25 if (argc > 1)
26 n = atoi(nptr: argv[1]);
27#pragma omp parallel
28 {
29#pragma omp single
30 printf(format: "fib(%i) = %i\n", n, fib(n));
31 }
32 return 0;
33}
34
35// CHECK-NOT: OMPT-OMPD mismatch
36// CHECK-NOT: Python Exception
37// CHECK-NOT: The program is not being run.
38

source code of openmp/libompd/test/openmp_examples/fibonacci.c