Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

openmp reduction bug in icc v11.0.081

kambrian
Beginner
270 Views
[cpp]#include 
#include 
#include 
#include 
//~ #include 

int main(int argc,char **argv)
{
	int i;
	double a,b,c,d,e,f;

	a=b=c=d=e=f=0.;	
	#pragma omp parallel for reduction(+: a,b,c,d,e,f)
	for(i=0;i<10;i++)
	{
	a+=1.;
	b+=1.;
	c+=1.;
	d+=1.;
	e+=1.;
	f+=1.;
    //~ printf("i=%d:%d,  %g,%g,%g,%g,%g,%gn",i,omp_get_thread_num(),a,b,c,d,e,f);
	}
	printf("%g,%g,%g,%g,%g,%gn",a,b,c,d,e,f);
	return 0;
}
[/cpp]

The above code compiles and runs correctly using icc v8.0 on ia64 and v10.0 on ia32 (which are two of my working platforms),but the result is confusing using icc v11.0.081 on ia64.
The expected results should print (and that's exactly the icc v8 and v10 results): 10,10,10,10,10,10.
While using icc v11, it prints: 10,10,10,10,1,1
Just the first four vars got reduced, the other two variables remain just the values of the main thread (which may change depending on the total threads used and thus work-sharing).
If I use float instead of double variables, the result is correct.What's more confusing is that Occasionally the result turns OK for the above code, but just once during my tests.
It's getting me feeling unsafe...
0 Kudos
3 Replies
Om_S_Intel
Employee
270 Views

This is a bug in the compiler.
0 Kudos
Om_S_Intel
Employee
270 Views
The issue is fixed in beta Intel C++ compiler version 11.1.023. I created a defect reference in the knowledge base http://software.intel.com/en-us/articles/openmp-reduction-error/

0 Kudos
kambrian
Beginner
270 Views
The issue is fixed in beta Intel C++ compiler version 11.1.023. I created a defect reference in the knowledge base http://software.intel.com/en-us/articles/openmp-reduction-error/


Thanks for your response.
0 Kudos
Reply