zoyo wrote:do we need to guaranty that if one thread start doing j=3, all the other threads MUST had finished j=1,meanwhile ,doing j=2 at least.
No you don't: it's perfectly OK for different threads to be in different run time instances of a do
region arising from the same do
construct in the code. (This works because the implementation takes care of the mapping of iterations to threads on a per run time instance basis).
zoyo wrote:and another quetion:is the first thread enconter the parallel loop do the first section of the loop, say i=1,1000 in this case?
Not if you use a STATIC schedule: the chunks of iterations are assigned strictly in thread order (so thread 0 will always get i=1,1000 in this case). It is also safe to assume that for a STATIC schedule, and for parallel loops of with the same number of iterations in the same parallel region, the mapping of iterations to threads will always be the same (see page 44 of the Version 3.1 specification).
(Note: strictly speaking, since your example does not specify a schedule clause, we should not assume that the implementation will use a STATIC schedule in this case, though, in practice, most implementations will).
If you used a DYNAMIC or GUIDED schedule, then the first thread to arrive would take the first chunk of iterations.