[Openib-windows] RE: [PATCH] cl_timer

Fab Tillier ftillier at silverstorm.com
Mon Sep 19 00:43:05 PDT 2005


> From: Yossi Leybovich [mailto:sleybo at mellanox.co.il]
> Sent: Sunday, September 18, 2005 1:07 AM
> 
> > -----Original Message-----
> > From: Fab Tillier [mailto:ftillier at silverstorm.com]
> > Sent: Thursday, September 15, 2005 7:10 PM
> >
> > > From: Yossi Leybovich [mailto:sleybo at mellanox.co.il]
> > > Sent: Thursday, September 15, 2005 3:14 AM
> > >
> > > Fab
> > > Attached patch for supporting nsec in timer stamp and provide way to
> > > get the CPU freq We use this in our performance tests (I hope that we
> > > upload them, to the OpenIB in the near future) (I left the
> > > cl_get_time_stamp_sec as is so we will not require to change old code)
> >
> > Why add the cl_get_time_stamp_usec function when
> > cl_get_time_stamp is identical? Why not just use the existing
> > function?  At a minimum, why not call the existing function
> > rather than duplicating it?
>
> I did not want to change the interface of existing code ,
> but you right the cl_get_time_stamp and cl_get_time_stamp_usec do the same
> I want new code to use cl_get_time_stamp_usec and later change existing code
> to use it.

Ok, I changed the cl_get_time_stamp_usec to be an inline function declared in
cl_timer.h (the common file).  We should be able to change which function is an
inline for which at a later time.

> > Also, for performance tests it would probably be better (lower impact of
> > counters) to have two functions - one to return the raw tick count, and
> > the other to return the frequency.  That way, you only perform the
> > conversion to human readable time units after the test completes, rather
> > than at runtime.
> >
> > If this is OK, I can code this up - it will add two
> > functions, cl_get_tick_count, and cl_get_tick_freq.
>
> OK its fine with me , the moment you check it in I will change the perf_main.
> (BTW I think I already add function to get the freq)

I coded this and committed it in revision 76.  I also added the kernel
implementation.  Note that cl_get_tick_perf returns a 64-bit unsigned integer,
rather than 32-bit.

Let me know if you run into any problems.

Thanks,

- Fab

Signed-off-by: Fab Tillier (ftillier at silverstorm.com)
Index: core/complib/user/cl_timer.c
===================================================================
--- core/complib/user/cl_timer.c	(revision 72)
+++ core/complib/user/cl_timer.c	(working copy)
@@ -169,3 +169,27 @@
 {
 	return( (uint32_t)(cl_get_time_stamp() / SEC_TO_MICRO) );
 }
+
+
+uint64_t
+cl_get_tick_count( void )
+{
+	LARGE_INTEGER	tick_count;
+
+	if( !QueryPerformanceCounter( &tick_count ) )
+		return( 0 );
+
+	return tick_count.QuadPart;
+}
+
+
+uint64_t
+cl_get_tick_freq( void )
+{
+	LARGE_INTEGER	frequency;
+
+	if( !QueryPerformanceFrequency( &frequency ) )
+		return( 0 );
+
+	return frequency.QuadPart;
+}
Index: inc/kernel/complib/cl_timer_osd.h
===================================================================
--- inc/kernel/complib/cl_timer_osd.h	(revision 72)
+++ inc/kernel/complib/cl_timer_osd.h	(working copy)
@@ -77,6 +77,24 @@
 	return( (uint32_t)(KeQueryInterruptTime() / HUNDREDNS_TO_SEC) );
 }
 
+CL_INLINE uint64_t CL_API
+cl_get_tick_count( void )
+{
+	LARGE_INTEGER	tick_count;
+
+	tick_count = KeQueryPerformanceCounter( NULL );
+	return tick_count.QuadPart;
+}
+
+CL_INLINE uint64_t CL_API
+cl_get_tick_freq( void )
+{
+	LARGE_INTEGER	frequency;
+
+	KeQueryPerformanceCounter( &frequency );
+	return frequency.QuadPart;
+}
+
 #ifdef __cplusplus
 }	/* extern "C" */
 #endif
Index: inc/complib/cl_timer.h
===================================================================
--- inc/complib/cl_timer.h	(revision 72)
+++ inc/complib/cl_timer.h	(working copy)
@@ -348,10 +348,34 @@
 *	Time elapsed, in microseconds, since the system was booted.
 *
 * SEE ALSO
-*	Timer, cl_get_time_stamp_sec
+*	Timer, cl_get_time_stamp_usec, cl_get_time_stamp_sec
 *********/
 
 
+/****f* Component Library: Time Stamp/cl_get_time_stamp_usec
+* NAME
+*	cl_get_time_stamp_usec
+*
+* DESCRIPTION
+*	The cl_get_time_stamp_usec function returns the current time stamp in
+*	microseconds since the system was booted.
+*
+* SYNOPSIS
+*/
+CL_INLINE uint64_t CL_API
+cl_get_time_stamp_usec( void )
+{
+	return cl_get_time_stamp();
+}
+/*
+* RETURN VALUE
+*	Time elapsed, in microseconds, since the system was booted.
+*
+* SEE ALSO
+*	Timer, cl_get_time_stamp, cl_get_time_stamp_sec
+*********/
+
+
 /****f* Component Library: Time Stamp/cl_get_time_stamp_sec
 * NAME
 *	cl_get_time_stamp_sec
@@ -373,6 +397,48 @@
 *********/
 
 
+/****f* Component Library: Time Stamp/cl_get_tick_count
+* NAME
+*	cl_get_tick_count
+*
+* DESCRIPTION
+*	The cl_get_tick_count function returns the raw high-resolution
+*	performance counter value.
+*
+* SYNOPSIS
+*/
+CL_EXPORT uint64_t CL_API
+cl_get_tick_count( void );
+/*
+* RETURN VALUE
+*	Value of the high-resolution performance counter.
+*
+* SEE ALSO
+*	Timer, cl_get_time_stamp, cl_get_tick_freq
+*********/
+
+
+/****f* Component Library: Time Stamp/cl_get_tick_freq
+* NAME
+*	cl_get_tick_freq
+*
+* DESCRIPTION
+*	The cl_get_tick_freq function returns the frequency of the
+*	high-resolution performance counter.
+*
+* SYNOPSIS
+*/
+CL_EXPORT uint64_t CL_API
+cl_get_tick_freq( void );
+/*
+* RETURN VALUE
+*	The frequency of the high-resolution performance counter.
+*
+* SEE ALSO
+*	Timer, cl_get_time_stamp, cl_get_tick_count
+*********/
+
+
 #ifdef __cplusplus
 }	/* extern "C" */
 #endif




More information about the ofw mailing list