* [Xenomai-help] Execution time profiling
@ 2012-02-29 17:29 Charles Lesire-Cabaniols
2012-02-29 17:40 ` Gilles Chanteperdrix
0 siblings, 1 reply; 11+ messages in thread
From: Charles Lesire-Cabaniols @ 2012-02-29 17:29 UTC (permalink / raw)
To: xenomai
[-- Attachment #1.1: Type: text/plain, Size: 1426 bytes --]
Hi guys,
I have installed a Debian+Xenomai (2.6.0) OS on my Gumstix Overo.
I want to evaluate the execution time of a simple program, executed as a
real-time thread.
I definitely wonder about which functions to use, as I have completely
inconsistent measures.
I have tried using rt_timer_read, rt_timer_tsc, clock_gettime.
I also directly read the CNNT register with ARM instructions (which is the
only one I think correct) in order to have a (good?) reference.
I join the simple program I use.
The output is :
----- ASM instruction -----
start: 62483 ; end: 172961 ; (s-e): 110478 ; overhead: 102 ;
(s-e-overhead): 110376 ; CET: 110478
----- Xenomai rt_timer_read -----
start: 1016 ; end: 3435090911 ; (s-e): 1016 ; CET: 3435246834
----- Xenomai rt_timer_tsc -----
start: 13 ; end: 938009132 ; (s-e): 13 ; CET: 938011124
----- Xenomai clock_gettime -----
[ s] start: 946689173 ; end: 946689173 ; (s-e): 0 ; CET: 0
[ns] start: 231412764 ; end: 231569761 ; (s-e): 156997 ; CET: 156997
So that I can support that the correct execution time is around 110 000
(ticks?)
Only the nsecs of clock_gettime seem to be consistent ; other functions
return erratic values!
What am I doing wrong?
Should I initialize something in my program (I tried
rt_timer_set_mode(TM_ONESHOT) without any change)?
Should I check or change my kernel or xenomai configuration options?
Any (urgent) help would be appreciated!
Thanks,
Charles.
[-- Attachment #1.2: Type: text/html, Size: 1559 bytes --]
[-- Attachment #2: wcet_test.c --]
[-- Type: text/x-csrc, Size: 3395 bytes --]
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>
#include <native/task.h>
#include <native/timer.h>
#include <rtdk.h>
#include <posix/time.h>
RT_TASK task;
int sum() {
int i = 0;
int s = 0;
for(i = 0; i < 10000; i++)
s += i;
return s;
}
static inline unsigned long int get_cyclecount (void)
{
unsigned long int value;
//MRC p15, 0, <Rd>, c9, c13, 0 ; Read CCNT Register
asm volatile ("MRC p15, 0, %[Rd], c9, c13, 0\t\n": [Rd] "=r"(value));
return value;
}
static inline void init_perfcounters (int32_t do_reset, int32_t enable_divider)
{
// in general enable all counters (including cycle counter)
int32_t value = 1;
// peform reset:
if (do_reset)
{
value |= 2; // reset all counters to zero.
value |= 4; // reset cycle counter to zero.
}
if (enable_divider)
value |= 8; // enable "by 64" divider for CCNT.
value |= 16;
// program the performance-counter control-register:
asm volatile ("MCR p15, 0, %0, c9, c12, 0\t\n" :: "r"(value));
// enable all counters:
asm volatile ("MCR p15, 0, %0, c9, c12, 1\t\n" :: "r"(0x8000000f));
// clear overflows:
asm volatile ("MCR p15, 0, %0, c9, c12, 3\t\n" :: "r"(0x8000000f));
}
void sum_task(void *arg) {
// Init ASM registers
init_perfcounters(1, 0);
// Init Timer
rt_timer_set_mode(TM_ONESHOT);
rt_printf("----- ASM instruction -----\n");
unsigned long int asm_s, asm_e, asm_c, asm_o;
asm_o = get_cyclecount(); asm_o = get_cyclecount() - asm_o;
asm_s = get_cyclecount();
sum();
asm_e = get_cyclecount();
asm_c = asm_e - asm_s;
rt_printf("start: %lu ; end: %lu ; (s-e): %lu ; overhead: %lu ; (s-e-overhead): %lu ; CET: %lu \n",
asm_s, asm_e, (asm_e - asm_s), asm_o, ((asm_e-asm_s)-asm_o), asm_c);
rt_printf("----- Xenomai rt_timer_read -----\n");
RTIME read_s, read_e, read_c;
read_s = rt_timer_read();
sum();
read_e = rt_timer_read();
read_c = read_e - read_s;
rt_printf("start: %lu ; end: %lu ; (s-e): %lu ; CET: %lu \n", read_s, read_e, (read_e - read_s), read_c);
rt_printf("----- Xenomai rt_timer_tsc -----\n");
RTIME tsc_s, tsc_e, tsc_c;
tsc_s = rt_timer_tsc();
sum();
tsc_e = rt_timer_tsc();
tsc_c = tsc_e - tsc_s;
rt_printf("start: %lu ; end: %lu ; (s-e): %lu ; CET: %lu \n", tsc_s, tsc_e, (tsc_e - tsc_s), tsc_c);
rt_printf("----- Xenomai clock_gettime -----\n");
struct timespec clock_s, clock_e, clock_c;
clock_gettime(CLOCK_REALTIME, &clock_s);
sum();
clock_gettime(CLOCK_REALTIME, &clock_e);
clock_c.tv_sec = clock_e.tv_sec - clock_s.tv_sec;
clock_c.tv_nsec = clock_e.tv_nsec - clock_s.tv_nsec;
rt_printf("[ s] start: %d ; end: %d ; (s-e): %d ; CET: %d \n",
clock_s.tv_sec, clock_e.tv_sec, (clock_e.tv_sec - clock_s.tv_sec), clock_c.tv_sec);
rt_printf("[ns] start: %d ; end: %d ; (s-e): %d ; CET: %d \n",
clock_s.tv_nsec, clock_e.tv_nsec, (clock_e.tv_nsec - clock_s.tv_nsec), clock_c.tv_nsec);
}
int main(int argc, char* argv[]) {
char str[10] ;
// Perform auto-init of rt_print buffers if the task doesn't do so
rt_print_auto_init(1);
// Lock memory : avoid memory swapping for this program
mlockall(MCL_CURRENT | MCL_FUTURE);
sprintf(str, "sum_test");
// rt_task_create(task, task name, stack size, priority, mode
rt_task_create(&task, str, 0, 50, 0);
// rt_task_start(task, task function, function argument
rt_task_start(&task, &sum_task, 0);
rt_task_join(&task);
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai-help] Execution time profiling
2012-02-29 17:29 [Xenomai-help] Execution time profiling Charles Lesire-Cabaniols
@ 2012-02-29 17:40 ` Gilles Chanteperdrix
2012-02-29 17:52 ` Charles Lesire-Cabaniols
0 siblings, 1 reply; 11+ messages in thread
From: Gilles Chanteperdrix @ 2012-02-29 17:40 UTC (permalink / raw)
To: Charles Lesire-Cabaniols; +Cc: xenomai
On 02/29/2012 06:29 PM, Charles Lesire-Cabaniols wrote:
> Hi guys,
>
> I have installed a Debian+Xenomai (2.6.0) OS on my Gumstix Overo.
>
> I want to evaluate the execution time of a simple program, executed as a
> real-time thread.
>
> I definitely wonder about which functions to use, as I have completely
> inconsistent measures.
> I have tried using rt_timer_read, rt_timer_tsc, clock_gettime.
> I also directly read the CNNT register with ARM instructions (which is the
> only one I think correct) in order to have a (good?) reference.
> (...)
> What am I doing wrong?
So, you should printf("%Lu %Lu\n", rt_timer_read(), rt_timer_tsc());
Not printf("%lu", ...)
--
Gilles.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai-help] Execution time profiling
2012-02-29 17:40 ` Gilles Chanteperdrix
@ 2012-02-29 17:52 ` Charles Lesire-Cabaniols
2012-02-29 18:01 ` Gilles Chanteperdrix
0 siblings, 1 reply; 11+ messages in thread
From: Charles Lesire-Cabaniols @ 2012-02-29 17:52 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: xenomai
[-- Attachment #1: Type: text/plain, Size: 1432 bytes --]
2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> On 02/29/2012 06:29 PM, Charles Lesire-Cabaniols wrote:
> > Hi guys,
> >
> > I have installed a Debian+Xenomai (2.6.0) OS on my Gumstix Overo.
> >
> > I want to evaluate the execution time of a simple program, executed as a
> > real-time thread.
> >
> > I definitely wonder about which functions to use, as I have completely
> > inconsistent measures.
> > I have tried using rt_timer_read, rt_timer_tsc, clock_gettime.
> > I also directly read the CNNT register with ARM instructions (which is
> the
> > only one I think correct) in order to have a (good?) reference.
> > (...)
> > What am I doing wrong?
>
> So, you should printf("%Lu %Lu\n", rt_timer_read(), rt_timer_tsc());
>
> Not printf("%lu", ...)
>
> --
> Gilles.
>
Effectively, that looks cleaner, thanks:
----- Xenomai rt_timer_read -----
start: 49166276042 ; end: 49166432273 ; (s-e): 156231 ; CET: 156231
----- Xenomai rt_timer_tsc -----
start: 639161547 ; end: 639163539 ; (s-e): 1992 ; CET: 1992
----- Xenomai clock_gettime -----
[ s] start: 946684855 ; end: 946684855 ; (s-e): 0 ; CET: 0
[ns] start: 275520245 ; end: 275677089 ; (s-e): 156844 ; CET: 156844
My ARM instruction reads 110554.
Which Xenomai function should I use?
Which one is supposed to be the more accurate?
Does rt_timer_read return nsecs?
What is the unit of rt_timer_tsc?
Charles.
[-- Attachment #2: Type: text/html, Size: 1990 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai-help] Execution time profiling
2012-02-29 17:52 ` Charles Lesire-Cabaniols
@ 2012-02-29 18:01 ` Gilles Chanteperdrix
2012-02-29 18:03 ` Charles Lesire-Cabaniols
0 siblings, 1 reply; 11+ messages in thread
From: Gilles Chanteperdrix @ 2012-02-29 18:01 UTC (permalink / raw)
To: Charles Lesire-Cabaniols; +Cc: xenomai
On 02/29/2012 06:52 PM, Charles Lesire-Cabaniols wrote:
> 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
>
>> On 02/29/2012 06:29 PM, Charles Lesire-Cabaniols wrote:
>>> Hi guys,
>>>
>>> I have installed a Debian+Xenomai (2.6.0) OS on my Gumstix Overo.
>>>
>>> I want to evaluate the execution time of a simple program, executed as a
>>> real-time thread.
>>>
>>> I definitely wonder about which functions to use, as I have completely
>>> inconsistent measures.
>>> I have tried using rt_timer_read, rt_timer_tsc, clock_gettime.
>>> I also directly read the CNNT register with ARM instructions (which is
>> the
>>> only one I think correct) in order to have a (good?) reference.
>>> (...)
>>> What am I doing wrong?
>>
>> So, you should printf("%Lu %Lu\n", rt_timer_read(), rt_timer_tsc());
>>
>> Not printf("%lu", ...)
>>
>> --
>> Gilles.
>>
>
> Effectively, that looks cleaner, thanks:
>
> ----- Xenomai rt_timer_read -----
> start: 49166276042 ; end: 49166432273 ; (s-e): 156231 ; CET: 156231
> ----- Xenomai rt_timer_tsc -----
> start: 639161547 ; end: 639163539 ; (s-e): 1992 ; CET: 1992
> ----- Xenomai clock_gettime -----
> [ s] start: 946684855 ; end: 946684855 ; (s-e): 0 ; CET: 0
> [ns] start: 275520245 ; end: 275677089 ; (s-e): 156844 ; CET: 156844
>
> My ARM instruction reads 110554.
>
> Which Xenomai function should I use?
> Which one is supposed to be the more accurate?
> Does rt_timer_read return nsecs?
> What is the unit of rt_timer_tsc?
rt_timer_tsc uses whatever hardware counter is available, you need
rt_timer_tsc2ns or rt_timer_ns2tsc to convert between this unit to and
from nanoseconds.
For more details, see:
http://www.xenomai.org/documentation/xenomai-2.6/html/api/group__native__timer.html
Depending on how xenomai user-space was compiled, rt_timer_tsc should
have the lowest overhead.
--
Gilles.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai-help] Execution time profiling
2012-02-29 18:01 ` Gilles Chanteperdrix
@ 2012-02-29 18:03 ` Charles Lesire-Cabaniols
2012-02-29 18:40 ` Gilles Chanteperdrix
0 siblings, 1 reply; 11+ messages in thread
From: Charles Lesire-Cabaniols @ 2012-02-29 18:03 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: xenomai
[-- Attachment #1: Type: text/plain, Size: 2208 bytes --]
2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> On 02/29/2012 06:52 PM, Charles Lesire-Cabaniols wrote:
> > 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> >
> >> On 02/29/2012 06:29 PM, Charles Lesire-Cabaniols wrote:
> >>> Hi guys,
> >>>
> >>> I have installed a Debian+Xenomai (2.6.0) OS on my Gumstix Overo.
> >>>
> >>> I want to evaluate the execution time of a simple program, executed as
> a
> >>> real-time thread.
> >>>
> >>> I definitely wonder about which functions to use, as I have completely
> >>> inconsistent measures.
> >>> I have tried using rt_timer_read, rt_timer_tsc, clock_gettime.
> >>> I also directly read the CNNT register with ARM instructions (which is
> >> the
> >>> only one I think correct) in order to have a (good?) reference.
> >>> (...)
> >>> What am I doing wrong?
> >>
> >> So, you should printf("%Lu %Lu\n", rt_timer_read(), rt_timer_tsc());
> >>
> >> Not printf("%lu", ...)
> >>
> >> --
> >> Gilles.
> >>
> >
> > Effectively, that looks cleaner, thanks:
> >
> > ----- Xenomai rt_timer_read -----
> > start: 49166276042 ; end: 49166432273 ; (s-e): 156231 ; CET: 156231
> > ----- Xenomai rt_timer_tsc -----
> > start: 639161547 ; end: 639163539 ; (s-e): 1992 ; CET: 1992
> > ----- Xenomai clock_gettime -----
> > [ s] start: 946684855 ; end: 946684855 ; (s-e): 0 ; CET: 0
> > [ns] start: 275520245 ; end: 275677089 ; (s-e): 156844 ; CET: 156844
> >
> > My ARM instruction reads 110554.
> >
> > Which Xenomai function should I use?
> > Which one is supposed to be the more accurate?
> > Does rt_timer_read return nsecs?
> > What is the unit of rt_timer_tsc?
>
> rt_timer_tsc uses whatever hardware counter is available, you need
> rt_timer_tsc2ns or rt_timer_ns2tsc to convert between this unit to and
> from nanoseconds.
>
> For more details, see:
>
>
> http://www.xenomai.org/documentation/xenomai-2.6/html/api/group__native__timer.html
>
> Depending on how xenomai user-space was compiled, rt_timer_tsc should
> have the lowest overhead.
>
And are the default options the best ones?
How can I tune the TSC performance?
>
> --
> Gilles.
>
[-- Attachment #2: Type: text/html, Size: 3370 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai-help] Execution time profiling
2012-02-29 18:03 ` Charles Lesire-Cabaniols
@ 2012-02-29 18:40 ` Gilles Chanteperdrix
2012-02-29 19:44 ` Charles Lesire-Cabaniols
0 siblings, 1 reply; 11+ messages in thread
From: Gilles Chanteperdrix @ 2012-02-29 18:40 UTC (permalink / raw)
To: Charles Lesire-Cabaniols; +Cc: xenomai
On 02/29/2012 07:03 PM, Charles Lesire-Cabaniols wrote:
> 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
>
>> On 02/29/2012 06:52 PM, Charles Lesire-Cabaniols wrote:
>>> 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
>>>
>>>> On 02/29/2012 06:29 PM, Charles Lesire-Cabaniols wrote:
>>>>> Hi guys,
>>>>>
>>>>> I have installed a Debian+Xenomai (2.6.0) OS on my Gumstix Overo.
>>>>>
>>>>> I want to evaluate the execution time of a simple program, executed as
>> a
>>>>> real-time thread.
>>>>>
>>>>> I definitely wonder about which functions to use, as I have completely
>>>>> inconsistent measures.
>>>>> I have tried using rt_timer_read, rt_timer_tsc, clock_gettime.
>>>>> I also directly read the CNNT register with ARM instructions (which is
>>>> the
>>>>> only one I think correct) in order to have a (good?) reference.
>>>>> (...)
>>>>> What am I doing wrong?
>>>>
>>>> So, you should printf("%Lu %Lu\n", rt_timer_read(), rt_timer_tsc());
>>>>
>>>> Not printf("%lu", ...)
>>>>
>>>> --
>>>> Gilles.
>>>>
>>>
>>> Effectively, that looks cleaner, thanks:
>>>
>>> ----- Xenomai rt_timer_read -----
>>> start: 49166276042 ; end: 49166432273 ; (s-e): 156231 ; CET: 156231
>>> ----- Xenomai rt_timer_tsc -----
>>> start: 639161547 ; end: 639163539 ; (s-e): 1992 ; CET: 1992
>>> ----- Xenomai clock_gettime -----
>>> [ s] start: 946684855 ; end: 946684855 ; (s-e): 0 ; CET: 0
>>> [ns] start: 275520245 ; end: 275677089 ; (s-e): 156844 ; CET: 156844
>>>
>>> My ARM instruction reads 110554.
>>>
>>> Which Xenomai function should I use?
>>> Which one is supposed to be the more accurate?
>>> Does rt_timer_read return nsecs?
>>> What is the unit of rt_timer_tsc?
>>
>> rt_timer_tsc uses whatever hardware counter is available, you need
>> rt_timer_tsc2ns or rt_timer_ns2tsc to convert between this unit to and
>> from nanoseconds.
>>
>> For more details, see:
>>
>>
>> http://www.xenomai.org/documentation/xenomai-2.6/html/api/group__native__timer.html
>>
>> Depending on how xenomai user-space was compiled, rt_timer_tsc should
>> have the lowest overhead.
>>
>
> And are the default options the best ones?
Yes, but I am not sure the debian package uses the default one. Please
post here the disassembly of rt_timer_tsc, I will tell you if your
system is compiled for the lowest overhead.
> How can I tune the TSC performance?
You use the --enable-arm-tsc or --disable-arm-tsc option of xenomai
configure script. The default is --enable-arm-tsc=kuser and should be
the best option. If you pass --disable-arm-tsc, rt_timer_tsc will emit a
system call.
--
Gilles.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai-help] Execution time profiling
2012-02-29 18:40 ` Gilles Chanteperdrix
@ 2012-02-29 19:44 ` Charles Lesire-Cabaniols
2012-02-29 19:48 ` Gilles Chanteperdrix
0 siblings, 1 reply; 11+ messages in thread
From: Charles Lesire-Cabaniols @ 2012-02-29 19:44 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: xenomai
[-- Attachment #1: Type: text/plain, Size: 3127 bytes --]
2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> On 02/29/2012 07:03 PM, Charles Lesire-Cabaniols wrote:
> > 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> >
> >> On 02/29/2012 06:52 PM, Charles Lesire-Cabaniols wrote:
> >>> 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> >>>
> >>>> On 02/29/2012 06:29 PM, Charles Lesire-Cabaniols wrote:
> >>>>> Hi guys,
> >>>>>
> >>>>> I have installed a Debian+Xenomai (2.6.0) OS on my Gumstix Overo.
> >>>>>
> >>>>> I want to evaluate the execution time of a simple program, executed
> as
> >> a
> >>>>> real-time thread.
> >>>>>
> >>>>> I definitely wonder about which functions to use, as I have
> completely
> >>>>> inconsistent measures.
> >>>>> I have tried using rt_timer_read, rt_timer_tsc, clock_gettime.
> >>>>> I also directly read the CNNT register with ARM instructions (which
> is
> >>>> the
> >>>>> only one I think correct) in order to have a (good?) reference.
> >>>>> (...)
> >>>>> What am I doing wrong?
> >>>>
> >>>> So, you should printf("%Lu %Lu\n", rt_timer_read(), rt_timer_tsc());
> >>>>
> >>>> Not printf("%lu", ...)
> >>>>
> >>>> --
> >>>> Gilles.
> >>>>
> >>>
> >>> Effectively, that looks cleaner, thanks:
> >>>
> >>> ----- Xenomai rt_timer_read -----
> >>> start: 49166276042 ; end: 49166432273 ; (s-e): 156231 ; CET: 156231
> >>> ----- Xenomai rt_timer_tsc -----
> >>> start: 639161547 ; end: 639163539 ; (s-e): 1992 ; CET: 1992
> >>> ----- Xenomai clock_gettime -----
> >>> [ s] start: 946684855 ; end: 946684855 ; (s-e): 0 ; CET: 0
> >>> [ns] start: 275520245 ; end: 275677089 ; (s-e): 156844 ; CET: 156844
> >>>
> >>> My ARM instruction reads 110554.
> >>>
> >>> Which Xenomai function should I use?
> >>> Which one is supposed to be the more accurate?
> >>> Does rt_timer_read return nsecs?
> >>> What is the unit of rt_timer_tsc?
> >>
> >> rt_timer_tsc uses whatever hardware counter is available, you need
> >> rt_timer_tsc2ns or rt_timer_ns2tsc to convert between this unit to and
> >> from nanoseconds.
> >>
> >> For more details, see:
> >>
> >>
> >>
> http://www.xenomai.org/documentation/xenomai-2.6/html/api/group__native__timer.html
> >>
> >> Depending on how xenomai user-space was compiled, rt_timer_tsc should
> >> have the lowest overhead.
> >>
> >
> > And are the default options the best ones?
>
> Yes, but I am not sure the debian package uses the default one. Please
> post here the disassembly of rt_timer_tsc, I will tell you if your
> system is compiled for the lowest overhead.
>
>
How to do that?
> > How can I tune the TSC performance?
>
> You use the --enable-arm-tsc or --disable-arm-tsc option of xenomai
> configure script. The default is --enable-arm-tsc=kuser and should be
> the best option. If you pass --disable-arm-tsc, rt_timer_tsc will emit a
> system call.
>
>
I do not use the debian package, but I compile Xenomai from sources ;
actually I have a vanilla kernel and a debain rootfs.
I think --enable-arm-tsc is the default then.
> --
> Gilles.
>
[-- Attachment #2: Type: text/html, Size: 5022 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai-help] Execution time profiling
2012-02-29 19:44 ` Charles Lesire-Cabaniols
@ 2012-02-29 19:48 ` Gilles Chanteperdrix
2012-02-29 19:59 ` Charles Lesire-Cabaniols
0 siblings, 1 reply; 11+ messages in thread
From: Gilles Chanteperdrix @ 2012-02-29 19:48 UTC (permalink / raw)
To: Charles Lesire-Cabaniols; +Cc: xenomai
On 02/29/2012 08:44 PM, Charles Lesire-Cabaniols wrote:
> 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
>
>> On 02/29/2012 07:03 PM, Charles Lesire-Cabaniols wrote:
>>> 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
>>>
>>>> On 02/29/2012 06:52 PM, Charles Lesire-Cabaniols wrote:
>>>>> 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
>>>>>
>>>>>> On 02/29/2012 06:29 PM, Charles Lesire-Cabaniols wrote:
>>>>>>> Hi guys,
>>>>>>>
>>>>>>> I have installed a Debian+Xenomai (2.6.0) OS on my Gumstix Overo.
>>>>>>>
>>>>>>> I want to evaluate the execution time of a simple program, executed
>> as
>>>> a
>>>>>>> real-time thread.
>>>>>>>
>>>>>>> I definitely wonder about which functions to use, as I have
>> completely
>>>>>>> inconsistent measures.
>>>>>>> I have tried using rt_timer_read, rt_timer_tsc, clock_gettime.
>>>>>>> I also directly read the CNNT register with ARM instructions (which
>> is
>>>>>> the
>>>>>>> only one I think correct) in order to have a (good?) reference.
>>>>>>> (...)
>>>>>>> What am I doing wrong?
>>>>>>
>>>>>> So, you should printf("%Lu %Lu\n", rt_timer_read(), rt_timer_tsc());
>>>>>>
>>>>>> Not printf("%lu", ...)
>>>>>>
>>>>>> --
>>>>>> Gilles.
>>>>>>
>>>>>
>>>>> Effectively, that looks cleaner, thanks:
>>>>>
>>>>> ----- Xenomai rt_timer_read -----
>>>>> start: 49166276042 ; end: 49166432273 ; (s-e): 156231 ; CET: 156231
>>>>> ----- Xenomai rt_timer_tsc -----
>>>>> start: 639161547 ; end: 639163539 ; (s-e): 1992 ; CET: 1992
>>>>> ----- Xenomai clock_gettime -----
>>>>> [ s] start: 946684855 ; end: 946684855 ; (s-e): 0 ; CET: 0
>>>>> [ns] start: 275520245 ; end: 275677089 ; (s-e): 156844 ; CET: 156844
>>>>>
>>>>> My ARM instruction reads 110554.
>>>>>
>>>>> Which Xenomai function should I use?
>>>>> Which one is supposed to be the more accurate?
>>>>> Does rt_timer_read return nsecs?
>>>>> What is the unit of rt_timer_tsc?
>>>>
>>>> rt_timer_tsc uses whatever hardware counter is available, you need
>>>> rt_timer_tsc2ns or rt_timer_ns2tsc to convert between this unit to and
>>>> from nanoseconds.
>>>>
>>>> For more details, see:
>>>>
>>>>
>>>>
>> http://www.xenomai.org/documentation/xenomai-2.6/html/api/group__native__timer.html
>>>>
>>>> Depending on how xenomai user-space was compiled, rt_timer_tsc should
>>>> have the lowest overhead.
>>>>
>>>
>>> And are the default options the best ones?
>>
>> Yes, but I am not sure the debian package uses the default one. Please
>> post here the disassembly of rt_timer_tsc, I will tell you if your
>> system is compiled for the lowest overhead.
>>
>>
> How to do that?
arm-none-linux-objdump -d /path/to/libnative.so.3 | less
search <rt_timer_tsc>, when you find it, post the disassembly here.
>
>
>>> How can I tune the TSC performance?
>>
>> You use the --enable-arm-tsc or --disable-arm-tsc option of xenomai
>> configure script. The default is --enable-arm-tsc=kuser and should be
>> the best option. If you pass --disable-arm-tsc, rt_timer_tsc will emit a
>> system call.
>>
>>
> I do not use the debian package, but I compile Xenomai from sources ;
> actually I have a vanilla kernel and a debain rootfs.
> I think --enable-arm-tsc is the default then.
Yes.
--
Gilles.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai-help] Execution time profiling
2012-02-29 19:48 ` Gilles Chanteperdrix
@ 2012-02-29 19:59 ` Charles Lesire-Cabaniols
2012-02-29 20:17 ` Gilles Chanteperdrix
0 siblings, 1 reply; 11+ messages in thread
From: Charles Lesire-Cabaniols @ 2012-02-29 19:59 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: xenomai
[-- Attachment #1: Type: text/plain, Size: 4699 bytes --]
2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> On 02/29/2012 08:44 PM, Charles Lesire-Cabaniols wrote:
> > 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> >
> >> On 02/29/2012 07:03 PM, Charles Lesire-Cabaniols wrote:
> >>> 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> >>>
> >>>> On 02/29/2012 06:52 PM, Charles Lesire-Cabaniols wrote:
> >>>>> 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> >>>>>
> >>>>>> On 02/29/2012 06:29 PM, Charles Lesire-Cabaniols wrote:
> >>>>>>> Hi guys,
> >>>>>>>
> >>>>>>> I have installed a Debian+Xenomai (2.6.0) OS on my Gumstix Overo.
> >>>>>>>
> >>>>>>> I want to evaluate the execution time of a simple program, executed
> >> as
> >>>> a
> >>>>>>> real-time thread.
> >>>>>>>
> >>>>>>> I definitely wonder about which functions to use, as I have
> >> completely
> >>>>>>> inconsistent measures.
> >>>>>>> I have tried using rt_timer_read, rt_timer_tsc, clock_gettime.
> >>>>>>> I also directly read the CNNT register with ARM instructions (which
> >> is
> >>>>>> the
> >>>>>>> only one I think correct) in order to have a (good?) reference.
> >>>>>>> (...)
> >>>>>>> What am I doing wrong?
> >>>>>>
> >>>>>> So, you should printf("%Lu %Lu\n", rt_timer_read(), rt_timer_tsc());
> >>>>>>
> >>>>>> Not printf("%lu", ...)
> >>>>>>
> >>>>>> --
> >>>>>> Gilles.
> >>>>>>
> >>>>>
> >>>>> Effectively, that looks cleaner, thanks:
> >>>>>
> >>>>> ----- Xenomai rt_timer_read -----
> >>>>> start: 49166276042 ; end: 49166432273 ; (s-e): 156231 ; CET: 156231
> >>>>> ----- Xenomai rt_timer_tsc -----
> >>>>> start: 639161547 ; end: 639163539 ; (s-e): 1992 ; CET: 1992
> >>>>> ----- Xenomai clock_gettime -----
> >>>>> [ s] start: 946684855 ; end: 946684855 ; (s-e): 0 ; CET: 0
> >>>>> [ns] start: 275520245 ; end: 275677089 ; (s-e): 156844 ; CET: 156844
> >>>>>
> >>>>> My ARM instruction reads 110554.
> >>>>>
> >>>>> Which Xenomai function should I use?
> >>>>> Which one is supposed to be the more accurate?
> >>>>> Does rt_timer_read return nsecs?
> >>>>> What is the unit of rt_timer_tsc?
> >>>>
> >>>> rt_timer_tsc uses whatever hardware counter is available, you need
> >>>> rt_timer_tsc2ns or rt_timer_ns2tsc to convert between this unit to and
> >>>> from nanoseconds.
> >>>>
> >>>> For more details, see:
> >>>>
> >>>>
> >>>>
> >>
> http://www.xenomai.org/documentation/xenomai-2.6/html/api/group__native__timer.html
> >>>>
> >>>> Depending on how xenomai user-space was compiled, rt_timer_tsc should
> >>>> have the lowest overhead.
> >>>>
> >>>
> >>> And are the default options the best ones?
> >>
> >> Yes, but I am not sure the debian package uses the default one. Please
> >> post here the disassembly of rt_timer_tsc, I will tell you if your
> >> system is compiled for the lowest overhead.
> >>
> >>
> > How to do that?
>
> arm-none-linux-objdump -d /path/to/libnative.so.3 | less
> search <rt_timer_tsc>, when you find it, post the disassembly here.
>
Here it is:
00005a54 <rt_timer_tsc>:
5a54: e59f2034 ldr r2, [pc, #52] ; 5a90
<rt_timer_tsc+0x3c>
5a58: e3e03a0f mvn r3, #61440 ; 0xf000
5a5c: e59f1030 ldr r1, [pc, #48] ; 5a94
<rt_timer_tsc+0x40>
5a60: e08f2002 add r2, pc, r2
5a64: e5133003 ldr r3, [r3, #-3]
5a68: e7921001 ldr r1, [r2, r1]
5a6c: e59f0024 ldr r0, [pc, #36] ; 5a98
<rt_timer_tsc+0x44>
5a70: e2833003 add r3, r3, #3
5a74: e0403283 sub r3, r0, r3, lsl #5
5a78: e92d4010 push {r4, lr}
5a7c: e5910008 ldr r0, [r1, #8]
5a80: e1a0e00f mov lr, pc
5a84: e12fff13 bx r3
5a88: e8bd4010 pop {r4, lr}
5a8c: e12fff1e bx lr
5a90: 000086a4 andeq r8, r0, r4, lsr #13
5a94: 000000ec andeq r0, r0, ip, ror #1
5a98: ffff1004 undefined instruction 0xffff1004
>
> >
> >
> >>> How can I tune the TSC performance?
> >>
> >> You use the --enable-arm-tsc or --disable-arm-tsc option of xenomai
> >> configure script. The default is --enable-arm-tsc=kuser and should be
> >> the best option. If you pass --disable-arm-tsc, rt_timer_tsc will emit a
> >> system call.
> >>
> >>
> > I do not use the debian package, but I compile Xenomai from sources ;
> > actually I have a vanilla kernel and a debain rootfs.
> > I think --enable-arm-tsc is the default then.
>
> Yes.
>
> --
> Gilles.
>
[-- Attachment #2: Type: text/html, Size: 7467 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai-help] Execution time profiling
2012-02-29 19:59 ` Charles Lesire-Cabaniols
@ 2012-02-29 20:17 ` Gilles Chanteperdrix
2012-02-29 20:42 ` Charles Lesire-Cabaniols
0 siblings, 1 reply; 11+ messages in thread
From: Gilles Chanteperdrix @ 2012-02-29 20:17 UTC (permalink / raw)
To: Charles Lesire-Cabaniols; +Cc: xenomai
On 02/29/2012 08:59 PM, Charles Lesire-Cabaniols wrote:
> 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
>
>> On 02/29/2012 08:44 PM, Charles Lesire-Cabaniols wrote:
>>> 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
>>>
>>>> On 02/29/2012 07:03 PM, Charles Lesire-Cabaniols wrote:
>>>>> 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
>>>>>
>>>>>> On 02/29/2012 06:52 PM, Charles Lesire-Cabaniols wrote:
>>>>>>> 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
>>>>>>>
>>>>>>>> On 02/29/2012 06:29 PM, Charles Lesire-Cabaniols wrote:
>>>>>>>>> Hi guys,
>>>>>>>>>
>>>>>>>>> I have installed a Debian+Xenomai (2.6.0) OS on my Gumstix Overo.
>>>>>>>>>
>>>>>>>>> I want to evaluate the execution time of a simple program, executed
>>>> as
>>>>>> a
>>>>>>>>> real-time thread.
>>>>>>>>>
>>>>>>>>> I definitely wonder about which functions to use, as I have
>>>> completely
>>>>>>>>> inconsistent measures.
>>>>>>>>> I have tried using rt_timer_read, rt_timer_tsc, clock_gettime.
>>>>>>>>> I also directly read the CNNT register with ARM instructions (which
>>>> is
>>>>>>>> the
>>>>>>>>> only one I think correct) in order to have a (good?) reference.
>>>>>>>>> (...)
>>>>>>>>> What am I doing wrong?
>>>>>>>>
>>>>>>>> So, you should printf("%Lu %Lu\n", rt_timer_read(), rt_timer_tsc());
>>>>>>>>
>>>>>>>> Not printf("%lu", ...)
>>>>>>>>
>>>>>>>> --
>>>>>>>> Gilles.
>>>>>>>>
>>>>>>>
>>>>>>> Effectively, that looks cleaner, thanks:
>>>>>>>
>>>>>>> ----- Xenomai rt_timer_read -----
>>>>>>> start: 49166276042 ; end: 49166432273 ; (s-e): 156231 ; CET: 156231
>>>>>>> ----- Xenomai rt_timer_tsc -----
>>>>>>> start: 639161547 ; end: 639163539 ; (s-e): 1992 ; CET: 1992
>>>>>>> ----- Xenomai clock_gettime -----
>>>>>>> [ s] start: 946684855 ; end: 946684855 ; (s-e): 0 ; CET: 0
>>>>>>> [ns] start: 275520245 ; end: 275677089 ; (s-e): 156844 ; CET: 156844
>>>>>>>
>>>>>>> My ARM instruction reads 110554.
>>>>>>>
>>>>>>> Which Xenomai function should I use?
>>>>>>> Which one is supposed to be the more accurate?
>>>>>>> Does rt_timer_read return nsecs?
>>>>>>> What is the unit of rt_timer_tsc?
>>>>>>
>>>>>> rt_timer_tsc uses whatever hardware counter is available, you need
>>>>>> rt_timer_tsc2ns or rt_timer_ns2tsc to convert between this unit to and
>>>>>> from nanoseconds.
>>>>>>
>>>>>> For more details, see:
>>>>>>
>>>>>>
>>>>>>
>>>>
>> http://www.xenomai.org/documentation/xenomai-2.6/html/api/group__native__timer.html
>>>>>>
>>>>>> Depending on how xenomai user-space was compiled, rt_timer_tsc should
>>>>>> have the lowest overhead.
>>>>>>
>>>>>
>>>>> And are the default options the best ones?
>>>>
>>>> Yes, but I am not sure the debian package uses the default one. Please
>>>> post here the disassembly of rt_timer_tsc, I will tell you if your
>>>> system is compiled for the lowest overhead.
>>>>
>>>>
>>> How to do that?
>>
>> arm-none-linux-objdump -d /path/to/libnative.so.3 | less
>> search <rt_timer_tsc>, when you find it, post the disassembly here.
>>
>
> Here it is:
>
> 00005a54 <rt_timer_tsc>:
> 5a54: e59f2034 ldr r2, [pc, #52] ; 5a90
> <rt_timer_tsc+0x3c>
> 5a58: e3e03a0f mvn r3, #61440 ; 0xf000
> 5a5c: e59f1030 ldr r1, [pc, #48] ; 5a94
> <rt_timer_tsc+0x40>
> 5a60: e08f2002 add r2, pc, r2
> 5a64: e5133003 ldr r3, [r3, #-3]
> 5a68: e7921001 ldr r1, [r2, r1]
> 5a6c: e59f0024 ldr r0, [pc, #36] ; 5a98
> <rt_timer_tsc+0x44>
> 5a70: e2833003 add r3, r3, #3
> 5a74: e0403283 sub r3, r0, r3, lsl #5
> 5a78: e92d4010 push {r4, lr}
> 5a7c: e5910008 ldr r0, [r1, #8]
> 5a80: e1a0e00f mov lr, pc
> 5a84: e12fff13 bx r3
> 5a88: e8bd4010 pop {r4, lr}
> 5a8c: e12fff1e bx lr
> 5a90: 000086a4 andeq r8, r0, r4, lsr #13
> 5a94: 000000ec andeq r0, r0, ip, ror #1
> 5a98: ffff1004 undefined instruction 0xffff1004
This is the good one.
--
Gilles.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai-help] Execution time profiling
2012-02-29 20:17 ` Gilles Chanteperdrix
@ 2012-02-29 20:42 ` Charles Lesire-Cabaniols
0 siblings, 0 replies; 11+ messages in thread
From: Charles Lesire-Cabaniols @ 2012-02-29 20:42 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: xenomai
[-- Attachment #1: Type: text/plain, Size: 4710 bytes --]
2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> On 02/29/2012 08:59 PM, Charles Lesire-Cabaniols wrote:
> > 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> >
> >> On 02/29/2012 08:44 PM, Charles Lesire-Cabaniols wrote:
> >>> 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> >>>
> >>>> On 02/29/2012 07:03 PM, Charles Lesire-Cabaniols wrote:
> >>>>> 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> >>>>>
> >>>>>> On 02/29/2012 06:52 PM, Charles Lesire-Cabaniols wrote:
> >>>>>>> 2012/2/29 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> >>>>>>>
> >>>>>>>> On 02/29/2012 06:29 PM, Charles Lesire-Cabaniols wrote:
> >>>>>>>>> Hi guys,
> >>>>>>>>>
> >>>>>>>>> I have installed a Debian+Xenomai (2.6.0) OS on my Gumstix Overo.
> >>>>>>>>>
> >>>>>>>>> I want to evaluate the execution time of a simple program,
> executed
> >>>> as
> >>>>>> a
> >>>>>>>>> real-time thread.
> >>>>>>>>>
> >>>>>>>>> I definitely wonder about which functions to use, as I have
> >>>> completely
> >>>>>>>>> inconsistent measures.
> >>>>>>>>> I have tried using rt_timer_read, rt_timer_tsc, clock_gettime.
> >>>>>>>>> I also directly read the CNNT register with ARM instructions
> (which
> >>>> is
> >>>>>>>> the
> >>>>>>>>> only one I think correct) in order to have a (good?) reference.
> >>>>>>>>> (...)
> >>>>>>>>> What am I doing wrong?
> >>>>>>>>
> >>>>>>>> So, you should printf("%Lu %Lu\n", rt_timer_read(),
> rt_timer_tsc());
> >>>>>>>>
> >>>>>>>> Not printf("%lu", ...)
> >>>>>>>>
> >>>>>>>> --
> >>>>>>>> Gilles.
> >>>>>>>>
> >>>>>>>
> >>>>>>> Effectively, that looks cleaner, thanks:
> >>>>>>>
> >>>>>>> ----- Xenomai rt_timer_read -----
> >>>>>>> start: 49166276042 ; end: 49166432273 ; (s-e): 156231 ; CET: 156231
> >>>>>>> ----- Xenomai rt_timer_tsc -----
> >>>>>>> start: 639161547 ; end: 639163539 ; (s-e): 1992 ; CET: 1992
> >>>>>>> ----- Xenomai clock_gettime -----
> >>>>>>> [ s] start: 946684855 ; end: 946684855 ; (s-e): 0 ; CET: 0
> >>>>>>> [ns] start: 275520245 ; end: 275677089 ; (s-e): 156844 ; CET:
> 156844
> >>>>>>>
> >>>>>>> My ARM instruction reads 110554.
> >>>>>>>
> >>>>>>> Which Xenomai function should I use?
> >>>>>>> Which one is supposed to be the more accurate?
> >>>>>>> Does rt_timer_read return nsecs?
> >>>>>>> What is the unit of rt_timer_tsc?
> >>>>>>
> >>>>>> rt_timer_tsc uses whatever hardware counter is available, you need
> >>>>>> rt_timer_tsc2ns or rt_timer_ns2tsc to convert between this unit to
> and
> >>>>>> from nanoseconds.
> >>>>>>
> >>>>>> For more details, see:
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>
> >>
> http://www.xenomai.org/documentation/xenomai-2.6/html/api/group__native__timer.html
> >>>>>>
> >>>>>> Depending on how xenomai user-space was compiled, rt_timer_tsc
> should
> >>>>>> have the lowest overhead.
> >>>>>>
> >>>>>
> >>>>> And are the default options the best ones?
> >>>>
> >>>> Yes, but I am not sure the debian package uses the default one. Please
> >>>> post here the disassembly of rt_timer_tsc, I will tell you if your
> >>>> system is compiled for the lowest overhead.
> >>>>
> >>>>
> >>> How to do that?
> >>
> >> arm-none-linux-objdump -d /path/to/libnative.so.3 | less
> >> search <rt_timer_tsc>, when you find it, post the disassembly here.
> >>
> >
> > Here it is:
> >
> > 00005a54 <rt_timer_tsc>:
> > 5a54: e59f2034 ldr r2, [pc, #52] ; 5a90
> > <rt_timer_tsc+0x3c>
> > 5a58: e3e03a0f mvn r3, #61440 ; 0xf000
> > 5a5c: e59f1030 ldr r1, [pc, #48] ; 5a94
> > <rt_timer_tsc+0x40>
> > 5a60: e08f2002 add r2, pc, r2
> > 5a64: e5133003 ldr r3, [r3, #-3]
> > 5a68: e7921001 ldr r1, [r2, r1]
> > 5a6c: e59f0024 ldr r0, [pc, #36] ; 5a98
> > <rt_timer_tsc+0x44>
> > 5a70: e2833003 add r3, r3, #3
> > 5a74: e0403283 sub r3, r0, r3, lsl #5
> > 5a78: e92d4010 push {r4, lr}
> > 5a7c: e5910008 ldr r0, [r1, #8]
> > 5a80: e1a0e00f mov lr, pc
> > 5a84: e12fff13 bx r3
> > 5a88: e8bd4010 pop {r4, lr}
> > 5a8c: e12fff1e bx lr
> > 5a90: 000086a4 andeq r8, r0, r4, lsr #13
> > 5a94: 000000ec andeq r0, r0, ip, ror #1
> > 5a98: ffff1004 undefined instruction 0xffff1004
>
> This is the good one.
>
> --
> Gilles.
>
Ok, thanks Gilles. Now I am more confident in my measurements! :)
Charles
[-- Attachment #2: Type: text/html, Size: 7681 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-02-29 20:42 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-29 17:29 [Xenomai-help] Execution time profiling Charles Lesire-Cabaniols
2012-02-29 17:40 ` Gilles Chanteperdrix
2012-02-29 17:52 ` Charles Lesire-Cabaniols
2012-02-29 18:01 ` Gilles Chanteperdrix
2012-02-29 18:03 ` Charles Lesire-Cabaniols
2012-02-29 18:40 ` Gilles Chanteperdrix
2012-02-29 19:44 ` Charles Lesire-Cabaniols
2012-02-29 19:48 ` Gilles Chanteperdrix
2012-02-29 19:59 ` Charles Lesire-Cabaniols
2012-02-29 20:17 ` Gilles Chanteperdrix
2012-02-29 20:42 ` Charles Lesire-Cabaniols
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.