cpu time of the computation

Mar 01, 2004 2 Replies

Hi,



I am new in using the embeded device (VirtexII-Pro) to implement an algorithm. As I want to count the cpu time of the algorithm , I use the XTime_GetTime(starttime) in the the xtime_l.h library. Also I need to print out the result to a uart by using xil_printf. But the result did not displayed successfully. Please find the program as follows.



Is there any step missed?



Many thanks, Terrence



#include "xgpio.h" #include "xparameters.h" #include "math.h" #include "xtime_l.h"


main() { XGpio gpio_reset, gpio_addr, gpio_data; int i,j=0, count=0,k, site=0; double likelihood[12], probability=0.0, lnL=0.0; XTime *starttime, *endtime; char *output;


xil_printf("start\n"); XTime_GetTime(starttime);



// Start computation



...



//End computation



XTime_GetTime(endtime);



//convert the long long to a string sprintf(output, "%llu", *endtime);


//print the result while(*output){ xil_printf("%c", *output); ++output; }



}



The following statements only allocate pointers, not a memory array or structure pointed to. I'm not sure if the XTime_GetTime() function allocates memory for you, but I'm sure than sprintf does not.

Thus you're calling functions with uninitialized pointers and the result is stored (probably at location zero) where the pointers were at the time of call.

if XTime starttime, endtime; char output[16]; // or as large as the largest message

xil_printf("start\n"); XTime_GetTime(&starttime);

// Start computation

...

//End computation

XTime_GetTime(&endtime);

//convert the long long to a string sprintf(output, "%llu", endtime);

...

you should have better results

It works, Thanks!

Terrence

the

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required