public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* -fprofile-arcs
@ 2005-07-18 14:10 Rajkishore Barik
  2005-07-18 14:31 ` -fprofile-arcs Jan Hubicka
  0 siblings, 1 reply; 6+ messages in thread
From: Rajkishore Barik @ 2005-07-18 14:10 UTC (permalink / raw)
  To: gcc

Hi,

I am trying to profile the frequency of each basic block of 
SPEC 2000 benchmarks by compiling them using -fprofile-arcs and opt -O3.
After running the benchmark, when I try to read "bb->count" while 
compiling
using "-fbranch-probabilities and -O3", I get "0" values for basic blocks
which were known to execute for sure. Any clue as to where I am missing?
Is "bb->count" is the right way to get the dynamic frequency in the second 
pass?

regards,
Raj

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

* Re: -fprofile-arcs
  2005-07-18 14:10 -fprofile-arcs Rajkishore Barik
@ 2005-07-18 14:31 ` Jan Hubicka
  2005-07-18 15:07   ` -fprofile-arcs Rajkishore Barik
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Hubicka @ 2005-07-18 14:31 UTC (permalink / raw)
  To: Rajkishore Barik; +Cc: gcc

> Hi,
> 
> I am trying to profile the frequency of each basic block of 
> SPEC 2000 benchmarks by compiling them using -fprofile-arcs and opt -O3.
> After running the benchmark, when I try to read "bb->count" while 
> compiling
> using "-fbranch-probabilities and -O3", I get "0" values for basic blocks
> which were known to execute for sure. Any clue as to where I am missing?
> Is "bb->count" is the right way to get the dynamic frequency in the second 
> pass?

It is.  You would need to provide more information for me to figure out
what is going wrong.  Of course the bb->count is initialized only after
profile is read in that at current mainline is pretty late in
compilation queue (after bp RTL pass), but this is going to change
hopefully at monday.

Honza
> 
> regards,
> Raj

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

* Re: -fprofile-arcs
  2005-07-18 14:31 ` -fprofile-arcs Jan Hubicka
@ 2005-07-18 15:07   ` Rajkishore Barik
  2005-07-20  8:09     ` -fprofile-arcs Jan Hubicka
  0 siblings, 1 reply; 6+ messages in thread
From: Rajkishore Barik @ 2005-07-18 15:07 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc

Hi,

Thanks a lot. Basically, I want to obtain dynamic basic block frequency at 
RTL
level just before register allocation. Look at the following piece of 
code(a.c):

void foo(int i, int *a, int *p) {
  int x1,j;
  for(j=0;j<200;j++) {
    x1=a[i]+j;
    *p=99;
    a[i]=x1;
  }
}

main() {
  int *a,*p,i=0;
  int x1,x2,x3,x4;
  a=malloc(sizeof(int));
  p=malloc(sizeof(int));
  a[0]=0;
  foo(0,a,p);
  printf("\n%d ",*p);
  for(i=0;i<1;i++) {
    printf(" %d ",a[i]);
  }
}

This code was executed using "gcc -O3 -fprofile-arcs --param 
max-unroll-times=0 a.c".
"a.out" was then executed (for profiling).
Now I compile using "gcc -O3 -fbranch-probabilities --param 
max-unroll-times=0 a.c".
During this phase, I try to obtain dynamic frequencies of the statements 
within the "for"
loop in "foo" method at RTL level. The frequencies return "0" using 
"bb->count". I 
would like this to reflect "200". How to obtain this information?

regards,
Raj







Jan Hubicka <hubicka@ucw.cz> 
07/18/2005 10:29 AM

To
Rajkishore Barik/India/IBM@IBMIN
cc
gcc@gcc.gnu.org
Subject
Re: -fprofile-arcs






> Hi,
> 
> I am trying to profile the frequency of each basic block of 
> SPEC 2000 benchmarks by compiling them using -fprofile-arcs and opt -O3.
> After running the benchmark, when I try to read "bb->count" while 
> compiling
> using "-fbranch-probabilities and -O3", I get "0" values for basic 
blocks
> which were known to execute for sure. Any clue as to where I am missing?
> Is "bb->count" is the right way to get the dynamic frequency in the 
second 
> pass?

It is.  You would need to provide more information for me to figure out
what is going wrong.  Of course the bb->count is initialized only after
profile is read in that at current mainline is pretty late in
compilation queue (after bp RTL pass), but this is going to change
hopefully at monday.

Honza
> 
> regards,
> Raj


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

* Re: -fprofile-arcs
  2005-07-18 15:07   ` -fprofile-arcs Rajkishore Barik
@ 2005-07-20  8:09     ` Jan Hubicka
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Hubicka @ 2005-07-20  8:09 UTC (permalink / raw)
  To: Rajkishore Barik; +Cc: Jan Hubicka, gcc

> Hi,
> 
> Thanks a lot. Basically, I want to obtain dynamic basic block frequency at 
> RTL
> level just before register allocation. Look at the following piece of 
> code(a.c):
> 
> void foo(int i, int *a, int *p) {
>   int x1,j;
>   for(j=0;j<200;j++) {
>     x1=a[i]+j;
>     *p=99;
>     a[i]=x1;
>   }
> }
> 
> main() {
>   int *a,*p,i=0;
>   int x1,x2,x3,x4;
>   a=malloc(sizeof(int));
>   p=malloc(sizeof(int));
>   a[0]=0;
>   foo(0,a,p);
>   printf("\n%d ",*p);
>   for(i=0;i<1;i++) {
>     printf(" %d ",a[i]);
>   }
> }
> 
> This code was executed using "gcc -O3 -fprofile-arcs --param 
> max-unroll-times=0 a.c".
> "a.out" was then executed (for profiling).
> Now I compile using "gcc -O3 -fbranch-probabilities --param 
> max-unroll-times=0 a.c".
> During this phase, I try to obtain dynamic frequencies of the statements 
> within the "for"
> loop in "foo" method at RTL level. The frequencies return "0" using 
> "bb->count". I 
> would like this to reflect "200". How to obtain this information?

I think the problem is that foo gets inlined into main, so the offline
copy of foo is really never executed.

Honza
> 
> regards,
> Raj
> 
> 
> 
> 
> 
> 
> 
> Jan Hubicka <hubicka@ucw.cz> 
> 07/18/2005 10:29 AM
> 
> To
> Rajkishore Barik/India/IBM@IBMIN
> cc
> gcc@gcc.gnu.org
> Subject
> Re: -fprofile-arcs
> 
> 
> 
> 
> 
> 
> > Hi,
> > 
> > I am trying to profile the frequency of each basic block of 
> > SPEC 2000 benchmarks by compiling them using -fprofile-arcs and opt -O3.
> > After running the benchmark, when I try to read "bb->count" while 
> > compiling
> > using "-fbranch-probabilities and -O3", I get "0" values for basic 
> blocks
> > which were known to execute for sure. Any clue as to where I am missing?
> > Is "bb->count" is the right way to get the dynamic frequency in the 
> second 
> > pass?
> 
> It is.  You would need to provide more information for me to figure out
> what is going wrong.  Of course the bb->count is initialized only after
> profile is read in that at current mainline is pretty late in
> compilation queue (after bp RTL pass), but this is going to change
> hopefully at monday.
> 
> Honza
> > 
> > regards,
> > Raj
> 

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

* Re: -fprofile-arcs
  2001-11-11  7:02 -fprofile-arcs Marc Schafer
@ 2001-11-11 14:21 ` Richard Henderson
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2001-11-11 14:21 UTC (permalink / raw)
  To: Marc Schafer; +Cc: gcc, crossgcc

On Wed, Nov 21, 2001 at 09:33:08AM +0100, Marc Schafer wrote:
> Of course, this doesn't work because I get a
> few unresolved symbols like "__bb_init_func"

This is in libgcc.a.

> I tried to figure out how to do this by looking at the assembly and map
> files generated for a simple program using the native compiler (running
> RedHat 7.1).  However, I am having a hard time figuring out what
> functions I need to supply and what they should do.

Look at the source for the functions in libgcc2.c.



r~

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

* -fprofile-arcs
@ 2001-11-11  7:02 Marc Schafer
  2001-11-11 14:21 ` -fprofile-arcs Richard Henderson
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Schafer @ 2001-11-11  7:02 UTC (permalink / raw)
  To: gcc, crossgcc

I am using gcc as a cross compiler (386-linux to powerpc-eabi) to
generate code for an embedded power pc app.  There is no operating
system running on the target and I am using newlib instead of glibc, but
I would still like to do code coverage analysis.  Adding -ftest-coverage
to the compile options generates the necessary .bb and .bbg files.
Adding -fprofile-arcs causes the output code to contain space for the
counts and each basic block has the necessary instructions for properly
incrementing the counts.  Of course, this doesn't work because I get a
few unresolved symbols like "__bb_init_func"

My target doesn't have a filesystem so there is no way to write the .da
files.  What I would like to do is supply my own library of functions to
support -fprofile-arcs so the counts still end up being generated
correctly in memory.  I can then send the .da files over a serial port
back to the host or use the gdb remote protocol to retrieve then and run
gcov.

I tried to figure out how to do this by looking at the assembly and map
files generated for a simple program using the native compiler (running
RedHat 7.1).  However, I am having a hard time figuring out what
functions I need to supply and what they should do.  I found some of it
in the gcc source code but there aren't many comments.  Is there some
documentation of how this works somewhere?  Can somebody help me figure
it out?

thanks,
marc


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

end of thread, other threads:[~2005-07-20  8:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-18 14:10 -fprofile-arcs Rajkishore Barik
2005-07-18 14:31 ` -fprofile-arcs Jan Hubicka
2005-07-18 15:07   ` -fprofile-arcs Rajkishore Barik
2005-07-20  8:09     ` -fprofile-arcs Jan Hubicka
  -- strict thread matches above, loose matches on Subject: below --
2001-11-11  7:02 -fprofile-arcs Marc Schafer
2001-11-11 14:21 ` -fprofile-arcs Richard Henderson

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