Reputation: 1374
Using Nsight Eclipse Edition 10.2 to debug a plain C++ code using gdb 7.11.1.
The code uses a pragma call to OpenMP for forking a for-loop.
The following is a minimal working example,
where a simple array q
is filled with values of another variable p
:
#pragma omp parallel for schedule (static)
for(int p=pstart; p<pend; p++){
const unsigned i = id[p];
if(start <= i && i < end)
q[i - start] = p;
}
In debug mode I would want use the step-in function (classically F5) to follow how the array q
gets filled in with p
's. However, that steps over the for loop altogether, and resumes where the parallel threads join again.
Is there a way to force stepping into a pragma directive/openMP loop?
Upvotes: 1
Views: 309
Reputation: 2859
Is there a way to force stepping into a pragma directive/openMP loop?
That will depend on the debugger, but it's also not entirely clear what it would mean. Since many threads execute the parallel loop, would you expect each of them to stop and then step together? How do you expect to show the different state of each thread? (each will have its own p
and i
). What happens if the thread control flow diverges?
There are debuggers which can do some of this (such as TotalView on Linux), but it's not trivial to do (and TotalView costs money [which is entirely fair and reasonable :-)]).
What you may need to do is set a breakpoint inside the loop, and then handle it being hit by N threads... (Which doesn't answer your precise question, but does let you see what's going on in the loop, which is possibly what you really need to do!)
Upvotes: 1