[Omp] CTOR/DTOR invocation for variables in empty paralleldirectives?

Tian, Xinmin xinmin.tian at intel.com
Tue Nov 1 15:02:40 PST 2005


The issue you have made me thinking of another example below 

int a = 10
#pragma omp threadprivate(a)

init{)
{
  #pragma omp parallel copyin(a)  
  {
  }
} 

main()
{
   init()
#pragma omp parallel 
  {
       if (a!=10) printf("error\n")
  }
}

In this case, if you remove the empty parallel region and not generate
threaded code for it, you will get unexpected results. 

Using this as an example, I don't think removing empty "parallel" region
at all optimization levels is standard conforming, in general. For
"parallel private" case you have, since the standard is not stated
explicitly, we need to double check the standard.  

Xinmin Tian (for OpenMP ARB)      



-----Original Message-----
From: Diego Novillo [mailto:dnovillo at redhat.com] 
Sent: Tuesday, November 01, 2005 2:27 PM
To: Tian, Xinmin
Cc: omp at openmp.org
Subject: Re: [Omp] CTOR/DTOR invocation for variables in empty
paralleldirectives?

On Tuesday 01 November 2005 17:15, Tian, Xinmin wrote:

> If users have this type of code, the performance may not be a big
> concern for users. In general, users can always use lower optimization
> (O0 or Od), so the compiler can still generate threaded code for empty
> parallel region by not being smart to remove it.
>
Thanks.  Though what I really need to clarify is whether the compiler is

*allowed* to elide that construct.

With our current implementation, GCC will remove the whole parallel 
directive regardless of optimization level.  No threaded code will be 
generated with

	#pragma omp parallel private (a)
	  {
	  }

Would the compiler be standard conforming if it converted the above into
a 
NOP?


Thanks.




More information about the Omp mailing list