discussion forum



message

Name: Grampa
Date: October 27, 2004 at 07:30:47
Subject: Need help on SPARC timing phenomenon -- desperately!
Text: Hi,
I hope I'm not too off-topic as this site is x86-only, but I hope there are some specialists on other architectures around here as well
I have encoutnered a strange phenomenon on a current ultra-sparc-iii driven Sun Fire-r280 which makes me really wonder:
Given a program like this one:

int a,b,c,d,e;
for(i=0;i<100;i++){
get_tick_counter();
e=myfunction(a,b,c,d);
get_tick_counter();
}

get_tick_counter is something similar to x86-"rdtsc", but for sparc, i.e. it reads a cpu cycles counter which I use to determine how many cycles have elapsed during "myfunction" is executed ( asm("rd %%tick, %%0":"=r"(t)); ).
after some loops the execution time for myfunction is constant (let's say X ticks, X <1000 ticks, so no timer interrupts involved, neither sys calls) as all necessary code and data is in cache.

To my very surprise a very strange phenomenon occurs if I start this piece of code again or an interrupt occurs during this loop: The execution time of myfunction is still constant, but not X anymore like during the first run, but something within X +/-5%.
I looks like this strange behaviour is call/return-related, but nobody (even at university) could explain why. I suspect it has something to do with those magic register windows sparc uses, but can anybody explain to me why the values differ between each run and what's going on there on hardware level? I mean, if it's really register-window related, the only reason why the times might differ is that it causes a trap and has to save the register window onto the stack which would most probably cause more than +5% execution time and shouldn't occur again after 2-3 loops.

However, if I remove the function call, the execution time of code between both get_tick_counter is always the same, no matter how often I run the program.

Any hints or ideas?

Thank you in advance!

Grampa




post a followup message
(Be nice... or be blocked. Be technical... or be erased.)

Name: optional link title:
eMail: optional link URL:
Subject: optional image URL:
  Insert line breaks by hand when only about one inch remains at the right side. Otherwise your message will be unreadable.
Text:
 

  Note: The above eMail form fields may look unaligned if you are using a browser other than Netscape Navigator version 3.0.



currently posted followup messages
(You may have to press the RELOAD button of your browser.)




main page