Crash in OpenMP when using tasks from different thread

Crash in OpenMP when using tasks from different thread

Portrait de mongush@gmail.com

Looks like if you use tasks in one thread and destroyed it after, than next time if you use tasks from other thread you get exception from libiomp5md.dll Here is code that reproduces it on my system (Microsoft Windows [Version 6.1.7601],Intel C++ Compiler XE for applications running on IA-32, Version 12.1.0.233 Build 20110811,Microsoft Visual Studio 2010Version 10.0.40219.1 SP1Rel)

#include 
#include 
int fib ( int n ) 
{
	int x,y;
	if ( n < 2 ) 
		return n;
#pragma omp task shared(x) 
	x = fib(n-1);
#pragma omp task shared(y) 
	y = fib(n-2);
#pragma omp taskwait
	return x+y;
}
void fib_fn(int n)
{
	int res;
#pragma omp parallel
	{
#pragma omp single
		res = fib(n);
	}
	std::cout << res << std::endl;
}
int main()
{
	fib_fn(10);
	for(int i = 0; i < 10; i++)
	{
		std::thread th(fib_fn,10);
		th.join();
	}
	return 0;
}
4 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.
Portrait de jimdempseyatthecove

OpenMP is designed to run from a single thread,principaly the main thread for a console app, but for a Windows app this could be one of the other threads you instantiate.

IOW it is not re-entrant (although within an OpenMP session you can use re-entrant constructs).

Jim Dempsey

www.quickthreadprogramming.com
Portrait de mongush@gmail.com

But everything works fine while using #pragma omp parallel for, only with tasks crash occur.
According to this post
http://software.intel.com/en-us/forums/showpost.php?p=160568
it seems to me that the posted code should work.

Portrait de jimdempseyatthecove

Did you read and understand the other post you referenced?
intmain()

{
fib_fn(10); // will instantiate OpenMP parallel team from main()
for(inti=0;i<10;i++)
{
std::threadth(fib_fn,10); // Instantiates non-OpenMP "main" thread
// ** each thread instantiating seperate "main" thread pool
// ** libiomp5md mayexhibit problems instantiating many thread pools
// ** the above code, on Sandy Bridge would generate11 thread pools each of 8 threads (88 threads)
// ** on IA32 the stack size may be an issue as well as reentrancy issues of libiomp5md.dll
th.join();
}
return0;
}

Jim Dempsey

www.quickthreadprogramming.com

Connectez-vous pour laisser un commentaire.