iiwusynth-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [iiwusynth-devel] Optimization


From: Peter Hanappe
Subject: Re: [iiwusynth-devel] Optimization
Date: 07 Mar 2002 01:34:19 +0100

On Wed, 2002-03-06 at 19:06, Josh Green wrote:
> On Wed, 2002-03-06 at 07:22, Peter Hanappe wrote:
> > On Mon, 2002-02-25 at 02:19, Josh Green wrote:
> > > Ohh yeah, forgot to reply to your bit about profilers. Have you looked
> > > into gprof yet? You just need to compile your program with profiling
> > > enabled (-pg for gcc to output gprof data). When you run your program
> > > that has been compiled with the -pg switch it outputs a gmon.out file
> > > which can be processed with gprof. Not sure how well it handles multiple
> > > threads though. Its been a while since I tried this, so I might be wrong
> > > about stuff :) Lates..
> > 
> > Thanks for the hint. Will check.
> > 
> > Peter
> > 
> 
> I just tried it last night with not much luck. There is probably
> something you need to do with threads and the like. I didn't give it
> much of a try but it only showed main and some other function. 

I'll give it a try too. Just to get familiar with the tool.

> Perhaps
> it would be better to use the pentium timer and just make some functions
> that can be called to start and stop it and store the count (perhaps do
> some min/max/avg stuff?). 

I found somes code on the web to use the TSC register on intel
processors. I'll copy it below. Seems like a good way to measure time.

Do you any other optimized way to read the time?


----------------------------------------------------------------
#include <stdio.h>

static double cpu_frequency = 100e6;

long long rdtsc(void)
{
  asm("rdtsc");
}

double dclock(void)
{
  long long tsc;

  tsc = rdtsc();
  return tsc / cpu_frequency;
}


double estimate_cpu_frequency(void)
{
  double start, stop;
  unsigned int a, b;
  
  asm ("rdtsc" : "=a" (a), "=b" (b));
  start = (double)b * (double)0x10000 * (double)0x10000 + a;

  sleep(1);
  
  asm ("rdtsc" : "=a" (a), "=b" (b));
  stop = (double)b * (double)0x10000 * (double)0x10000 + a;

  return (stop - start);
}


int main()
{
  double t1, t2;

  cpu_frequency = estimate_cpu_frequency();
  
  printf("CPU %.0f MHz\n", cpu_frequency / 1e6.0);

  t1 = dclock();
  
  while (dclock() - t1 < 10.0) 
    ;
  
  t2 = dclock();
  printf("did we go 10 secs? time=%f\n", t2 - t1);

  return 0;
}
----------------------------------------------------------------


Cheers!
Peter

> We could then target it at specific spots to
> get a more direct idea of what parts of the synthesis loop are taking up
> the most time. I just realized last night that a lot of my performance
> issues were because I had debugging enabled (duhh!) this thought had
> totally escaped me before for some reason, even though I knew that there
> wasn't any optimization going on. Now I was unable to max it out with
> the few instruments I tested on my PII-366. A lot more optimized :)
> Cheers!
>       Josh Green
> 
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]