[gcc r17-3468] openmp: Turn -fopenmp-ompt{, -detailed} into a single option with argument
Paul-Antoine Arras via Gcc-cvs <[email protected]>
| Newsgroups | gmane.comp.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://gcc.gnu.org/g:1da280a13bd0fed8801e4bdc95dcd0e780378df7 commit r17-3468-g1da280a13bd0fed8801e4bdc95dcd0e780378df7 Author: Paul-Antoine Arras <[email protected]> Date: Wed Aug 12 12:22:41 2026 +0200 openmp: Turn -fopenmp-ompt{,-detailed} into a single option with argument Replace the pair of boolean options -fopenmp-ompt and -fopenmp-ompt-detailed with a single -fopenmp-ompt[=level] option, where level is one of minimal (the previous default, i.e. neither option given), basic (the previous -fopenmp-ompt), or extended (the previous -fopenmp-ompt-detailed). Plain -fopenmp-ompt is an alias for -fopenmp-ompt=basic. This avoids the previous scheme in which -fopenmp-ompt-detailed silently implied -fopenmp-ompt, and makes it clearer that the levels are on an ordered scale rather than independent toggles. There is no -fno-openmp-ompt, since minimal detail is always available once -fopenmp is in effect. Also improve the documentation wording to emphasise the observable effect to the user rather than implementation details. gcc/ChangeLog: * common.opt (fopenmp-ompt): Turn into an alias for -fopenmp-ompt=basic. (fopenmp-ompt=): New option, replacing fopenmp-ompt{,-detailed}. * common.opt.urls: Regenerate. * doc/invoke.texi (-fopenmp-ompt): Document the new levels and drop -fopenmp-ompt-detailed. * flag-types.h (enum omp_ompt_level): New. * omp-expand.cc (expand_omp_for_static_nochunk, expand_omp_for_static_chunk): Check flag_openmp_ompt against OMP_OMPT_LEVEL_EXTENDED instead of flag_openmp_ompt_detailed. * opts.cc (finish_options): Adjust diagnostic for the removal of -fopenmp-ompt-detailed. libgomp/ChangeLog: * config/gcn/teams.c (GOMP_distribute_static_worksharing_start): Update comment. * config/nvptx/teams.c (GOMP_distribute_static_worksharing_start): Likewise. * loop.c (GOMP_loop_static_worksharing_start): Likewise. * teams.c (GOMP_distribute_static_worksharing_start): Likewise. * testsuite/libgomp.c-c++-common/for-static-3.c: Use -fopenmp-ompt=extended instead of -fopenmp-ompt-detailed. gcc/testsuite/ChangeLog: * c-c++-common/gomp/for-static-3.c: Use -fopenmp-ompt=extended instead of -fopenmp-ompt-detailed. * c-c++-common/gomp/openmp-ompt-1.c: Adjust expected diagnostic. * c-c++-common/gomp/openmp-ompt-2.c: Use -fopenmp-ompt=extended and adjust expected diagnostic. * c-c++-common/gomp/scan-8.c: Use -fopenmp-ompt=basic instead of -fopenmp-ompt. * c-c++-common/gomp/scope-7.c: Likewise. * c-c++-common/gomp/single2.c: Likewise. * c-c++-common/gomp/for-static-4.c: New test. * c-c++-common/gomp/openmp-ompt-3.c: New test. * c-c++-common/gomp/openmp-ompt-4.c: New test. Diff: --- gcc/common.opt | 21 ++++++-- gcc/common.opt.urls | 6 +-- gcc/doc/invoke.texi | 62 ++++++++++++++-------- gcc/flag-types.h | 8 +++ gcc/omp-expand.cc | 4 +- gcc/opts.cc | 7 +-- gcc/testsuite/c-c++-common/gomp/for-static-3.c | 4 +- gcc/testsuite/c-c++-common/gomp/for-static-4.c | 12 +++++ gcc/testsuite/c-c++-common/gomp/openmp-ompt-1.c | 2 +- gcc/testsuite/c-c++-common/gomp/openmp-ompt-2.c | 4 +- gcc/testsuite/c-c++-common/gomp/openmp-ompt-3.c | 4 ++ gcc/testsuite/c-c++-common/gomp/openmp-ompt-4.c | 4 ++ gcc/testsuite/c-c++-common/gomp/scan-8.c | 2 +- gcc/testsuite/c-c++-common/gomp/scope-7.c | 2 +- gcc/testsuite/c-c++-common/gomp/single2.c | 2 +- libgomp/config/gcn/teams.c | 2 +- libgomp/config/nvptx/teams.c | 2 +- libgomp/loop.c | 2 +- libgomp/teams.c | 2 +- .../testsuite/libgomp.c-c++-common/for-static-3.c | 4 +- 20 files changed, 106 insertions(+), 50 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index 1c6ad3aa4e5b..c5590f76ebb6 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2503,12 +2503,23 @@ Common Var(flag_omit_frame_pointer) Optimization When possible do not generate stack frames. fopenmp-ompt -Common Var(flag_openmp_ompt) EnabledBy(fopenmp-ompt-detailed) -Emit additional calls into libgomp, enabling OMPT callbacks before and after some OpenMP worksharing constructs. +Common Alias(fopenmp-ompt=,basic) RejectNegative -fopenmp-ompt-detailed -Common Var(flag_openmp_ompt_detailed) -Like -fopenmp-ompt, and emit additional calls into libgomp, enabling OMPT dispatch callbacks. +fopenmp-ompt= +Common Joined RejectNegative Enum(ompt_level) Var(flag_openmp_ompt) Init(OMP_OMPT_LEVEL_MINIMAL) +Control how much detail GCC reports to an OMPT tool. + +Enum +Name(ompt_level) Type(int) + +EnumValue +Enum(ompt_level) String(minimal) Value(OMP_OMPT_LEVEL_MINIMAL) + +EnumValue +Enum(ompt_level) String(basic) Value(OMP_OMPT_LEVEL_BASIC) + +EnumValue +Enum(ompt_level) String(extended) Value(OMP_OMPT_LEVEL_EXTENDED) fopenmp-target-simd-clone Common Alias(fopenmp-target-simd-clone=,any,none) diff --git a/gcc/common.opt.urls b/gcc/common.opt.urls index 567a8dfc2d6a..ab0f0bd872e8 100644 --- a/gcc/common.opt.urls +++ b/gcc/common.opt.urls @@ -1337,10 +1337,10 @@ fomit-frame-pointer UrlSuffix(gcc/Optimize-Options.html#index-fno-omit-frame-pointer) fopenmp-ompt -UrlSuffix(gcc/OpenMP-and-OpenACC-Options.html#index-fno-openmp-ompt) +UrlSuffix(gcc/OpenMP-and-OpenACC-Options.html#index-fopenmp-ompt) -fopenmp-ompt-detailed -UrlSuffix(gcc/OpenMP-and-OpenACC-Options.html#index-fno-openmp-ompt-detailed) +fopenmp-ompt= +UrlSuffix(gcc/OpenMP-and-OpenACC-Options.html#index-fopenmp-ompt) fopenmp-target-simd-clone UrlSuffix(gcc/OpenMP-and-OpenACC-Options.html#index-fno-openmp-target-simd-clone) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 01925ecf30d7..8f176d200d31 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -323,7 +323,7 @@ Objective-C and Objective-C++ Dialects}. @xref{OpenMP and OpenACC Options,,Options Controlling OpenMP and OpenACC}. @gccoptlist{-foffload=@var{arg} -foffload-options=@var{arg} -fopenacc -fopenacc-dim=@var{geom} --fopenmp -fopenmp-simd -fopenmp-ompt -fopenmp-ompt-detailed +-fopenmp -fopenmp-simd -fopenmp-ompt@r{[}=@var{level}@r{]} -fopenmp-target-simd-clone@r{[}=@var{device-type}@r{]}} @item Diagnostic Message Formatting Options @@ -5620,28 +5620,48 @@ Fortran. In fixed source form Fortran, the sentinels can also start with to the current task region, independent of the specified @code{bind} clause. @opindex fopenmp-ompt -@opindex fno-openmp-ompt @cindex OpenMP OMPT @item -fopenmp-ompt -For some OpenMP constructs, generate calls into the OpenMP runtime before and -after the region instead of only on region entry. For those constructs, the -additional calls are only needed to provide better tracing results in tools -using the OMPT interface and have a small overhead. The extra calls are -generated for the @code{masked}, @code{master}, @code{scope}, and @code{single} -constructs and with static scheduling for the @code{distribute} and worksharing -loop constructs. Requires @option{-fopenmp}. - -@opindex fopenmp-ompt-detailed -@opindex fno-openmp-ompt-detailed -@cindex OpenMP OMPT -@item -fopenmp-ompt-detailed -Add additional calls into the OpenMP runtime for more detailed tracing via OMPT, -which might have a measurable effect on the performance. The option enables -additional constructs to issue events for the @code{dispatch} callback, which -is invoked when beginning to execute a section or a collapsed iteration in a -@code{taskloop} or worksharing construct. The additional calls are generated -with static scheduling for the @code{distribute} and worksharing loop -constructs. Implies @option{-fopenmp-ompt} and requires @option{-fopenmp}. +@itemx -fopenmp-ompt=@var{level} +Control how much detail GCC reports to an @dfn{OMPT} tool---a tool +that registers callbacks with the OpenMP runtime to observe events +such as when a parallel region or worksharing construct starts and +ends. The @var{level} argument is one of @samp{minimal}, @samp{basic}, +or @samp{extended}; @option{-fopenmp-ompt} without an argument is +equivalent to @option{-fopenmp-ompt=basic}. OMPT support itself is +always present with @option{-fopenmp}; this option only changes how +much is reported and at what runtime cost. Requires +@option{-fopenmp}. + +@table @samp +@item minimal +The level used when @option{-fopenmp-ompt} is not specified. Some +OpenMP constructs are reported to an OMPT tool as a single combined +``encountered'' event, so a tool cannot tell how long the construct's +region actually ran. No extra runtime calls are generated beyond +what the construct's semantics already require. + +@item basic +For the @code{single}, @code{masked}, and @code{master} constructs, +and for @code{distribute} and worksharing-loop (@code{for}/@code{do}) +constructs that use static scheduling, GCC instead reports a separate +``begin'' event when the region is entered and an ``end'' event when +it is left. This lets an OMPT tool measure the time actually spent in +those regions, at the cost of one extra runtime call per region. + +@item extended +In addition to what @samp{basic} reports, report a ``dispatch'' event +each time a new chunk of loop iterations begins within a statically +scheduled @code{distribute} or worksharing-loop construct (a +@dfn{chunk} is the contiguous run of iterations handed to one thread +or team at a time). This lets an OMPT tool see how work is actually +split across threads, but adds a runtime call for every chunk, which +can be measurably slower for loops with many small chunks. +@end table + +There is no @option{-fno-openmp-ompt}: the lowest available level is +@option{-fopenmp-ompt=minimal}, since OMPT support cannot be disabled +outright once @option{-fopenmp} is in effect. @opindex fopenmp-target-simd-clone @opindex fno-openmp-target-simd-clone diff --git a/gcc/flag-types.h b/gcc/flag-types.h index 3d182785c824..df983d9d947f 100644 --- a/gcc/flag-types.h +++ b/gcc/flag-types.h @@ -585,6 +585,14 @@ enum omp_target_simd_clone_device_kind OMP_TARGET_SIMD_CLONE_ANY = 3 }; +/* Levels for -fopenmp-ompt. */ +enum omp_ompt_level +{ + OMP_OMPT_LEVEL_MINIMAL = 0, + OMP_OMPT_LEVEL_BASIC = 1, + OMP_OMPT_LEVEL_EXTENDED = 2 +}; + #endif #endif /* ! GCC_FLAG_TYPES_H */ diff --git a/gcc/omp-expand.cc b/gcc/omp-expand.cc index 50b9d9817d0c..d3eb3d9fa329 100644 --- a/gcc/omp-expand.cc +++ b/gcc/omp-expand.cc @@ -5644,7 +5644,7 @@ expand_omp_for_static_nochunk (struct omp_region *region, cont_bb, body_bb); } - if (flag_openmp_ompt_detailed) + if (flag_openmp_ompt == OMP_OMPT_LEVEL_EXTENDED) { /* Insert call to GOMP_*_static_worksharing_dispatch at the end of seq_start_bb. */ @@ -6492,7 +6492,7 @@ expand_omp_for_static_chunk (struct omp_region *region, } gsi_remove (&gsi, true); - if (flag_openmp_ompt_detailed) + if (flag_openmp_ompt == OMP_OMPT_LEVEL_EXTENDED) { /* Insert call to GOMP_*_static_worksharing_dispatch at the end of seq_start_bb. */ diff --git a/gcc/opts.cc b/gcc/opts.cc index 88d533c66417..7eabab9b2e12 100644 --- a/gcc/opts.cc +++ b/gcc/opts.cc @@ -1537,11 +1537,8 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set, " %<-fstrict-flex-arrays%> is not present"); } - if ((opts->x_flag_openmp_ompt || opts->x_flag_openmp_ompt_detailed) - && !opts->x_flag_openmp) - error_at ( - loc, - "%<-fopenmp-ompt%> and %<-fopenmp-ompt-detailed%> require %<-fopenmp%>"); + if (opts->x_flag_openmp_ompt && !opts->x_flag_openmp) + error_at (loc, "%<-fopenmp-ompt%> requires %<-fopenmp%>"); diagnose_options (opts, opts_set, loc); } diff --git a/gcc/testsuite/c-c++-common/gomp/for-static-3.c b/gcc/testsuite/c-c++-common/gomp/for-static-3.c index a5cf680a9465..8164c3894bf7 100644 --- a/gcc/testsuite/c-c++-common/gomp/for-static-3.c +++ b/gcc/testsuite/c-c++-common/gomp/for-static-3.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ -/* { dg-additional-options "-fopenmp-ompt-detailed -fdump-tree-ompexp" } */ +/* { dg-additional-options "-fopenmp-ompt=extended -fdump-tree-ompexp" } */ -/* Check that, with -fopenmp-ompt-detailed, _dispatch builtins are called along +/* Check that, with -fopenmp-ompt=extended, _dispatch builtins are called along with the _start and _end variants. */ #include "for-static.h" diff --git a/gcc/testsuite/c-c++-common/gomp/for-static-4.c b/gcc/testsuite/c-c++-common/gomp/for-static-4.c new file mode 100644 index 000000000000..ceed535fe1ff --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/for-static-4.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fopenmp-ompt -fopenmp-ompt=minimal -fdump-tree-ompexp" } */ + +/* Check that minimal OMPT callbacks are generated (same as for-static-1.c). */ + +#include "for-static.h" + +/* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing \\(\[^\\)\]" 2 "ompexp" } } */ +/* { dg-final { scan-tree-dump-not "GOMP_loop_static_worksharing_start" "ompexp" } } */ +/* { dg-final { scan-tree-dump-not "GOMP_loop_static_worksharing_dispatch" "ompexp" } } */ +/* { dg-final { scan-tree-dump-not "GOMP_loop_static_worksharing_end" "ompexp" } } */ +/* { dg-final { scan-tree-dump-times "GOMP_distribute_static_worksharing \\(\[^\\)\]" 2 "ompexp" } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/openmp-ompt-1.c b/gcc/testsuite/c-c++-common/gomp/openmp-ompt-1.c index 0a45c2bd52c9..7231d95c50b7 100644 --- a/gcc/testsuite/c-c++-common/gomp/openmp-ompt-1.c +++ b/gcc/testsuite/c-c++-common/gomp/openmp-ompt-1.c @@ -1,4 +1,4 @@ /* { dg-do compile } */ /* { dg-options "-fopenmp-ompt" } */ -/* { dg-error ".-fopenmp-ompt. and .-fopenmp-ompt-detailed. require .-fopenmp." "" { target *-*-* } 0 } */ +/* { dg-error ".-fopenmp-ompt. requires .-fopenmp." "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/c-c++-common/gomp/openmp-ompt-2.c b/gcc/testsuite/c-c++-common/gomp/openmp-ompt-2.c index f93f69203274..753de82a66e7 100644 --- a/gcc/testsuite/c-c++-common/gomp/openmp-ompt-2.c +++ b/gcc/testsuite/c-c++-common/gomp/openmp-ompt-2.c @@ -1,4 +1,4 @@ /* { dg-do compile } */ -/* { dg-options "-fopenmp-ompt-detailed" } */ +/* { dg-options "-fopenmp-ompt=extended" } */ -/* { dg-error ".-fopenmp-ompt. and .-fopenmp-ompt-detailed. require .-fopenmp." "" { target *-*-* } 0 } */ +/* { dg-error ".-fopenmp-ompt. requires .-fopenmp." "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/c-c++-common/gomp/openmp-ompt-3.c b/gcc/testsuite/c-c++-common/gomp/openmp-ompt-3.c new file mode 100644 index 000000000000..66c3da6912bb --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/openmp-ompt-3.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-openmp-ompt" } */ + +/* { dg-error "unrecognized command-line option .-fno-openmp-ompt." "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/c-c++-common/gomp/openmp-ompt-4.c b/gcc/testsuite/c-c++-common/gomp/openmp-ompt-4.c new file mode 100644 index 000000000000..86f43fdbc081 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/openmp-ompt-4.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-openmp-ompt=none" } */ + +/* { dg-error "unrecognized command-line option .-fno-openmp-ompt=none." "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/c-c++-common/gomp/scan-8.c b/gcc/testsuite/c-c++-common/gomp/scan-8.c index cff8c03b3495..c014e448fe0d 100644 --- a/gcc/testsuite/c-c++-common/gomp/scan-8.c +++ b/gcc/testsuite/c-c++-common/gomp/scan-8.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-additional-options "-fopenmp-ompt -fdump-tree-ompexp" } */ +/* { dg-additional-options "-fopenmp-ompt=basic -fdump-tree-ompexp" } */ /* Check that an extra, OMPT variant of GOMP_loop_end is not emitted when the inscan modifier is present on the for construct. */ diff --git a/gcc/testsuite/c-c++-common/gomp/scope-7.c b/gcc/testsuite/c-c++-common/gomp/scope-7.c index 9db2fd1053cb..3a6616f53320 100644 --- a/gcc/testsuite/c-c++-common/gomp/scope-7.c +++ b/gcc/testsuite/c-c++-common/gomp/scope-7.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-additional-options "-fopenmp-ompt -fdump-tree-omplower" } */ +/* { dg-additional-options "-fopenmp-ompt=basic -fdump-tree-omplower" } */ /* Check that OMPT variants of libgomp calls are emitted for the scope construct, both with and without a task reduction clause. */ diff --git a/gcc/testsuite/c-c++-common/gomp/single2.c b/gcc/testsuite/c-c++-common/gomp/single2.c index 215f0368ce4f..2622e03cef4d 100644 --- a/gcc/testsuite/c-c++-common/gomp/single2.c +++ b/gcc/testsuite/c-c++-common/gomp/single2.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-additional-options "-fopenmp-ompt -fdump-tree-ompexp" } */ +/* { dg-additional-options "-fopenmp-ompt=basic -fdump-tree-ompexp" } */ void foo (void) diff --git a/libgomp/config/gcn/teams.c b/libgomp/config/gcn/teams.c index f748d0db1a4e..2bb55c1e2d81 100644 --- a/libgomp/config/gcn/teams.c +++ b/libgomp/config/gcn/teams.c @@ -64,7 +64,7 @@ GOMP_distribute_static_worksharing_start (unsigned long long niter return nteams + tid * 1I; } -/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed. START is the +/* Stub for OMPT callback enabled by -fopenmp-ompt=extended. START is the starting index of the chunk in the logical iteration space. ITERATIONS is the number of iterations in the chunk. */ diff --git a/libgomp/config/nvptx/teams.c b/libgomp/config/nvptx/teams.c index 15a3fe5c3178..2ff5200845fe 100644 --- a/libgomp/config/nvptx/teams.c +++ b/libgomp/config/nvptx/teams.c @@ -65,7 +65,7 @@ GOMP_distribute_static_worksharing_start (unsigned long long niter return nteams + tid * 1I; } -/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed. START is the +/* Stub for OMPT callback enabled by -fopenmp-ompt=extended. START is the starting index of the chunk in the logical iteration space. ITERATIONS is the number of iterations in the chunk. */ diff --git a/libgomp/loop.c b/libgomp/loop.c index 7474279fcd62..ce0073966582 100644 --- a/libgomp/loop.c +++ b/libgomp/loop.c @@ -1214,7 +1214,7 @@ GOMP_loop_static_worksharing_start (unsigned long long niter return nthreads + tid * 1I; } -/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed. START is the +/* Stub for OMPT callback enabled by -fopenmp-ompt=extended. START is the starting index of the chunk in the logical iteration space. ITERATIONS is the number of iterations in the chunk. */ diff --git a/libgomp/teams.c b/libgomp/teams.c index 817d24029106..3d7f5e9a784b 100644 --- a/libgomp/teams.c +++ b/libgomp/teams.c @@ -84,7 +84,7 @@ GOMP_distribute_static_worksharing_start (unsigned long long return nteams + tid * 1I; } -/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed. START is the +/* Stub for OMPT callback enabled by -fopenmp-ompt=extended. START is the starting index of the chunk in the logical iteration space. ITERATIONS is the number of iterations in the chunk. */ diff --git a/libgomp/testsuite/libgomp.c-c++-common/for-static-3.c b/libgomp/testsuite/libgomp.c-c++-common/for-static-3.c index 1f6922fd2257..3ded366cc140 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/for-static-3.c +++ b/libgomp/testsuite/libgomp.c-c++-common/for-static-3.c @@ -1,7 +1,7 @@ /* { dg-do link { target offload_target_any } } */ -/* { dg-additional-options "-O0 -foffload=-fdump-tree-optimized -fopenmp-ompt-detailed" } */ +/* { dg-additional-options "-O0 -foffload=-fdump-tree-optimized -fopenmp-ompt=extended" } */ -/* Check that, with -fopenmp-ompt-detailed, _dispatch builtins are called along +/* Check that, with -fopenmp-ompt=extended, _dispatch builtins are called along with the _start and _end variants. */ #include "for-static.h"