| 1 |
/* { dg-do compile } */ |
| 2 |
|
| 3 |
#include <omp.h> |
| 4 |
|
| 5 |
void |
| 6 |
example_criticial () |
| 7 |
{ |
| 8 |
int a, b; |
| 9 |
#pragma omp parallel for |
| 10 |
for (int i = 0; i < 10; ++i) |
| 11 |
{ |
| 12 |
#pragma omp critical hint(omp_sync_hint_none) /* OK */ |
| 13 |
a += i; |
| 14 |
#pragma omp critical (HASH) hint(omp_sync_hint_none) /* OK */ |
| 15 |
a += i; |
| 16 |
#pragma omp critical (HASH2) hint(omp_sync_hint_uncontended) /* OK */ |
| 17 |
a += i; |
| 18 |
#pragma omp critical (HASH3) hint(omp_sync_hint_contended) /* OK */ |
| 19 |
a += i; |
| 20 |
#pragma omp critical (HASH4) hint(omp_sync_hint_speculative) /* OK */ |
| 21 |
a += i; |
| 22 |
#pragma omp critical (HASH5) hint(omp_sync_hint_nonspeculative) /* OK */ |
| 23 |
a += i; |
| 24 |
#pragma omp critical (HASH6) hint(omp_sync_hint_contended + omp_sync_hint_speculative) /* OK */ |
| 25 |
a += i; |
| 26 |
#pragma omp critical (HASH6) hint(omp_sync_hint_contended | omp_sync_hint_speculative) /* OK */ |
| 27 |
a += i; |
| 28 |
|
| 29 |
/* Accepted but invalid: different hint for same name. */ |
| 30 |
#pragma omp critical (HASH6) hint(omp_sync_hint_uncontended + omp_sync_hint_speculative) |
| 31 |
a += i; |
| 32 |
/* Accepted but invalid: Some random integer expr. */ |
| 33 |
#pragma omp critical (HASH) hint(omp_sync_hint_speculative + 1 + 2) |
| 34 |
a += i; |
| 35 |
|
| 36 |
#pragma omp critical (HASH) hint(-3) /* { dg-error "expected constant integer expression" } */ |
| 37 |
a += i; |
| 38 |
#pragma omp critical (HASH2) hint(b) /* { dg-error "constant integer expression" } */ |
| 39 |
a += i; |
| 40 |
/* |
| 41 |
Fails with gcc as 'expected identifier' and |
| 42 |
with g++ as "clause requires a name, except when 'omp_sync_hint_none'" |
| 43 |
#pragma omp critical () hint(omp_sync_hint_speculative) |
| 44 |
a += i; |
| 45 |
*/ |
| 46 |
#pragma omp critical hint(omp_sync_hint_speculative) /* { dg-error "with 'hint' clause requires a name, except when 'omp_sync_hint_none' is used" } */ |
| 47 |
a += i; |
| 48 |
} |
| 49 |
} |