[Openib-windows] [PATCH] cl_timer
Yossi Leybovich
sleybo at mellanox.co.il
Thu Sep 15 03:13:55 PDT 2005
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)
10x
Yossi
Singed-off-by: Yossi Leybovice (sleybo at mellanox.co.il)
--- C:\sleybo\OpenIB\core\complib\user\cl_timer.c Sun Sep 04 09:41:58 2005
+++ C:\sleybo\clean\core\complib\user\cl_timer.c Thu Sep 15 12:39:02 2005
@@ -149,6 +149,7 @@
#define SEC_TO_MICRO 1000000ULL // s to µs conversion
+#define SEC_TO_NANO 1000000000ULL // s to µs conversion
uint64_t
cl_get_time_stamp( void )
@@ -164,8 +165,48 @@
return( tick_count.QuadPart / (frequency.QuadPart / SEC_TO_MICRO) );
}
+uint64_t
+cl_get_time_stamp_nsec( void )
+{
+ LARGE_INTEGER tick_count, frequency;
+
+ if( !QueryPerformanceFrequency( &frequency ) )
+ return( 0 );
+
+ if( !QueryPerformanceCounter( &tick_count ) )
+ return( 0 );
+
+ return( tick_count.QuadPart / (frequency.QuadPart / SEC_TO_NANO) );
+}
+
+
+uint64_t
+cl_get_time_stamp_usec( void )
+{
+ LARGE_INTEGER tick_count, frequency;
+
+ if( !QueryPerformanceFrequency( &frequency ) )
+ return( 0 );
+
+ if( !QueryPerformanceCounter( &tick_count ) )
+ return( 0 );
+
+ return( tick_count.QuadPart / (frequency.QuadPart / SEC_TO_MICRO) );
+}
+
uint32_t
cl_get_time_stamp_sec( void )
{
return( (uint32_t)(cl_get_time_stamp() / SEC_TO_MICRO) );
}
+
+uint32_t
+cl_get_frequency( void )
+{
+ LARGE_INTEGER frequency;
+
+ if( !QueryPerformanceFrequency( &frequency ) )
+ return( 0 );
+ return (uint32_t)(frequency.QuadPart);
+}
+
--- C:\sleybo\OpenIB\inc\complib\cl_timer.h Sun Sep 04 09:42:22 2005
+++ C:\sleybo\clean\inc\complib\cl_timer.h Tue Aug 23 14:19:46 2005
@@ -351,6 +351,48 @@
* Timer, cl_get_time_stamp_sec
*********/
+/****f* Component Library: Time Stamp/cl_get_time_stamp_sec
+* NAME
+* cl_get_time_stamp_nsec
+*
+* DESCRIPTION
+* The cl_get_time_stamp_sec function returns the current time stamp in
+* seconds since the system was booted.
+*
+* SYNOPSIS
+*/
+
+CL_EXPORT uint64_t CL_API
+cl_get_time_stamp_nsec( void );
+/*
+* RETURN VALUE
+* Time elapsed, in nano seconds, since the system was booted.
+*
+* SEE ALSO
+* Timer, cl_get_time_stamp
+*********/
+
+/****f* Component Library: Time Stamp/cl_get_time_stamp_sec
+* NAME
+* cl_get_time_stamp_usec
+*
+* DESCRIPTION
+* The cl_get_time_stamp_sec function returns the current time stamp in
+* seconds since the system was booted.
+*
+* SYNOPSIS
+*/
+
+CL_EXPORT uint64_t CL_API
+cl_get_time_stamp_usec( void );
+/*
+* RETURN VALUE
+* Time elapsed, in micro seconds, since the system was booted.
+*
+* SEE ALSO
+* Timer, cl_get_time_stamp
+*********/
+
/****f* Component Library: Time Stamp/cl_get_time_stamp_sec
* NAME
@@ -372,6 +414,26 @@
* Timer, cl_get_time_stamp
*********/
+
+/****f* Component Library: Time Stamp/cl_get_frequency
+* NAME
+* cl_get_frequency
+*
+* DESCRIPTION
+* The cl_get_frequency function returns
+* the frequency of the high-resolution performance counter.
+*
+* SYNOPSIS
+*/
+CL_EXPORT uint32_t CL_API
+cl_get_frequency( void );
+/*
+* RETURN VALUE
+* the frequency of the high-resolution performance counter.
+*
+* SEE ALSO
+* Timer, cl_get_time_stamp
+*********/
#ifdef __cplusplus
} /* extern "C" */
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20050915/662bcff6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: timer.patch
Type: application/octet-stream
Size: 2995 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20050915/662bcff6/attachment.obj>
More information about the ofw
mailing list