cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
8,339 Views
Registered: ‎04-09-2008

PowerPC speed measurement

Hi,

 

My goal is to measure the time which the powerPC needs to excecute simple instructions like add, multiply and divide. I use the following code for this:

 

#include "xparameters.h"

#include "xbasic_types.h"

#include "xgpio.h"

#include "xtime_l.h"

#include "sleep.h"

 int main()

{

XTime start_time;

XTime stop_time;

int i;

int xtimeRegReadDelay;

int a,b,c;

a = 2352;

b = 5462;
 

print("---------------------------------------------------\r\n");print(

"--Entering main--\r\n\n");

 

XTime_GetTime(&start_time);

XTime_GetTime(&stop_time);

xil_printf(
"Time needed for reading XTime reg: %d ns\r\n",((int)(stop_time - start_time))*10);

XTime_GetTime(&start_time);

XTime_GetTime(&stop_time);

xil_printf(
"Time needed for reading XTime reg: %d ns\r\n\n",((int)(stop_time - start_time))*10);xtimeRegReadDelay = (int)(stop_time - start_time);

 

print(
"ADD:\r\n");

XTime_GetTime(&start_time);

c = a + b;

XTime_GetTime(&stop_time);

xil_printf(
"Time needed for sum (%d + %d = %d): %d ns\r\n\n",a,b,c,((int)(stop_time - start_time)-xtimeRegReadDelay)*10);

 

print(
"MULTIPLY:\r\n");

XTime_GetTime(&start_time);

c = a * b;

XTime_GetTime(&stop_time);

xil_printf(
"Time needed for multiplication (%d * %d = %d): %d ns\r\n\n",a,b,c,((int)(stop_time - start_time)-xtimeRegReadDelay)*10);

 

print(
"DIVIDE:\r\n");

XTime_GetTime(&start_time);

c = b / a;

XTime_GetTime(&stop_time);

xil_printf(
"Time needed for division (%d / %d = %d): %d ns\r\n\n",b,a,c,((int)(stop_time - start_time)-xtimeRegReadDelay)*10);

 

 

print(
"--Exiting main--\r\n\n"); return 0;

 }

 

The reason why I multiply by 10 is because one period is 10 ns. (PowerPC is running at 100MHz, I'm using the Virtex4 ML403 Evaluation Platform)

 

But the results are dissapointing:

 

---------------------------------------------------
--Entering main--

Time needed for reading XTime reg: 1540 ns
Time needed for reading XTime reg: 1540 ns

ADD:
Time needed for sum (2352 + 5462 = 7814): 690 ns

MULTIPLY:
Time needed for multiplication (2352 * 5462 = 12846624): 700 ns

DIVIDE:
Time needed for division (5462 / 2352 = 2): 1020 ns

--Exiting main--

 

This can't be right? Can it? What did I do wrong?

Thx very much in advance,

 

Ruben

0 Kudos
4 Replies
Highlighted
Explorer
Explorer
8,305 Views
Registered: ‎12-11-2007

Hi, Ruben,

 

It mainly should be like that.

 

While I would like to recommend you take a look at the exact executation flow, i.e., if the code are executed in order as you wrote. In case you set 'optimization' in compile, then most likely it's not. Look at the assembly code executation order in debug.

 

My solution is use 'synchronize_io()' before and right after my test code. Refer to xilinx/IBM for synchronize_io instruction.

 

Another issue is, provided that you set 'optimization' in compile, then you must ensure that your code is not optimized to 'nop'...

 

 

0 Kudos
Highlighted
Visitor
Visitor
8,274 Views
Registered: ‎04-09-2008

hi jeffsen,

 

thx for your reply, it brougth a bit more clarity about the optimization. But where can I find more about the 'synchronize_io()' you're talking about?

thx,
Ruben

0 Kudos
Highlighted
Explorer
Explorer
8,258 Views
Registered: ‎12-11-2007

Hi, Ruben,

 

You may find the ASM of 'synchronize_io()' in xio.h, it's actually eieio, refer to: http://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/com.ibm.aix.aixassem/doc/alangref/eieio.htm

 

hope it helps.

 

regards,

jianfeng

0 Kudos
Highlighted
8,216 Views
Registered: ‎02-20-2008

Hello,

 

I am having a similar problem but I am using microblaze and I want to measure the speed of a DMA transfer. I am using xps_timer to achieve that but just after start I read the value from the conter and it is already in 1352 . I believe that is not correct, microblaze wouldn't take 1352 cycles just to read a register.

I am usig EDK 10.1 and a Virtex 4 FPGA. I simply use:

 

XTmrCtr_Start (&Contador, 1);
  
 Xuint32 RegValue_Int1;
 RegValue_Int1 = XTmrCtr_GetValue(&Contador, 1);

 

When I read RegValue_Int1, the value is 1352.

 

Best regards,

 

Leandro Pralon

0 Kudos