(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.c-c++-common/
nested-parallel-unbalanced.c
       1  /* Ensure that nested parallel regions work even when the number of loop
       2     iterations is not divisible by the number of threads.  */
       3  
       4  #include <stdlib.h>
       5  
       6  int main() {
       7    int A[30][40], B[30][40];
       8    size_t n = 30;
       9  
      10    for (size_t i = 0; i < 30; ++i)
      11      for (size_t j = 0; j < 40; ++j)
      12      A[i][j] = 42;
      13  
      14  #pragma omp target map(A[0:30][0:40], B[0:30][0:40])
      15    {
      16  #pragma omp parallel for num_threads(8)
      17      for (size_t i = 0; i < n; ++i)
      18        {
      19  #pragma omp parallel for
      20  	for (size_t j = 0; j < n; ++j)
      21  	  {
      22  	    B[i][j] = A[i][j];
      23  	  }
      24        }
      25    }
      26  
      27  for (size_t i = 0; i < n; ++i)
      28    for (size_t j = 0; j < n; ++j)
      29      if (B[i][j] != 42)
      30        abort ();
      31  }