public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Question about -fbranch-probabilities
@ 2008-08-22 18:29 David Bruant
  2008-08-22 19:35 ` Brian Dessent
  0 siblings, 1 reply; 2+ messages in thread
From: David Bruant @ 2008-08-22 18:29 UTC (permalink / raw)
  To: gcc-help

Hi !

I'm David Bruant, I'm french, so sorry if my english is not perfect.
Here is my problem
On the manual chap 3 page 99 (111 of the pdf document), there are
explanations about -fbranch-probabilities :

"After running a program compiled with ‘-fprofile-arcs’ (see Section 3.9
[Options for Debugging Your Program or gcc], page 63), you can compile
it a second time using ‘-fbranch-probabilities’, to improve
optimizations based on the number of times each branch was taken. When
the program compiled with ‘-fprofile-arcs’ exits it saves arc execution
counts to a file called ‘sourcename.gcda’ for each source file. The
information in this data file is very dependent on the structure of the
generated code, so you must use the same source code and the same
optimization options for both compilations."

And I've got a problem with the "When the program compiled with
‘-fprofile-arcs’ exits" because I am running a backtrack algorithm which
is not going to exit before the end of the universe, but I would be
interested to have a (very) good solution (or at least the beginning of
one) of my problem before my death, that's why I would like to improve
its speed thanks to -profile-arcs and -fbranch-probabilities.

I have had an idea which would be to force the end of the algorithm
thanks to a variable which would end it after 2 hours (for example).
This way, -fprofile-arcs would have a wide enough sample to improve with
-fbranch-probabilities, but the "you must use the same source code"
frightens me because if I add a variable to measure time, it's obviously
not the same source code.
So, could anyone tell me more about the restrictions of -fprofile-arcs
and if my idea is a good one ?

Thanks

David Bruant

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Question about -fbranch-probabilities
  2008-08-22 18:29 Question about -fbranch-probabilities David Bruant
@ 2008-08-22 19:35 ` Brian Dessent
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Dessent @ 2008-08-22 19:35 UTC (permalink / raw)
  To: David Bruant; +Cc: gcc-help

David Bruant wrote:

> I have had an idea which would be to force the end of the algorithm
> thanks to a variable which would end it after 2 hours (for example).
> This way, -fprofile-arcs would have a wide enough sample to improve with
> -fbranch-probabilities, but the "you must use the same source code"
> frightens me because if I add a variable to measure time, it's obviously
> not the same source code.

You could simply install a signal handler that responds to SIGUSR1 or
something and terminates gracefully.  Then you can terminate or leave
running indefinitely your application at will without any source level
changes.

Brian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-22 18:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-22 18:29 Question about -fbranch-probabilities David Bruant
2008-08-22 19:35 ` Brian Dessent

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).