c++ - Why can't if get the correct tid when using omp #pragma omp for schedule(dynamic)? -


#pragma omp parallel private(nthreads, tid)                                                                                                                                                                {                                                                                   tid = omp_get_thread_num();                                                                                                                                                                              printf("hello world thread = %d\n", tid);                                                                                                                                                            /* master thread */                                                                                                                                                                       if (tid == 0)                                                                                                                                                                                              {                                                                                                                                                                                                          nthreads = omp_get_num_threads();                                                                                                                                                                        printf("number of threads = %d\n", nthreads);                                                                                                                                                           }                                                                                                                                                                                                      #pragma omp barrier                                                                                                                                                                                        #pragma omp schedule(dynamic)                                                                                                                                                                            for(int n=0; n<10; ++n){                                                                                                                                                                                 printf(" %d", n);                                                                                                                                                                                        printf(" %d", tid);                                                                                                                                                                                      }                                                                                                                                                                                                         printf("\n");                                                                                                                                                                                            }                 

why when print tid schedule(dynamic) 0, while when using schedule(static) see each tid print (0-9). if concerned thread doing what, not using dynamic curious.

thanks in advance.


Comments