c++ - OpenMP specify thread number of a for loop iteration -
i'm using following command parallelize single loop on available threads of program:
#pragma omp parallel num_threads(threads) for(long = 0; < threads; i++) { array[i] = calculatestuff(i,...); }
for technical reasons, guarantee thread number 0 executes i=0
, , thread number 1 executes i=1
. in other words, want i=omp_get_thread_num()
. possible?
try
#pragma omp parallel num_threads(threads) schedule(static,1)
now @hristo iliev has turned i'm 100% confident openmp standard requires static schedule assign iteration 0 thread 0, 1 1, etc.
try , let know how on.
then again
#pragma omp parallel num_threads(threads) schedule(dynamic,1)
ought work too, since have many iterations have threads. it's possible though if thread 0 finishes work before thread n
starts thread 0 grab iteration n
.
Comments
Post a Comment