idb info taskwait (gdb mode only)

Display information for any existing taskwait.

Syntax

idb info taskwait [ taskwait_id, ... ]

Parameters

taskwait_id

A taskwait ID.

Description

An OpenMP* taskwait is a task-specific barrier. It defines a point in an application that all tasks generated by the current task or thread have to reach before thread execution continues.

This command displays the following information for any existing taskwait, which you specify with taskwait_id, in an OpenMP* application.

If you do not specify taskwait_id, this command shows all existing tasks in the OpenMP* application.

Note iconNote

This command is fully supported for OpenMP* versions 3.0 and higher. For older versions, this command has restricted functionality.

Example

The program being debugged in this example calculates the 5th Fibonacci number by spawning tasks to calculate the previous two numbers recursively. Consider the following source code:

1 #include <stdio.h>
2 #include <omp.h>
3 
4 static int fib(int n) {
5   if (n == 0) {
6     return 0;
7   } else if (n == 1) {
8     return 1;
9   } else {
10     int i = 0;
11     int j = 0;
12 
13 #pragma omp task shared(i)
14     i = fib(n-1);
15  
16 #pragma omp task shared(j)
17     j = fib(n-2);
18  
19 #pragma omp taskwait
20     return i+j;
21   }
22 }
23 
24 
25 main()
26 {
27   int result = 0;
28 
29   omp_set_num_threads(4);
30 
31 #pragma omp parallel
32   {
33     #pragma omp single
34     {
35       result = fib(5);
36     }
37   }
38 
39   printf("fib(5) = %d\n", result);
40 }

The following output illustrates the type of information that idb info taskwait displays.

(idb)  b 6
Breakpoint 1 at 0x804898e: file /fib.C, line 6.
(idb)  r
Starting program: /fib
[New Thread 3086866112 (LWP 22340)]
[New Thread 3086866112 (LWP 22340)]
[New Thread 1194912 (LWP 22341)]
[New Thread 7830432 (LWP 22342)]
[New Thread 9931680 (LWP 22343)]
[New Thread 15641504 (LWP 22344)]
 
Breakpoint 1, fib (n=0) at /fib.C:6
6     return 0;(idb)  idb info taskwait
150000001           taskwait for task 15, waiting tasks
                    Encountering thread: 1
                    Created at: "/fib.C":fib:19:19
                    Awaiting tasks: 20 19 
 
190000001           taskwait for task 19, waiting tasks
                    Encountering thread: 3
                    Created at: "/fib.C":fib:19:19
                    Awaiting tasks: 25 26 
 
200000001           taskwait for task 20, waiting tasks
                    Encountering thread: 1
                    Created at: "/fib.C":fib:19:19
                    Awaiting tasks: 21 
 
210000001           taskwait for task 21, waiting tasks
                    Encountering thread: 1
                    Created at: "/fib.C":fib:19:19
                    Awaiting tasks: 23 24 

See Also


Submit feedback on this help topic

Copyright © 2001-2011, Intel Corporation. All rights reserved.