Topic
  • 5 replies
  • Latest Post - ‏2010-05-20T14:25:52Z by SchnellCoder
SchnellCoder
SchnellCoder
10 Posts

Pinned topic Timing a segment of code running on an SPE

‏2010-05-10T17:30:25Z |
Hello:

I'm looking for a tutorial explaining how to time a section of code running on a SPE. So far, I haven't found what I'm looking for. I'm hoping for a timing mechanism which allows me to start and stop it in code, not external to the program.

Thank you for you help,
Updated on 2010-05-20T14:25:52Z at 2010-05-20T14:25:52Z by SchnellCoder
  • andhp
    andhp
    48 Posts

    Re: Timing a segment of code running on an SPE

    ‏2010-05-11T07:59:21Z  
    Have you looked at the SPU timer library?

    http://public.dhe.ibm.com/software/dw/cell/SPU_Runtime_Library_Extensions_v3.1.pdf
  • SchnellCoder
    SchnellCoder
    10 Posts

    Re: Timing a segment of code running on an SPE

    ‏2010-05-13T16:41:56Z  
    I'm using SDK 2.1 and it doesn't appear the timer library is part of it; I'm also unable to migrate to a newer version of the SDK. Is there another way of get a timestamp (maybe in clock cycles) where I can get the time, perform the work, get the time, then subtract the earlier time from the later time?
  • SystemAdmin
    SystemAdmin
    10114 Posts

    Re: Timing a segment of code running on an SPE

    ‏2010-05-13T21:29:49Z  
    I'm using SDK 2.1 and it doesn't appear the timer library is part of it; I'm also unable to migrate to a newer version of the SDK. Is there another way of get a timestamp (maybe in clock cycles) where I can get the time, perform the work, get the time, then subtract the earlier time from the later time?
    Hi,

    I think SPU decrementer and the related functions may be useful for you. Each SPU has a (decrementing) counter with a special frequency and you can read its value:

    spu_write_decrementer(-1);//write the maximum value
    uint64_t temp=spu_read_decrementer();
    //... Do something here
    temp=temp-spu_read_decrementer();

    You can use temp value to determine the time your work lasts based on the frequency of decrementer. You can find some info here:
    http://moss.csc.ncsu.edu/~mueller/cluster /ps3/SPU_language_extensions_v21.pdf
  • andhp
    andhp
    48 Posts

    Re: Timing a segment of code running on an SPE

    ‏2010-05-13T22:40:12Z  
    I'm using SDK 2.1 and it doesn't appear the timer library is part of it; I'm also unable to migrate to a newer version of the SDK. Is there another way of get a timestamp (maybe in clock cycles) where I can get the time, perform the work, get the time, then subtract the earlier time from the later time?
    Exactly. The decrementer runs at the timebase frequency listed in /proc/cpuinfo.
    On the PS3 for example, this would be 79.8 MHz, which means a tick every 40 clock cycles (assuming an SPU clock frequency of 3.2 GHz).
    So the elapsed time in clock cycles would be temp * 40.

    But look up the actual timebase on your system.
  • SchnellCoder
    SchnellCoder
    10 Posts

    Re: Timing a segment of code running on an SPE

    ‏2010-05-20T14:25:52Z  
    Thank you guys, this worked for me.