On Fri, 16 Nov 2018 22:10:00 +0100 Jakub Jelinek <ja...@redhat.com> wrote:
> Kevin, did you have some gdb testcases you were trying for the r253335 > change? Can you try those with added another e.g. parallel around it (say > #pragma omp parallel if (0) or num_threads (1), so that it doesn't spawn too > many children and see if you can check variables not mentioned in the inner > parallel inside of the outer parallel, or even outside of the outer > parallel? Hi Jakub, Sorry for the delayed response - I had some issues on the GDB side of things that needed to be addressed before I could properly test your patch. In the GDB test that I've written, I test four scenarios: 1) Simple parallel region with no additional lexical scopes. 2) Like the above, but with additional lexical scopes. 3) Parallel region within nested function. 4) Nested parallel regions. With your patch in place, I see correct results for scenarios 1, 2, and 3. Scenario 4 works better than it ever did in the past, though there are still some problems. Here is that test case - just scenario 4: static int file_scope_var = 9876; void nested_parallel (void) { int i = 1, j = 2; int l = -1; omp_set_nested (1); omp_set_dynamic (0); #pragma omp parallel num_threads (2) private (l) { int num = omp_get_thread_num (); int nthr = omp_get_num_threads (); int off = num * nthr; int k = off + 101; l = off + 102; #pragma omp parallel num_threads (2) shared (num) { #pragma omp critical printf ("nested_parallel (inner threads): outer thread num = %d, thread num = %d\n", num, omp_get_thread_num ()); } #pragma omp critical printf ("nested_parallel (outer threads) %d: k = %d, l = %d\n", num, k, l); } } Breakpoints are placed on both of the printfs and attempts are made to print some of the variables that should be in scope at each stop. For the "inner threads" printf, there are four stops altogether. At each stop for those inner threads, GDB is able to successfully print file_scope_var, num, i, and j. For all but one of the stops, GDB is able to print the values for l and k. Here is the log output for the fourth stop in which GDB cannot print out either l or k: print l No frame is currently executing in block nested_parallel._omp_fn.3. (gdb) XFAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 4th stop: print l print k No frame is currently executing in specified block (gdb) XFAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 4th stop: print k These failures are not entirely unexpected due to the fact that GDB is not always able to correctly determine the thread parent for the nested parallel case. (Additional support will be required from libgomp.) I still need to do some investigation to find out whether the messages being printed make sense. Anyway... I'm all in favor of your patch. It fixes a bunch of failures that I had been seeing for quite a while. Kevin