[ofa-general] Re: [PATCH] uDAPL fix DT_Mdep_GetTime

Arlin Davis ardavis at ichips.intel.com
Tue Oct 2 16:04:03 PDT 2007


Anton Blanchard wrote:
> Hi,
> 
>> The userspace DT_Mdep_GetTime() function is supposed to output the time in
>> milliseconds. It uses the times() syscall to do this, and uses the
>> CLOCKS_PER_SEC define to scale it. On PowerPC this is hardwired to
>> 1000000 which leads to bogus values.
> 
> Note also that times() is pretty low resolution, Id suggest using
> gettimeofday(). What do you think?

Thanks, committed for 1.2 and 2.0.

> 
> --
> 
> Change DT_Mdep_GetTime to use gettimeofday() which has more resolution
> than times().
> 
> Signed-off-by: Anton Blanchard <anton at samba.org>
> ---
> 
> diff --git a/test/dapltest/mdep/linux/dapl_mdep_user.c b/test/dapltest/mdep/linux/dapl_mdep_user.c
> index 1e2d44b..c5738e1 100644
> --- a/test/dapltest/mdep/linux/dapl_mdep_user.c
> +++ b/test/dapltest/mdep/linux/dapl_mdep_user.c
> @@ -176,9 +176,9 @@ DT_Mdep_GetCpuStat (
>  unsigned long
>  DT_Mdep_GetTime (void)
>  {
> -    struct tms      ts;
> -    clock_t         t = times (&ts);
> -    return (unsigned long) ((DAT_UINT64) t * 1000 / CLOCKS_PER_SEC);
> +    struct timeval tv;
> +    gettimeofday(&tv, NULL);
> +    return tv.tv_sec * 1000 + tv.tv_usec / 1000;
>  }
>  
>  double
> 



More information about the general mailing list