public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Tobias Burnus <burnus@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-11] Fortran: openmp: Add support for thread_limit clause on target Date: Sun, 27 Feb 2022 21:35:19 +0000 (GMT) [thread overview] Message-ID: <20220227213519.B188D3858414@sourceware.org> (raw) https://gcc.gnu.org/g:c48a85897d3e0d0ee348fd5111bd1a9953923472 commit c48a85897d3e0d0ee348fd5111bd1a9953923472 Author: Tobias Burnus <tobias@codesourcery.com> Date: Mon Nov 15 15:44:11 2021 +0100 Fortran: openmp: Add support for thread_limit clause on target gcc/fortran/ChangeLog: * openmp.c (OMP_TARGET_CLAUSES): Add thread_limit. * trans-openmp.c (gfc_split_omp_clauses): Add thread_limit also to teams. libgomp/ChangeLog: * testsuite/libgomp.fortran/thread-limit-1.f90: New test. (cherry picked from commit 82ec4cb3c43c7429be6b902d96770a6435fa068b) Diff: --- gcc/fortran/ChangeLog.omp | 9 +++++ gcc/fortran/openmp.c | 3 +- gcc/fortran/trans-openmp.c | 2 ++ libgomp/ChangeLog.omp | 7 ++++ .../testsuite/libgomp.fortran/thread-limit-1.f90 | 41 ++++++++++++++++++++++ 5 files changed, 61 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp index 7f71f1f6a73..f78aa5e366f 100644 --- a/gcc/fortran/ChangeLog.omp +++ b/gcc/fortran/ChangeLog.omp @@ -1,3 +1,12 @@ +2022-02-27 Tobias Burnus <tobias@codesourcery.com> + + Backported from master: + 2021-11-15 Tobias Burnus <tobias@codesourcery.com> + + * openmp.c (OMP_TARGET_CLAUSES): Add thread_limit. + * trans-openmp.c (gfc_split_omp_clauses): Add thread_limit also to + teams. + 2022-02-27 Tobias Burnus <tobias@codesourcery.com> Backported from master: diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index ecc3844f9f5..13cbab1b42a 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -3570,7 +3570,8 @@ cleanup: (omp_mask (OMP_CLAUSE_DEVICE) | OMP_CLAUSE_MAP | OMP_CLAUSE_IF \ | OMP_CLAUSE_DEPEND | OMP_CLAUSE_NOWAIT | OMP_CLAUSE_PRIVATE \ | OMP_CLAUSE_FIRSTPRIVATE | OMP_CLAUSE_DEFAULTMAP \ - | OMP_CLAUSE_IS_DEVICE_PTR | OMP_CLAUSE_IN_REDUCTION) + | OMP_CLAUSE_IS_DEVICE_PTR | OMP_CLAUSE_IN_REDUCTION \ + | OMP_CLAUSE_THREAD_LIMIT) #define OMP_TARGET_DATA_CLAUSES \ (omp_mask (OMP_CLAUSE_DEVICE) | OMP_CLAUSE_MAP | OMP_CLAUSE_IF \ | OMP_CLAUSE_USE_DEVICE_PTR | OMP_CLAUSE_USE_DEVICE_ADDR) diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 99da12f9088..a4eec2d7b98 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -5902,6 +5902,8 @@ gfc_split_omp_clauses (gfc_code *code, = code->ext.omp_clauses->lists[OMP_LIST_IS_DEVICE_PTR]; clausesa[GFC_OMP_SPLIT_TARGET].device = code->ext.omp_clauses->device; + clausesa[GFC_OMP_SPLIT_TARGET].thread_limit + = code->ext.omp_clauses->thread_limit; for (int i = 0; i < OMP_DEFAULTMAP_CAT_NUM; i++) clausesa[GFC_OMP_SPLIT_TARGET].defaultmap[i] = code->ext.omp_clauses->defaultmap[i]; diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp index 3149d78027b..5d186464017 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -1,3 +1,10 @@ +2022-02-27 Tobias Burnus <tobias@codesourcery.com> + + Backported from master: + 2021-11-15 Tobias Burnus <tobias@codesourcery.com> + + * testsuite/libgomp.fortran/thread-limit-1.f90: New test. + 2022-02-27 Tobias Burnus <tobias@codesourcery.com> Backported from master: diff --git a/libgomp/testsuite/libgomp.fortran/thread-limit-1.f90 b/libgomp/testsuite/libgomp.fortran/thread-limit-1.f90 new file mode 100644 index 00000000000..bca69fbb466 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/thread-limit-1.f90 @@ -0,0 +1,41 @@ +! { dg-additional-options "-fdump-tree-original" } + +! { dg-final { scan-tree-dump-times "#pragma omp teams thread_limit\\(9\\)" 1 "original" } } +! { dg-final { scan-tree-dump-times "#pragma omp target thread_limit\\(9\\)" 1 "original" } } + +! { dg-final { scan-tree-dump-times "#pragma omp target nowait thread_limit\\(4\\)" 1 "original" } } +! { dg-final { scan-tree-dump-times "#pragma omp parallel num_threads\\(1\\)" 1 "original" } } + +! { dg-final { scan-tree-dump-times "#pragma omp target thread_limit\\(6\\)" 1 "original" } } + + +module m + use omp_lib + implicit none +contains + +subroutine uncalled() + !$omp target teams thread_limit (9) + !$omp end target teams +end + +subroutine foo () + block + !$omp target parallel nowait thread_limit (4) num_threads (1) + if (omp_get_thread_limit () > 4) & + stop 1 + !$omp end target parallel + end block + !$omp taskwait +end +end module + +program main + use m + implicit none + !$omp target thread_limit (6) + if (omp_get_thread_limit () > 6) & + stop 2 + !$omp end target + call foo () +end
reply other threads:[~2022-02-27 21:35 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220227213519.B188D3858414@sourceware.org \ --to=burnus@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).