Mambru37,
If you do not specify the number of threads for the parallel sections then the parallel sections begins with the default number of available threads. Each section within the parallel sections in turn will run on one of the threads, in your case one thread from the set of threads for the sections will run for each of two sections. Any additional threads will wait at the end parallel sections (assuming you do not use NOWAIT).
Pseudo code for you to consider
...
int NumberOfPackages = YourGetNumberOfPackages();
void* PackageMask[] = {NULL, NULL};
bool FirstTime[] = {TRUE, TRUE};
void DoWork0(void)
{
if(FirstTime[0])
{
#omp parallel
{
YourSetAffinity(PackageMask[0]);
}
FirstTime[0] = FALSE;
}
...
}
// DoWork1 similar to above
main(...)
{
...
PackageMask[0] = YourGetAffinityMaskForPackage(0);
if(NumberOfPackages > 1)
{
PackageMask[1] = YourGetAffinityMaskForPackage(1);
} else {
PackageMask[1] = PackageMask[0];
}
#pragma omp parallel num_threads(2)
{
int ThreadNum = omp_get_thread_num();
while(ProcessMainLoop)
{
if(FirstTime[ThreadNum])
{
SetAffinity(PackageMask[ThreadNum]);
}
DoMainIterationPreamble(ThreadNum); // e.g. read data
#pragma omp barrier
if(ThreadNum == 0)
{
DoWork0();
} else {
DoWork1();
}
#pragma omp barrier
}
}
}
Jim Dempsey