[gomp] New tests
Jakub Jelinek
jakub@redhat.com
Mon Oct 17 16:28:00 GMT 2005
On Mon, Oct 17, 2005 at 12:14:19PM -0400, Diego Novillo wrote:
>
> These are all adapted from Appendix A of the standard. We fail only a few.
> I'm looking into those failures today.
By any chance, do you have the Fortran testcases as well?
> Of interest is the failure in libgomp/a.18.1.c. We have a shared array
> used to busy wait for neighbors:
>
> #pragma omp flush(work,synch)
> synch[iam] = 1;
> #pragma omp flush(synch)
> neighbor = (iam > 0 ? iam : omp_get_num_threads ()) - 1;
> while (synch[neighbor] == 0)
> {
> #pragma omp flush(synch)
> }
> #pragma omp flush(work,synch)
>
>
> When compiled at -O2, this program enters an infinite loop because the RTL
> optimizers hoist the load from 'sync[neighbor]' out of the loop, so we end
> up with
>
> .L10:
> testl %edx, %edx
> je .L10
>
> instead of
>
> .L14:
> movl synch(,%edx,4), %eax
> testl %eax, %eax
> je .L12
>
> This is "fixed" by marking 'synch' volatile. However, IIUC, the standard
> assumes this should not be necessary in the presence of 'flush'. Richard,
> Jakub?
Well, flush needs to translate into an optimization barrier.
So, IMHO either we should translate it into GOMP_flush function call and do
the __sync_synchronize (); in libgomp, or use something equally strong
to a non-pure function call to prevent optimizations across it.
Jakub
More information about the Gcc-patches
mailing list