Description
See the program below. Imagine 4 test cases, where a debugger halts all threads at lines 29, 39, 52 and 65.
All fo the lines have the same code, e.g.
int k=id; // someplace to put a breakpoint.
So there are four test cases.
At each breakpoint, query the OMPD runtime library for task information.
For test cases 2 and 3, at lines 29 and 39 respectively,
the retrieved task information indicates the tasks are NOT associated with a parallel_region.
For test case 2 and 4, at lines 39 and 65 respectively,
the retrieved task information indicates the tasks are associated with a parallel_region.
The differences is that cases 1 and 3 pass in a #threads=1; e.g. #pragma omp parallel num_threads(1)
while 2 and 4 pass in #threads>2; e.g. #pragma omp parallel num_threads(2)
It appears that a num_threads(1) results in the ompd library not indicating that the associated tasks in the parallel region are actually NOT in the parallel regions, when to the casual programmer, they actually are in a parallel region.
/* Sample OpenMP program to test OMPD handling. */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <string.h>
#include <omp.h>
static volatile int volatile_int;
int
main ( int argc, char *argv [] )
{
int id;
int test_num = 0;
int i;
printf ( "main \n");
// PartI. implicit pragma section
test_num++;
i = 1;
printf ( "Part I: implicit pragma section test == %d nthreads == %d\n", test_num, i );
#pragma omp parallel num_threads(i), private(id)
{
id = omp_get_thread_num ();
printf ( " num_threads==%d id==%d\n", i, id );
int k=id; // someplace to put a breakpoint
}
test_num++;
i = 2;
printf ( "Part I: implicit pragma section test == %d nthreads == %d\n", test_num, i );
#pragma omp parallel num_threads(i), private(id)
{
id = omp_get_thread_num ();
printf ( " num_threads==%d id==%d\n", i, id );
int k=id; // someplace to put a breakpoint
}
// Part II. explicit task section
test_num++;
i=1;
printf ( "Part II: explict task pragma section test == %d nthreads == %d\n", test_num, i );
#pragma omp parallel num_threads(i), private(id)
{
id = omp_get_thread_num ();
#pragma omp task
{
printf ( " num_threads==%d id==%d\n", i, id );
int k=id; // someplace to put a breakpoint
}
}
test_num++;
i=2;
printf ( "Part II: explict task pragma section test == %d nthreads == %d\n", test_num, i );
#pragma omp parallel num_threads(i), private(id)
{
id = omp_get_thread_num ();
#pragma omp task
{
printf ( " num_threads==%d id==%d\n", i, id );
int k=id; // someplace to put a breakpoint
}
}
return 0;
} /* main */