UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Explorer
Explorer
9,711 Views
Registered: ‎03-31-2011

calculation of execution time of a thread in XILKERNEL

hiee

 

I am using spartan3e and i have successfully implemented xilkernel in my board and able to run a static thread,,

 

Do u all have any idea that how could i calculate the time of execution of my thread as we usually use XPS_TIMER in our design with xilkernel....

 

thank you

 

regards

Joy

0 Kudos
12 Replies
Highlighted
Advisor evgenis1
Advisor
9,707 Views
Registered: ‎12-03-2007

Re: calculation of execution time of a thread in XILKERNEL

Hi Joy,

 

One simple but fairly accurate technique is to instument your thread to toggle an IO by writing to a register (for example toggle an IO every time you enter a thread). This can be an external FPGA IO that you can monitor with a logic analyzer, or virtual IO that hooked up to the ChipScope ILA core.

 

Thanks,

Evgeni

Tags (1)
0 Kudos
Explorer
Explorer
9,703 Views
Registered: ‎08-14-2007

Re: calculation of execution time of a thread in XILKERNEL

Just use an XPS_TIMER then?  If you haven't got a spare one, add one - that's the beauty of an FPGA-based system :)

 

Alternatively, when I needed better precision than the XPS_TIMER I created a small DWFSL perpiheral which logged a timestamp each time it was written to.  These timestamps were stuffed into the returning FIFO-d FSL, and read once per algorithm iteration.  The software then did some calculations to show me min/ave/max timing for various sections of code. (The advantage of using the FSL is that it gives very low-jitter - due to no bus accesses.)

Martin Thompson
martin.j.thompson@trw.com
http://www.conekt.co.uk/capabilities/electronic-hardware
0 Kudos
Explorer
Explorer
9,691 Views
Registered: ‎03-31-2011

Re: calculation of execution time of a thread in XILKERNEL

Thanx for reply.......usually axilkernel code outline is

 

#include “stdio.h”

#include "xmk.h"        // Xilinx Micro Kernel library

 

int main(void)

{

 


 

xilkernel_main();   /* Start the kernel */

 

/* Control does not reach here */

 

}

 

void* main_thread(void)     /* Statically created first thread */

{

xil_printf("This is thread \r\n");

return NULL;

 

}

 

 

 

where should use what sort of function to measure execution time of my thread by XPS_TIMER...

#include “xmk.h

#include <stdio.h>

#include “xmk.h

#include <stdio.h>

/* various declarations and definitions go here */

int main()

{

/* Application initialization code goes here */

/* Don’t invoke kernel interfaces yet */

xilkernel_main (); /* Start the kernel */

/* Control does not reach here */

}

 

#include “xmk.h

#include <stdio.h>

/* various declarations and definitions go here */

int main()

{

/* Application initialization code goes here */

/* Don’t invoke kernel interfaces yet */

xilkernel_main (); /* Start the kernel */

/* Control does not reach here */

}

 

 

 

#include “xmk.h

#include <stdio.h>

/* various declarations and definitions go here */

int main()

{

/* Application initialization code goes here */

/* Don’t invoke kernel interfaces yet */

xilkernel_main (); /* Start the kernel */

/* Control does not reach here */

}

 

0 Kudos
Explorer
Explorer
9,679 Views
Registered: ‎08-14-2007

Re: calculation of execution time of a thread in XILKERNEL

Read the timer at the start of your thread, read it again at the end.  Subtract the two. Divide by the clock rate.

 

Obviously if you have more than one thread running and/or interrupts going off, the timing will vary from run to run, even for a very simple thread, but that's life in the real world.

 

* If you need hard deterministic tick-level performance for something simple, do it in hardware.

* If you can live with no particular guarantees about worst-case behaviour, carry on.

* If you do need hard real-time performance, but hardware is inappropriate, you'll have to join the "real-time embedded systems" world, do lots of analysis and likely make the some carefully thought-out financial invesments in tools

Martin Thompson
martin.j.thompson@trw.com
http://www.conekt.co.uk/capabilities/electronic-hardware
0 Kudos
Explorer
Explorer
9,658 Views
Registered: ‎03-31-2011

Re: calculation of execution time of a thread in XILKERNEL


Thanx for ur ans

 

 

would u plz explain what the changes should be made for appropiate hardware for "real-time embedded systems" world...

 

do u have any idea that how further we could work with RTOS in FPGA
domain and what kind of hardware changes should be made for real time
systems

 

plz share

 

regards

 

Joy




0 Kudos
Explorer
Explorer
9,648 Views
Registered: ‎08-14-2007

Re: calculation of execution time of a thread in XILKERNEL

would u plz explain what the changes should be made for appropiate hardware for "real-time embedded systems" world...

That's a massively application specific question, there's just too many things to consider. You're either going to have to "learn by doing" as you go, or engage with someone who's been doing it for years to help you up the learning curve. It's not something which can be sorted in a few newsboard messages I'm afraid! Martin

Martin Thompson
martin.j.thompson@trw.com
http://www.conekt.co.uk/capabilities/electronic-hardware
0 Kudos
Explorer
Explorer
9,642 Views
Registered: ‎03-31-2011

Re: calculation of execution time of a thread in XILKERNEL

Ok

 

atlast i was able to measure the time of a thread.using XPS_TIMER including "xtmrctr.h"..by setting a timer before and after execution of that thread

 

the time taken to execute a algorithm in a thread is comparitevely very low while the algo was running in general without xilkernel...

 

what could be the reason that faster the execution in a thread, the clock and processor are same in both program:smileyindifferent::smileyindifferent:

0 Kudos
Explorer
Explorer
9,639 Views
Registered: ‎08-14-2007

Re: calculation of execution time of a thread in XILKERNEL

First guess would be caches - were they enabled for both versions?

Martin Thompson
martin.j.thompson@trw.com
http://www.conekt.co.uk/capabilities/electronic-hardware
0 Kudos
Explorer
Explorer
9,636 Views
Registered: ‎03-31-2011

Re: calculation of execution time of a thread in XILKERNEL

yes that was enabled in both program..

 

while i am executing a algo in  a function and executing in a thread i think that differs....

 

 

0 Kudos
Explorer
Explorer
3,809 Views
Registered: ‎08-14-2007

Re: calculation of execution time of a thread in XILKERNEL

Can you post your timing code?  How are you detecting that the thread has finished?

 

 

Martin Thompson
martin.j.thompson@trw.com
http://www.conekt.co.uk/capabilities/electronic-hardware
0 Kudos
Explorer
Explorer
3,806 Views
Registered: ‎03-31-2011

Re: calculation of execution time of a thread in XILKERNEL

I have added only one thread with priority 1 in xilkernel setting at Pthread_static_function ie start_func my code is this type

 

#include"xmk.h"

#include"stdio.h"

#include"xtmrctr.h"

 

void Start_Timer()
{

 

//fuction

 

}

 

int Stop_Timer()

{

 

.......

 

}

 

int Get_Timer()

 

{

 

return...

 

}

 

 

int main(void)

{

 

Start_Timer();
start_timer_value=Get_Timer();

 

xilkernel_main();

 

}

 

void* start_func ()   /*staic thread*/

{

 

///algo starts

 

 

    end_timer_value=Stop_Timer();
       
xil_printf("\n\rStart Timer Value=> %d\n\r",start_timer_value);
xil_printf("\n\rEnd Timer Value=> %d\n\r",end_timer_value);

 

 

 

/// algo output

 

}

 

       I have only one thread and want to stop my timer when my algo ends...similarly i had started my timer at begining of my algo and ended at that same place in my genaral program without using xilkernel

 

regards

Joy

 

0 Kudos
Explorer
Explorer
3,801 Views
Registered: ‎08-14-2007

Re: calculation of execution time of a thread in XILKERNEL

Hmmm. Assuming you are timing the "non-xilkernel" algorithm is much the same way, there doesn't look to be a problem there.

 

Other places to look:

 

* linker file - is some data or code located differently in one project or the other?

* Run it lots of times in each project - is the algorithm time actually varying a lot, and it just *looks* like the project settings are different?

* Compiler optimisation settings

* Debug settings

* Caches (I think I already said this)

* compare the other compiler flags (eg is the slow project using software floating-point for some bizarre reason?)

 

I'll post more if I think of them!

Martin Thompson
martin.j.thompson@trw.com
http://www.conekt.co.uk/capabilities/electronic-hardware
0 Kudos