So here is the code:
#pragma omp parallel private (myId)
{
set_affinity();
myId = omp_get_thread_num();
if (myId<myConstant)
{
#pragma omp for schedule(static,1)
for(count = 0; count < AnotherConstant; count++)
{
}
}
#pragma omp barrier
#pragma omp single
{
}
#pragma omp barrier
par_time(cc_time_tot, phi_time_tot, psi_time_tot);
#pragma omp barrier
}
Now, to explain what is happening. At the beginning of my parallel area, myId is set to private, so each thread has its own correct thread id. set_affinity () controls which thread runs on which kernel. The problem I have includes #pragma omp for schedule (static, 1).
block:
if (myId<myConstant)
{
#pragma omp for schedule(static,1)
for(count = 0; count < AnotherConstant; count++)
{
}
}
This is some work that I want to distribute over a certain number of threads, 0 through myConstant-1. In these threads, I want to evenly (according to how the schedule does it (static, 1)) distribute the loop iterations. All this is done correctly.
, , . , myConstant 2. , 3 , , id 3 .
, , . id 3 ( myConstant ) , par_time(), , , . par_time() .
pragma omp (static, 1) , for ( if statement if (myId == 0)), . , .
, - , . , , - OMP.