I'm using OpenMP in c++. I want to specify the number of threads (16) and then run each thread with an id from 0 to 15. I have an array of 16 numbers which I want to use as parameters in each separate thread. So I have
omp_set_dynamic(0);
omp_set_num_threads(16);
int tid;
#pragma omp parallel shared(myvector) private(tid)
{
tid = omp_get_thread_num();
// Do some calculations using myvector[tid]
}
However, the (tid)s are not ordered as 0 to 15, as some are repeated twice or more. How do I force it to run one task with each of the 16 parameters?