ade6e7204c
libgomp/ChangeLog: * testsuite/libgomp.c-c++-common/critical-hint-1.c: New; moved from gcc/testsuite/c-c++-common/gomp/. * testsuite/libgomp.c-c++-common/critical-hint-2.c: Likewise. * testsuite/libgomp.fortran/critical-hint-1.f90: New; moved from gcc/testsuite/gfortran.dg/gomp/. * testsuite/libgomp.fortran/critical-hint-2.f90: Likewise. gcc/testsuite/ChangeLog: * c-c++-common/gomp/critical-hint-1.c: Moved to libgomp/. * c-c++-common/gomp/critical-hint-2.c: Moved to libgomp/. * gfortran.dg/gomp/critical-hint-1.f90: Moved to libgomp/. * gfortran.dg/gomp/critical-hint-2.f90: Moved to libgomp/.
50 lines
1.8 KiB
C
50 lines
1.8 KiB
C
/* { dg-do compile } */
|
|
|
|
#include <omp.h>
|
|
|
|
void
|
|
example_criticial ()
|
|
{
|
|
int a, b;
|
|
#pragma omp parallel for
|
|
for (int i = 0; i < 10; ++i)
|
|
{
|
|
#pragma omp critical hint(omp_sync_hint_none) /* OK */
|
|
a += i;
|
|
#pragma omp critical (HASH) hint(omp_sync_hint_none) /* OK */
|
|
a += i;
|
|
#pragma omp critical (HASH2) hint(omp_sync_hint_uncontended) /* OK */
|
|
a += i;
|
|
#pragma omp critical (HASH3) hint(omp_sync_hint_contended) /* OK */
|
|
a += i;
|
|
#pragma omp critical (HASH4) hint(omp_sync_hint_speculative) /* OK */
|
|
a += i;
|
|
#pragma omp critical (HASH5) hint(omp_sync_hint_nonspeculative) /* OK */
|
|
a += i;
|
|
#pragma omp critical (HASH6) hint(omp_sync_hint_contended + omp_sync_hint_speculative) /* OK */
|
|
a += i;
|
|
#pragma omp critical (HASH6) hint(omp_sync_hint_contended | omp_sync_hint_speculative) /* OK */
|
|
a += i;
|
|
|
|
/* Accepted but invalid: different hint for same name. */
|
|
#pragma omp critical (HASH6) hint(omp_sync_hint_uncontended + omp_sync_hint_speculative)
|
|
a += i;
|
|
/* Accepted but invalid: Some random integer expr. */
|
|
#pragma omp critical (HASH) hint(omp_sync_hint_speculative + 1 + 2)
|
|
a += i;
|
|
|
|
#pragma omp critical (HASH) hint(-3) /* { dg-error "expected constant integer expression" } */
|
|
a += i;
|
|
#pragma omp critical (HASH2) hint(b) /* { dg-error "constant integer expression" } */
|
|
a += i;
|
|
/*
|
|
Fails with gcc as 'expected identifier' and
|
|
with g++ as "clause requires a name, except when 'omp_sync_hint_none'"
|
|
#pragma omp critical () hint(omp_sync_hint_speculative)
|
|
a += i;
|
|
*/
|
|
#pragma omp critical hint(omp_sync_hint_speculative) /* { dg-error "with 'hint' clause requires a name, except when 'omp_sync_hint_none' is used" } */
|
|
a += i;
|
|
}
|
|
}
|