[gomp] Fix omp single

Richard Henderson rth@redhat.com
Wed Sep 28 17:35:00 GMT 2005


On Wed, Sep 28, 2005 at 08:09:06AM -0400, Diego Novillo wrote:
> There isn't a barrier at the end of thread bodies as I thought there was.

If you return from the __omp_fn.N function, there is indeed a 
barrier: either in libgomp or in GOMP_parallel_end.

But you're forgetting these directives needn't be nested 
directly inside the omp parallel.

	void foo()
	{
	#pragma omp single copyprivate(x,y,z)
	  x = , y = , z = ...;
	}

	void bar()
	{
	  clobber stack;
	}

	void baz()
	{
	  for (int i = 0; i < 10; i++)
	    foo(), bar();
	}

	int main()
	{
	#pragma omp parallel
	  baz ();
	}


r~



More information about the Gcc-patches mailing list