diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2020-07-22 12:12:48 +0200 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2020-07-22 12:14:22 +0200 |
commit | ade6e7204ce4d179cd9fa4637ddee85ba1fa12d9 (patch) | |
tree | d0bfb66b2a8b9e3790e969c33c5f7c52a7f7884c /libgomp | |
parent | cd91a084877dabcc53aec57ab70ca4fc32f3d985 (diff) | |
download | gcc-ade6e7204ce4d179cd9fa4637ddee85ba1fa12d9.zip gcc-ade6e7204ce4d179cd9fa4637ddee85ba1fa12d9.tar.gz gcc-ade6e7204ce4d179cd9fa4637ddee85ba1fa12d9.tar.bz2 |
critical-hint-*.{c,f90}: Move from gcc/testsuite to libgomp/testsuite
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/.
Diffstat (limited to 'libgomp')
4 files changed, 248 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c-c++-common/critical-hint-1.c b/libgomp/testsuite/libgomp.c-c++-common/critical-hint-1.c new file mode 100644 index 0000000..1e49747 --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/critical-hint-1.c @@ -0,0 +1,49 @@ +/* { 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; + } +} diff --git a/libgomp/testsuite/libgomp.c-c++-common/critical-hint-2.c b/libgomp/testsuite/libgomp.c-c++-common/critical-hint-2.c new file mode 100644 index 0000000..057353b --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/critical-hint-2.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-original" } */ +#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) + a += i; + #pragma omp critical (HASH1) hint(omp_sync_hint_none) + a += i; + #pragma omp critical (HASH2) hint(omp_sync_hint_uncontended) + a += i; + #pragma omp critical (HASH3) hint(omp_sync_hint_contended) + a += i; + #pragma omp critical (HASH4) hint(omp_sync_hint_speculative) + a += i; + #pragma omp critical (HASH5) hint(omp_sync_hint_nonspeculative) + a += i; + #pragma omp critical (HASH6) hint(omp_sync_hint_contended + omp_sync_hint_speculative) + a += i; + #pragma omp critical (HASH7) hint(omp_sync_hint_contended | omp_sync_hint_speculative) + a += i; + } +} + +/* { dg-final { scan-tree-dump-times "omp critical \\(HASH1\\) hint\\(0\\)" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "omp critical \\(HASH2\\) hint\\(1\\)" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "omp critical \\(HASH3\\) hint\\(2\\)" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "omp critical \\(HASH4\\) hint\\(8\\)" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "omp critical \\(HASH5\\) hint\\(4\\)" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "omp critical \\(HASH6\\) hint\\(10\\)" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "omp critical \\(HASH7\\) hint\\(10\\)" 1 "original" } } */ diff --git a/libgomp/testsuite/libgomp.fortran/critical-hint-1.f90 b/libgomp/testsuite/libgomp.fortran/critical-hint-1.f90 new file mode 100644 index 0000000..225d9a7 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/critical-hint-1.f90 @@ -0,0 +1,96 @@ +! { dg-do compile } + +subroutine example_criticial () + use omp_lib + implicit none + integer, parameter :: my_omp_hint = omp_sync_hint_contended + integer i, a, b + + !$omp parallel do + do i = 1, 10 + !$omp critical (HASH0) hint(my_omp_hint) ! OK + a = a + i; + !$omp end critical (HASH0) + end do + !$omp parallel do + do i = 1, 10 + !$omp critical (HASH1) hint(omp_sync_hint_none) ! OK + a = a + i; + !$omp end critical (HASH1) + end do + !$omp parallel do + do i = 1, 10 + !$omp critical (HASH2) hint(omp_sync_hint_uncontended) ! OK + a = a + i; + !$omp end critical (HASH2) + end do + !$omp parallel do + do i = 1, 10 + !$omp critical (HASH3) hint(omp_sync_hint_contended) ! OK + a = a + i; + !$omp end critical (HASH3) + end do + !$omp parallel do + do i = 1, 10 + !$omp critical (HASH4) hint(omp_sync_hint_speculative) ! OK + a = a + i; + !$omp end critical (HASH4) + end do + !$omp parallel do + do i = 1, 10 + !$omp critical (HASH5) hint(omp_sync_hint_nonspeculative) ! OK + a = a + i; + !$omp end critical (HASH5) + end do + !$omp parallel do + do i = 1, 10 + !$omp critical (HASH6) hint(omp_sync_hint_contended + omp_sync_hint_speculative) ! OK + a = a + i; + !$omp end critical (HASH6) + end do + + !$omp parallel do + do i = 1, 10 + ! Accepted but invalid: different hint for same name. + !$omp critical (HASH6) hint(omp_sync_hint_contended + omp_sync_hint_speculative) ! OK + a = a + i; + !$omp end critical (HASH6) + end do + !$omp parallel do + do i = 1, 10 + ! Accepted but invalid: Some random integer expr. + !$omp critical (HASH) hint(1 + 2) + a = a + i; + !$omp end critical (HASH) + end do + !$omp parallel do + do i = 1, 10 + !$omp critical (HASH) hint(-3) ! { dg-error "shall be a valid constant hint expression" } + a = a + i; + !$omp end critical (HASH) + end do + !$omp parallel do + do i = 1, 10 + !$omp critical (HASH2) hint(b) ! { dg-error "shall be a valid constant hint expression" } + a = a + i; + !$omp end critical (HASH2) + end do + !$omp parallel do + do i = 1, 10 + !$omp critical () hint(omp_hint_speculative) ! { dg-error "Invalid character in name" } + a = a + i; +! !$omp end critical + end do + !$omp parallel do + do i = 1, 10 + !$omp critical hint(omp_sync_hint_none) ! OK + a = a + i; + !$omp end critical + end do + !$omp parallel do + do i = 1, 10 + !$omp critical hint(omp_sync_hint_contended) ! { dg-error "CRITICAL at .1. with HINT clause requires a NAME, except when omp_sync_hint_none is used" } + a = a + i; + !$omp end critical + end do +end diff --git a/libgomp/testsuite/libgomp.fortran/critical-hint-2.f90 b/libgomp/testsuite/libgomp.fortran/critical-hint-2.f90 new file mode 100644 index 0000000..f34680c --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/critical-hint-2.f90 @@ -0,0 +1,66 @@ +! { dg-do compile } +! { dg-additional-options "-fdump-tree-original" } +subroutine example_criticial () + use omp_lib + implicit none + integer, parameter :: my_omp_hint = omp_sync_hint_contended + integer i, a, b + + !$omp parallel do + do i = 1, 10 + !$omp critical (HASH0) hint(my_omp_hint) + a = a + i; + !$omp end critical (HASH0) + end do + !$omp parallel do + do i = 1, 10 + !$omp critical (HASH1), hint(omp_sync_hint_none) + a = a + i; + !$omp end critical (HASH1) + end do + !$omp parallel do + do i = 1, 10 + !$omp critical (HASH2) hint(omp_sync_hint_uncontended) + a = a + i; + !$omp end critical (HASH2) + end do + !$omp parallel do + do i = 1, 10 + !$omp critical (HASH3) hint(omp_sync_hint_contended) + a = a + i; + !$omp end critical (HASH3) + end do + !$omp parallel do + do i = 1, 10 + !$omp critical (HASH4) hint(omp_sync_hint_speculative) + a = a + i; + !$omp end critical (HASH4) + end do + !$omp parallel do + do i = 1, 10 + !$omp critical (HASH5) hint(omp_sync_hint_nonspeculative) + a = a + i; + !$omp end critical (HASH5) + end do + !$omp parallel do + do i = 1, 10 + !$omp critical (HASH6), hint(omp_sync_hint_contended + omp_sync_hint_speculative) + a = a + i; + !$omp end critical (HASH6) + end do + !$omp parallel do + do i = 1, 10 + !$omp critical hint(omp_sync_hint_none + omp_sync_hint_none) + a = a + i; + !$omp end critical + end do +end + +! { dg-final { scan-tree-dump-times "omp critical \\(hash0\\) hint\\(2\\)" 1 "original" } } +! { dg-final { scan-tree-dump-times "omp critical \\(hash1\\) hint\\(0\\)" 1 "original" } } +! { dg-final { scan-tree-dump-times "omp critical \\(hash2\\) hint\\(1\\)" 1 "original" } } +! { dg-final { scan-tree-dump-times "omp critical \\(hash3\\) hint\\(2\\)" 1 "original" } } +! { dg-final { scan-tree-dump-times "omp critical \\(hash4\\) hint\\(8\\)" 1 "original" } } +! { dg-final { scan-tree-dump-times "omp critical \\(hash5\\) hint\\(4\\)" 1 "original" } } +! { dg-final { scan-tree-dump-times "omp critical \\(hash6\\) hint\\(10\\)" 1 "original" } } +! { dg-final { scan-tree-dump-times "omp critical hint\\(0\\)" 1 "original" } } |