cpu time of the computation

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
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;
}

}





Re: cpu time of the computation
Quoted text here. Click to load it

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.

Quoted text here. Click to load it

if instead you wrote:

  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

Re: cpu time of the computation
It works, Thanks!

Terrence

Quoted text here. Click to load it
the



Site Timeline