Hi,

That could be done, but loop_time must be a float. It could replace the single 
long loop ...

        while (count < BUSY_LOOP_CNT_LONG) {
            count++;
        };

... after this patch is applied. I just want to get rid of the minute long wait 
ASAP. The loop can be tuned and verified on multiple CPUs with frequency 
scaling afterwards.

-Petri


> -----Original Message-----
> From: EXT Ivan Khoronzhuk [mailto:[email protected]]
> Sent: Thursday, April 14, 2016 5:39 PM
> To: Savolainen, Petri (Nokia - FI/Espoo) <[email protected]>;
> [email protected]
> Subject: Re: [lng-odp] [PATCH] validation: time: shorten test duration
> 
> What about to do smth like below
> (I didn't normalize it to ns...but that are tehnical details)
> 
>       uint64_t c1, c2;
>       uint64_t loop_time;
> 
>       c1 = odp_cpu_cycles();
> 
>       while (loop_time <= 4) {
>               c2 = odp_cpu_cycles();
>               cycle_diff = odp_cpu_cycles_diff(c2, c1);
>               loop_time += cycle_diff / odp_cpu_hz();
>               c1 = c2;
>       };
> 
> 
> On 14.04.16 17:24, Ivan Khoronzhuk wrote:
> >
> >
> > On 14.04.16 17:15, Savolainen, Petri (Nokia - FI/Espoo) wrote:
> >> Hi,
> >>
> >> I said back then that we need one test case that runs longer than 4
> sec, other test cases can be shorter. This patch  does that - combines
> long lasting tests into single >4sec run.
> >>
> >> The rationale for shorter duration is that many of us need to run 'make
> check' multiple times a day and the benefit from every second we can save
> is multiplied by the number users and test runs per user. This patch saves
> roughly 40 seconds per user per test run.
> >>
> >> Optimally, time validation test should be able to verify the API in a
> bit more than 4 seconds. Also a single, very long test case makes people
> wonder if the system hanged...
> >>
> >> You could add a configure option for a longer test run, but by default
> the time test (or any other test) should not take a minute.
> >>
> >> -Petri
> > That's because there is no general way to get correct CPU freq,
> > in another way it's possible to figure out needed number of loops in
> runtime...
> >
> >>
> >>
> >>> -----Original Message-----
> >>> From: EXT Ivan Khoronzhuk [mailto:[email protected]]
> >>> Sent: Thursday, April 14, 2016 5:00 PM
> >>> To: Savolainen, Petri (Nokia - FI/Espoo) <[email protected]>;
> >>> [email protected]
> >>> Subject: Re: [lng-odp] [PATCH] validation: time: shorten test duration
> >>>
> >>> Hi, Petri.
> >>>
> >>> As far I remember you was OK to increase time of testing on even more
> >>> time.
> >>> It was supposed to include future freqs...I know, for now it's not
> >>> correct..
> >>> but anyway. Also I dislike the idea to combine two separate tests in
> one
> >>> function.
> >>> Yes, it makes tests faster, but doesn't reflect unit test nature.
> Also,
> >>> Ok,
> >>> you've made test shorter supposing that freq can not be fast enough to
> >>> exit the
> >>> 4sec range, you've saved ~ minute, but why you decrease 5 sec to 3
> sec, it
> >>> helps to
> >>> see sense of time......and can be missed easily.
> >>>
> >>> On 14.04.16 14:41, Petri Savolainen wrote:
> >>>> Time test duration was almost a minute on a 2.6GHz CPU.
> >>>> Combined local and global time monotonity tests, so that
> >>>> the there is only single run of the long wait loop.
> >>>> Shortened wait test time to 3 seconds and long loop into
> >>>> roughly 14 seconds on a 2.6GHz CPU. There should be enough
> >>>> head room to keep loop duration over 4 seconds even with
> >>>> higher CPU frequencies.
> >>>>
> >>>> Signed-off-by: Petri Savolainen <[email protected]>
> >>>> ---
> >>>>    test/validation/time/time.c | 63 ++++++++++++++++++++++++---------
> ----
> >>> --------
> >>>>    test/validation/time/time.h |  3 +--
> >>>>    2 files changed, 35 insertions(+), 31 deletions(-)
> >>>>
> >>>> diff --git a/test/validation/time/time.c
> b/test/validation/time/time.c
> >>>> index cb1ddef..5e55817 100644
> >>>> --- a/test/validation/time/time.c
> >>>> +++ b/test/validation/time/time.c
> >>>> @@ -9,10 +9,11 @@
> >>>>    #include "time.h"
> >>>>
> >>>>    #define BUSY_LOOP_CNT        30000000    /* used for t > min
> >>> resolution */
> >>>> -#define BUSY_LOOP_CNT_LONG    12000000000 /* used for t > 4 sec */
> >>>> +#define BUSY_LOOP_CNT_LONG    6000000000  /* used for t > 4 sec */
> >>>>    #define MIN_TIME_RATE        32000
> >>>>    #define MAX_TIME_RATE        15000000000
> >>>>    #define DELAY_TOLERANCE        20000000        /* deviation for
> delay
> >>> */
> >>>> +#define WAIT_SECONDS            3
> >>>>
> >>>>    static uint64_t local_res;
> >>>>    static uint64_t global_res;
> >>>> @@ -98,42 +99,45 @@ void time_test_global_conversion(void)
> >>>>        time_test_conversion(odp_time_global_from_ns, global_res);
> >>>>    }
> >>>>
> >>>> -static void time_test_monotony(time_cb time)
> >>>> +void time_test_monotony(void)
> >>>>    {
> >>>>        volatile uint64_t count = 0;
> >>>> -    odp_time_t t1, t2, t3;
> >>>> +    odp_time_t l_t1, l_t2, l_t3;
> >>>> +    odp_time_t g_t1, g_t2, g_t3;
> >>>>        uint64_t ns1, ns2, ns3;
> >>>>
> >>>> -    t1 = time();
> >>>> +    l_t1 = odp_time_local();
> >>>> +    g_t1 = odp_time_global();
> >>>>
> >>>>        while (count < BUSY_LOOP_CNT) {
> >>>>            count++;
> >>>>        };
> >>>>
> >>>> -    t2 = time();
> >>>> +    l_t2 = odp_time_local();
> >>>> +    g_t2 = odp_time_global();
> >>>>
> >>>>        while (count < BUSY_LOOP_CNT_LONG) {
> >>>>            count++;
> >>>>        };
> >>>>
> >>>> -    t3 = time();
> >>>> +    l_t3 = odp_time_local();
> >>>> +    g_t3 = odp_time_global();
> >>>>
> >>>> -    ns1 = odp_time_to_ns(t1);
> >>>> -    ns2 = odp_time_to_ns(t2);
> >>>> -    ns3 = odp_time_to_ns(t3);
> >>>> +    ns1 = odp_time_to_ns(l_t1);
> >>>> +    ns2 = odp_time_to_ns(l_t2);
> >>>> +    ns3 = odp_time_to_ns(l_t3);
> >>>>
> >>>> +    /* Local time assertions */
> >>>>        CU_ASSERT(ns2 > ns1);
> >>>>        CU_ASSERT(ns3 > ns2);
> >>>> -}
> >>>>
> >>>> -void time_test_local_monotony(void)
> >>>> -{
> >>>> -    time_test_monotony(odp_time_local);
> >>>> -}
> >>>> +    ns1 = odp_time_to_ns(g_t1);
> >>>> +    ns2 = odp_time_to_ns(g_t2);
> >>>> +    ns3 = odp_time_to_ns(g_t3);
> >>>>
> >>>> -void time_test_global_monotony(void)
> >>>> -{
> >>>> -    time_test_monotony(odp_time_global);
> >>>> +    /* Global time assertions */
> >>>> +    CU_ASSERT(ns2 > ns1);
> >>>> +    CU_ASSERT(ns3 > ns2);
> >>>>    }
> >>>>
> >>>>    static void time_test_cmp(time_cb time, time_from_ns_cb
> time_from_ns)
> >>>> @@ -324,16 +328,18 @@ static void time_test_wait_until(time_cb time,
> >>> time_from_ns_cb time_from_ns)
> >>>>
> >>>>        start_time = time();
> >>>>        wait = start_time;
> >>>> -    for (i = 1; i < 6; i++) {
> >>>> +    for (i = 0; i < WAIT_SECONDS; i++) {
> >>>>            wait = odp_time_sum(wait, second);
> >>>>            odp_time_wait_until(wait);
> >>>> -        printf("%d..", i);
> >>>> +        printf("%d..", i + 1);
> >>>>        }
> >>>>        end_time = time();
> >>>>
> >>>>        wait = odp_time_diff(end_time, start_time);
> >>>> -    lower_limit = time_from_ns(5 * ODP_TIME_SEC_IN_NS -
> >>> DELAY_TOLERANCE);
> >>>> -    upper_limit = time_from_ns(5 * ODP_TIME_SEC_IN_NS +
> >>> DELAY_TOLERANCE);
> >>>> +    lower_limit = time_from_ns(WAIT_SECONDS * ODP_TIME_SEC_IN_NS -
> >>>> +                   DELAY_TOLERANCE);
> >>>> +    upper_limit = time_from_ns(WAIT_SECONDS * ODP_TIME_SEC_IN_NS +
> >>>> +                   DELAY_TOLERANCE);
> >>>>
> >>>>        CU_ASSERT(odp_time_cmp(wait, lower_limit) >= 0);
> >>>>        CU_ASSERT(odp_time_cmp(wait, upper_limit) <= 0);
> >>>> @@ -356,18 +362,18 @@ void time_test_wait_ns(void)
> >>>>        odp_time_t start_time, end_time, diff;
> >>>>
> >>>>        start_time = odp_time_local();
> >>>> -    for (i = 1; i < 6; i++) {
> >>>> +    for (i = 0; i < WAIT_SECONDS; i++) {
> >>>>            odp_time_wait_ns(ODP_TIME_SEC_IN_NS);
> >>>> -        printf("%d..", i);
> >>>> +        printf("%d..", i + 1);
> >>>>        }
> >>>>        end_time = odp_time_local();
> >>>>
> >>>>        diff = odp_time_diff(end_time, start_time);
> >>>>
> >>>> -    lower_limit = odp_time_local_from_ns(5 * ODP_TIME_SEC_IN_NS -
> >>>> -                            DELAY_TOLERANCE);
> >>>> -    upper_limit = odp_time_local_from_ns(5 * ODP_TIME_SEC_IN_NS +
> >>>> -                            DELAY_TOLERANCE);
> >>>> +    lower_limit = odp_time_local_from_ns(WAIT_SECONDS *
> >>> ODP_TIME_SEC_IN_NS -
> >>>> +                         DELAY_TOLERANCE);
> >>>> +    upper_limit = odp_time_local_from_ns(WAIT_SECONDS *
> >>> ODP_TIME_SEC_IN_NS +
> >>>> +                         DELAY_TOLERANCE);
> >>>>
> >>>>        CU_ASSERT(odp_time_cmp(diff, lower_limit) >= 0);
> >>>>        CU_ASSERT(odp_time_cmp(diff, upper_limit) <= 0);
> >>>> @@ -412,7 +418,6 @@ odp_testinfo_t time_suite_time[] = {
> >>>>        ODP_TEST_INFO(time_test_constants),
> >>>>        ODP_TEST_INFO(time_test_local_res),
> >>>>        ODP_TEST_INFO(time_test_local_conversion),
> >>>> -    ODP_TEST_INFO(time_test_local_monotony),
> >>>>        ODP_TEST_INFO(time_test_local_cmp),
> >>>>        ODP_TEST_INFO(time_test_local_diff),
> >>>>        ODP_TEST_INFO(time_test_local_sum),
> >>>> @@ -421,12 +426,12 @@ odp_testinfo_t time_suite_time[] = {
> >>>>        ODP_TEST_INFO(time_test_local_to_u64),
> >>>>        ODP_TEST_INFO(time_test_global_res),
> >>>>        ODP_TEST_INFO(time_test_global_conversion),
> >>>> -    ODP_TEST_INFO(time_test_global_monotony),
> >>>>        ODP_TEST_INFO(time_test_global_cmp),
> >>>>        ODP_TEST_INFO(time_test_global_diff),
> >>>>        ODP_TEST_INFO(time_test_global_sum),
> >>>>        ODP_TEST_INFO(time_test_global_wait_until),
> >>>>        ODP_TEST_INFO(time_test_global_to_u64),
> >>>> +    ODP_TEST_INFO(time_test_monotony),
> >>>>        ODP_TEST_INFO_NULL
> >>>>    };
> >>>>
> >>>> diff --git a/test/validation/time/time.h
> b/test/validation/time/time.h
> >>>> index d75b0f5..3911814 100644
> >>>> --- a/test/validation/time/time.h
> >>>> +++ b/test/validation/time/time.h
> >>>> @@ -15,8 +15,6 @@ void time_test_local_res(void);
> >>>>    void time_test_global_res(void);
> >>>>    void time_test_local_conversion(void);
> >>>>    void time_test_global_conversion(void);
> >>>> -void time_test_local_monotony(void);
> >>>> -void time_test_global_monotony(void);
> >>>>    void time_test_local_cmp(void);
> >>>>    void time_test_global_cmp(void);
> >>>>    void time_test_local_diff(void);
> >>>> @@ -28,6 +26,7 @@ void time_test_global_wait_until(void);
> >>>>    void time_test_wait_ns(void);
> >>>>    void time_test_local_to_u64(void);
> >>>>    void time_test_global_to_u64(void);
> >>>> +void time_test_monotony(void);
> >>>>
> >>>>    /* test arrays: */
> >>>>    extern odp_testinfo_t time_suite_time[];
> >>>>
> >>>
> >>> --
> >>> Regards,
> >>> Ivan Khoronzhuk
> >
> 
> --
> Regards,
> Ivan Khoronzhuk
_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to