- Code: Select all
int main (int argc, char *argv)
#pragma omp parallel for
for (int i = 0; i < 100; i++)
std::cout << i << std::endl;
std::cout << "Thread num: " << omp_get_thread_num() << std::endl;
std::cout << std::endl;
when compiled with -fopenmp and linked to 'gomp' (linux) would write the numbers 0 through 99 in a seemingly chaotic fashion. However, what I see is that thread 0 write the first 49 numbers, and then thread 1 writes the rest (all sequentially). Is there something else I am forgetting to do?