Quick question ... I have the following code:
void testingOMP()
{
#pragma omp parallel for
for(int i=0;i<5;i++)
{
#pragma omp single
cout << "During single: " <<omp_get_thread_num() << endl;
cout << "After single: " << omp_get_thread_num() << endl;
}
}
which hangs, yielding the following result:
During single: 1 After single: 1 After single: after single: 2During single: 0
1
I needed ctrl + c to stop it. The sharing directive ensures that only one thread executes a block of code that has a synchronization barrier at the end. I think the problem is that if I use master (which does not wait) or adds nowait, the program does not crash.
If anyone could tell me why this is happening, they really appreciate me.
source
share