I'm new to OpenMP. When I parallelize a for
loop using
#pragma omp parallel for num_threads(4)
for(i=0;i<4;i++){
//some parallelizable code
}
Is it guaranteed that every thread takes one and only one value of i
? How is the loop work divided among the threads in general when num_threads
is not equal to or does not evenly divide the total number of times of the for loop? Is there a command I can use to specify that each thread takes only one value of i
, or the number of values of i
each thread takes?