[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2022-01-06 Thread ygribov at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

Yury Gribov  changed:

   What|Removed |Added

 CC||ygribov at gcc dot gnu.org

--- Comment #29 from Yury Gribov  ---
> > 1. it can only merge two directories at one time. So, for multiple
> > directories, for example "n", we have to invoke gcov-tool merge n-1 times in
> > order to merge all of them?
> 
> Yep. I guess one can write a simple bash script that does that.

I've added one at
https://github.com/yugr/maintainer-scripts/blob/master/gcov-tool-many

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2019-05-02 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #28 from Martin Liška  ---
(In reply to Martin Liška from comment #26)
> (In reply to qinzhao from comment #25)
> > (In reply to Martin Liška from comment #24)
> > > 
> > > > How about the patch for the above 2? has it been committed?
> > > 
> > > It has been there for a while, please take a look at:
> > > 
> > > $ gcov-tool merge --help
> > > merge: unrecognized option '--help'
> > > Merge subcomand usage:  merge [options]   Merge 
> > > coverage
> > > file contents
> > > -o, --output   Output directory
> > > -v, --verbose   Verbose mode
> > > -w, --weight Set weights (float point values)
> > 
> > two more questions on this merge tool:
> > 1. it can only merge two directories at one time. So, for multiple
> > directories, for example "n", we have to invoke gcov-tool merge n-1 times in
> > order to merge all of them?
> 
> Yep. I guess one can write a simple bash script that does that.
> 
> > 2. Intel compiler (icc)'s profmerge is able to merge all the .dyn files
> > under one directory, does gcc have such functionality currently?
> 
> We have folder-base merging where we search for all .gcda files and we merge
> them to a destination folder.

$ echo "int main() {return 0;}" >> main.c && gcc --coverage main.c && ./a.out
$ mkdir a && mkdir b && cp main.gcda c && cp main.gcda b
$ gcov-tool merge a b -o a+b -v
reading file: ./main.gcda
tag one function id=108032747
reading file: ./main.gcda
tag one function id=108032747

$ ls a+b
main.gcda

$ gcov-dump a+b/main.gcda 
a+b/main.gcda:data:magic `gcda':version `A83*'
a+b/main.gcda:stamp 2031787297
a+b/main.gcda:  a300:  22:PROGRAM_SUMMARY checksum=0x33c369a8
a+b/main.gcda:counts=1, runs=1, sum_all=2, run_max=2, sum_max=2
a+b/main.gcda:counter histogram:
a+b/main.gcda: 2: num counts=1, min counter=2, cum_counter=2
a+b/main.gcda:  0100:   3:FUNCTION ident=108032747,
lineno_checksum=0x3b5ee2be, cfg_checksum=0xdb5de9e8
a+b/main.gcda:01a1:   2:COUNTERS arcs 1 counts

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2019-05-02 Thread qing.zhao at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #27 from Qing Zhao  ---
> --- Comment #26 from Martin Liška  ---
> 
>> 2. Intel compiler (icc)'s profmerge is able to merge all the .dyn files
>> under one directory, does gcc have such functionality currently?
> 
> We have folder-base merging where we search for all .gcda files and we merge
> them to a destination folder.

could you please point me which command does this? thanks.

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2019-05-02 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #26 from Martin Liška  ---
(In reply to qinzhao from comment #25)
> (In reply to Martin Liška from comment #24)
> > 
> > > How about the patch for the above 2? has it been committed?
> > 
> > It has been there for a while, please take a look at:
> > 
> > $ gcov-tool merge --help
> > merge: unrecognized option '--help'
> > Merge subcomand usage:  merge [options]   Merge coverage
> > file contents
> > -o, --output   Output directory
> > -v, --verbose   Verbose mode
> > -w, --weight Set weights (float point values)
> 
> two more questions on this merge tool:
> 1. it can only merge two directories at one time. So, for multiple
> directories, for example "n", we have to invoke gcov-tool merge n-1 times in
> order to merge all of them?

Yep. I guess one can write a simple bash script that does that.

> 2. Intel compiler (icc)'s profmerge is able to merge all the .dyn files
> under one directory, does gcc have such functionality currently?

We have folder-base merging where we search for all .gcda files and we merge
them to a destination folder.

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2019-04-30 Thread qinzhao at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #25 from qinzhao at gcc dot gnu.org ---
(In reply to Martin Liška from comment #24)
> 
> > How about the patch for the above 2? has it been committed?
> 
> It has been there for a while, please take a look at:
> 
> $ gcov-tool merge --help
> merge: unrecognized option '--help'
> Merge subcomand usage:  merge [options]   Merge coverage
> file contents
> -o, --output   Output directory
> -v, --verbose   Verbose mode
> -w, --weight Set weights (float point values)

two more questions on this merge tool:
1. it can only merge two directories at one time. So, for multiple directories,
for example "n", we have to invoke gcov-tool merge n-1 times in order to merge
all of them?
2. Intel compiler (icc)'s profmerge is able to merge all the .dyn files under
one directory, does gcc have such functionality currently?

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2019-04-25 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #24 from Martin Liška  ---
(In reply to qinzhao from comment #23)
> (In reply to Andrew Pinski from comment #7)
> > Created attachment 27869 [details]
> > Patch for adding merge-gcda
> > 
> > here is the patch which adds merge-gcda .  I don't add any testcases as it
> > is currently designed only for how Cavium's Simple-exec works in that each
> > core writes out its own gcda file.
> 
> I recently found this bug due to a similar problem. looks like that there
> are two parts of work for this problem:
> 
> 1. GCC's new feature to guarantee that all pre-merged files are saved with
> different names for different instances of the same process. 
> 2. a merge tool to merge all the gcda files afterwards. 
> 
> from my understanding, the patch for the above 1 has been committed into
> GCC9.

Yes.

> How about the patch for the above 2? has it been committed?

It has been there for a while, please take a look at:

$ gcov-tool merge --help
merge: unrecognized option '--help'
Merge subcomand usage:  merge [options]   Merge coverage
file contents
-o, --output   Output directory
-v, --verbose   Verbose mode
-w, --weight Set weights (float point values)

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2019-04-24 Thread qinzhao at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

qinzhao at gcc dot gnu.org changed:

   What|Removed |Added

 CC||qinzhao at gcc dot gnu.org

--- Comment #23 from qinzhao at gcc dot gnu.org ---
(In reply to Andrew Pinski from comment #7)
> Created attachment 27869 [details]
> Patch for adding merge-gcda
> 
> here is the patch which adds merge-gcda .  I don't add any testcases as it
> is currently designed only for how Cavium's Simple-exec works in that each
> core writes out its own gcda file.

I recently found this bug due to a similar problem. looks like that there are
two parts of work for this problem:

1. GCC's new feature to guarantee that all pre-merged files are saved with
different names for different instances of the same process. 
2. a merge tool to merge all the gcda files afterwards. 

from my understanding, the patch for the above 1 has been committed into GCC9.
How about the patch for the above 2? has it been committed?

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2018-06-05 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

Martin Liška  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #22 from Martin Liška  ---
Implemented.

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2018-06-05 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #21 from Martin Liška  ---
Author: marxin
Date: Tue Jun  5 12:10:22 2018
New Revision: 261199

URL: https://gcc.gnu.org/viewcvs?rev=261199=gcc=rev
Log:
Support variables in expansion of -fprofile-generate option (PR
gcov-profile/47618).

2018-06-05  Martin Liska  

PR gcov-profile/47618
* doc/invoke.texi: Document how -fprofile-dir format
is extended.
2018-06-05  Martin Liska  

PR gcov-profile/47618
* libgcov-driver-system.c (replace_filename_variables): New
function.
(gcov_exit_open_gcda_file): Use it.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/doc/invoke.texi
trunk/libgcc/ChangeLog
trunk/libgcc/libgcov-driver-system.c

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2018-02-19 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

Martin Liška  changed:

   What|Removed |Added

   Target Milestone|--- |9.0

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2018-01-03 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #20 from Martin Liška  ---
(In reply to Petr Špaček from comment #19)
> Sure, I would be happy with any version, thank you!
> 
> For people who want to generate code coverage reports for parallel
> executions, beware of https://github.com/linux-test-project/lcov/issues/37.

Good. I will do it in timeframe of stage1 of GCC 9.

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2018-01-02 Thread petr.spacek at nic dot cz
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #19 from Petr Špaček  ---
Sure, I would be happy with any version, thank you!

For people who want to generate code coverage reports for parallel executions,
beware of https://github.com/linux-test-project/lcov/issues/37.

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2017-12-27 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

Martin Liška  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |marxin at gcc dot 
gnu.org

--- Comment #18 from Martin Liška  ---
(In reply to Petr Špaček from comment #17)
> I found this bug while searching for a way to solve exactly this problem, so
> for the record: It sounds like very good and useful addition. Thank you!

Good to hear. Unfortunately the patch will be possible to land in GCC 9.x.
Is it acceptable for you?

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2017-12-23 Thread petr.spacek at nic dot cz
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #17 from Petr Špaček  ---
I found this bug while searching for a way to solve exactly this problem, so
for the record: It sounds like very good and useful addition. Thank you!

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2017-11-09 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

Martin Liška  changed:

   What|Removed |Added

   Assignee|marxin at gcc dot gnu.org  |unassigned at gcc dot 
gnu.org

--- Comment #16 from Martin Liška  ---
I see any feedback, leaving the PR then ...

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2017-06-07 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

Martin Liška  changed:

   What|Removed |Added

 CC||pinskia at gcc dot gnu.org

--- Comment #15 from Martin Liška  ---
Adding Andrew, may I ask you for your opinion about suggested patch/approach?

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2017-06-06 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #14 from Martin Liška  ---
Created attachment 41481
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41481=edit
Patch candidate

I'm attaching patch that supports following expansion of -fprofile-dir (or
arguments of -fprofile-generate and -fprofile-use) option value:

%w - expands during compile time to working directory; it's handy when one
wants to preserve tree hierarchy of gcda files corresponding to another build
directory
%p - expands during run-time to PID
%q{ENV} - expands to value of environmental variable 'ENV' during run-time

Having that, I guess we can eventually drop GCOV_PREFIX_STRIP and GCOV_PREFIX
as one can use -fprofile-dir="%q{PREFIX}" and then e.g. set
PREFIX="../my/folder/".

Feel free to comment the patch.

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2017-04-13 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

Martin Liška  changed:

   What|Removed |Added

 CC||marxin at gcc dot gnu.org

--- Comment #13 from Martin Liška  ---
The issue is quite old, however it's probably still valid. Implementing similar
to what valgrind does with '%p' and '%q{VAR}' is elegant solution. I can work
on that for GCC8 when there's an interest?

[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2012-07-25 Thread steven at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #12 from Steven Bosscher steven at gcc dot gnu.org 2012-07-25 
08:24:49 UTC ---
(In reply to comment #9)
 I think a tool to merge would be a good partial solution.

We will go with the tool solution. I'll take care of the tool before GCC 4.8,
if that's OK with apinski.

I think we shouldn't have a new tool, though. I'd prefer to teach the gcov
program to do it instead. What would you prefer?


 As far as I can see what would still be missing for user-friendly usage, is a
 mechanism to guarantee that all pre-merged files are saved with different
 names, so that different processes don't overwrite each others output files.

Deeply berried in the GCC manuals is this section:
http://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Cross_002dprofiling.html

With the right combination of GCOV_PREFIX_STRIP and GCOV_PREFIX, it should be
possible to send the gcda files to unique directories per MPI rank. But I think
that a more practical solution is necessary. (I also don't know how these
environment variables interact with -profile-dir. I doubt anyone looked into
this before now...)

I like the %q (and %p) variables from Valgrind, and I don't think it's very
hard to add support for them in libgcov.
(http://valgrind.org/docs/manual/manual-core.html)


[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2012-07-24 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #7 from Andrew Pinski pinskia at gcc dot gnu.org 2012-07-24 
22:12:44 UTC ---
Created attachment 27869
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=27869
Patch for adding merge-gcda

here is the patch which adds merge-gcda .  I don't add any testcases as it is
currently designed only for how Cavium's Simple-exec works in that each core
writes out its own gcda file.


[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2012-07-24 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #8 from Andrew Pinski pinskia at gcc dot gnu.org 2012-07-24 
23:20:14 UTC ---
(In reply to comment #7)
 Created attachment 27869 [details]
 Patch for adding merge-gcda

I am changing the copyright over to the FSF based on the fact Cavium (Networks)
has a blanket copyright assignment in place.  I just forgot to do it in the
patch itself.


[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2012-07-24 Thread roland at rschulz dot eu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #9 from Roland Schulz roland at rschulz dot eu 2012-07-24 
23:52:41 UTC ---
I think a tool to merge would be a good partial solution.

As far as I can see what would still be missing for user-friendly usage, is a
mechanism to guarantee that all pre-merged files are saved with different
names, so that different processes don't overwrite each others output files. In
the case of MPI one would want to have the mpi rank as part of the output
folder to guarantee unique file names. Thus my suggestion to support
-fprofile-dir /some/path/%q{SOME_ENV}, where SOME_ENV would be the environment
variable containing the mpi rank. Without being able to make the output path
depending on a environment variable one would be required to write some wrapper
scripts and that might not even be possible in all cases.


[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2012-07-24 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #10 from Andrew Pinski pinskia at gcc dot gnu.org 2012-07-25 
00:05:40 UTC ---
 so that different processes don't overwrite each others output files. 

They don't overwrite each other, rather they are merged together at write out
time.


[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2012-07-24 Thread roland at rschulz dot eu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #11 from Roland Schulz roland at rschulz dot eu 2012-07-25 
00:50:30 UTC ---
Steven wrote that they are not merged but that race conditions occur. That is
also what I observed. To clarify: Message Passing Interface (MPI) is a
parallelization method which executes the same binary multiple times in
parallel (with support for messages for communication). Allowing to merge the
output into one file at runtime would require file-locking (often over network
file-systems) and would not scale because MPI applications are often used with
more than 1 (or even 1M) parallel processes simultaneous.


[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2012-07-22 Thread xunxun1982 at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

xunxun xunxun1982 at gmail dot com changed:

   What|Removed |Added

 CC||xunxun1982 at gmail dot com

--- Comment #3 from xunxun xunxun1982 at gmail dot com 2012-07-22 06:56:11 
UTC ---
(In reply to comment #1)
 A tool to merge multiple gcda files shoulnd't be very difficult to write. I
 don't think this should be done by the compiler itself, that would greatly
 complicate things. But a separate tool, gcov-merge say, would work, and this
 isn't a big job to create using libgcov (and gcov-dump as an example). You'd
 also be able to merge profile information from different directories.
 
 Would something like the above work for you?

But for VC and Intel Compiler

they can auto merge all PGO information.

Will we make gcc to have the similar behavior?


[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2012-07-22 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #4 from Andrew Pinski pinskia at gcc dot gnu.org 2012-07-22 
07:06:47 UTC ---
-fprofile-dir= is already implemented.


[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2012-07-22 Thread steven at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #5 from Steven Bosscher steven at gcc dot gnu.org 2012-07-22 
10:23:37 UTC ---
(In reply to comment #3)
 (In reply to comment #1)
  A tool to merge multiple gcda files shoulnd't be very difficult to write. I
  don't think this should be done by the compiler itself, that would greatly
  complicate things. But a separate tool, gcov-merge say, would work, and this
  isn't a big job to create using libgcov (and gcov-dump as an example). You'd
  also be able to merge profile information from different directories.
  
  Would something like the above work for you?
 
 But for VC and Intel Compiler
 
 they can auto merge all PGO information.
 
 Will we make gcc to have the similar behavior?

xunxun,

GCC does merge profile information from different runs into one gcda file. It
works differently from ICC in that ICC produces one .dyn file per test run and
uses prof_merge to generate merge multiple .dyn files into a summary file. GCC
does this merging from multiple runs automatically.

What GCC does not do, is merge multiple gcda files (which would be the
equivalent of merging multiple pgopti.dpi files with ICC).

The issue in this problem report, is that with MPI there will be multiple
images of the same program running simultaneously. The different images can't
share the same set of gcda files (you'd have races) so each image generates its
own set of gcda files. For that, a new merge tool is necessary.

Ideally, this tool would also run transparently. One way to do this could be to
take multiple arguments for -fprofile-dir and merge profile info from each
directory.


[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2012-07-22 Thread steven at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #6 from Steven Bosscher steven at gcc dot gnu.org 2012-07-22 
10:46:30 UTC ---
(In reply to comment #2)
 We have one internally at Cavium which is designed to run afterwards and merge
 a few gcda file.  It is designed for how we run multi-core programs and write 
 a
 gcda file for each run.

And now, of course, you're going to contribute that? ;-)


 And there one here:
 http://gcc.gnu.org/ml/gcc-patches/2007-06/msg00423.html

This merges results for files without their own gcno file but mentioned more
than once in gcda files for multiple source files (e.g. for inline functions in
headers). You can't merge multiple gcda files for one source file, but the
patch does provide the infrastructure to support this.


[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2012-07-21 Thread steven at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

Steven Bosscher steven at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2012-07-21
 CC||steven at gcc dot gnu.org
 Ever Confirmed|0   |1

--- Comment #1 from Steven Bosscher steven at gcc dot gnu.org 2012-07-21 
23:57:18 UTC ---
A tool to merge multiple gcda files shoulnd't be very difficult to write. I
don't think this should be done by the compiler itself, that would greatly
complicate things. But a separate tool, gcov-merge say, would work, and this
isn't a big job to create using libgcov (and gcov-dump as an example). You'd
also be able to merge profile information from different directories.

Would something like the above work for you?


[Bug gcov-profile/47618] Collecting multiple profiles and using all for PGO

2012-07-21 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47618

--- Comment #2 from Andrew Pinski pinskia at gcc dot gnu.org 2012-07-22 
00:42:28 UTC ---
We have one internally at Cavium which is designed to run afterwards and merge
a few gcda file.  It is designed for how we run multi-core programs and write a
gcda file for each run.

And there one here:
http://gcc.gnu.org/ml/gcc-patches/2007-06/msg00423.html