OpenMP in windows thread problem

OpenMP in windows thread problem

I have a problem with OpenMP creating new "shadow" thread and not closing it on the main thread exit:

1) Windows thread starts
2) The first openmp section creates some kind of internal "shadow" intel-openMP thread ( can see cound in "Windows Task Manager"
3) on thread exit, this "shadow" thread is not destroyed.

If 1-2 repeats, number of threads eventually overflows.
I've filed the same question with Compiler support, but posting it here, just in case I'm missing something simple (other then increasing KMP_ALL_THREADS, which will eventually overflow).
Below is sample to show the problem ( I was lazy to setup events, so it is done via "Sleep" just to show the problem).
Thanks,
at.

#include
#include
intd0=0;
intd1=0;
HANDLEhVideoEncodeThread=0;
DWORD vencodeThreadID;
DWORD WINAPI VideoEncodeThread(LPVOID lpParameter)
{
int i,size=100;
#pragma omp parallel
#pragma omp sections
{
#pragma omp section
for(i=0; i#pragma omp section
for(i=size/2; i}
#pragma omp barrier
hVideoEncodeThread=0;
return 0;
}
int main(int argc, char* argv[])
{
int i;
for (i=0;i<100;i++) {
printf("Creating thread %d
",i);
hVideoEncodeThread=CreateThread(NULL,4000000,(LPTHREAD_START_ROUTINE)VideoEncodeThread,0,0,&vencodeThreadID);
while (hVideoEncodeThread) {
Sleep(100);
}
printf("thread %d is completed
",i);
}
return 0;
}

1 Beitrag / 0 neu
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.