From: ftillier Date: Mon, 19 Sep 2005 07:32:51 +0000 (+0000) Subject: [COMPLIB] Add support for retrieveing high resolution counter tick X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=e8b1d5a2661b0ac5f30f97008a360890ae52b975;p=~shefty%2Frdma-win.git [COMPLIB] Add support for retrieveing high resolution counter tick count and frequency. Signed-off-by: Fab Tillier (ftillier@silverstorm.com) Signed-off-by: Yossi Leybovich (sleybo@mellanox.co.il) git-svn-id: svn://openib.tc.cornell.edu/gen1@75 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/trunk/core/complib/user/cl_timer.c b/trunk/core/complib/user/cl_timer.c index 9df169f4..81c5b922 100644 --- a/trunk/core/complib/user/cl_timer.c +++ b/trunk/core/complib/user/cl_timer.c @@ -169,3 +169,27 @@ cl_get_time_stamp_sec( void ) { 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_frequency( void ) +{ + LARGE_INTEGER frequency; + + if( !QueryPerformanceFrequency( &frequency ) ) + return( 0 ); + + return frequency.QuadPart; +} diff --git a/trunk/inc/complib/cl_timer.h b/trunk/inc/complib/cl_timer.h index a7f36249..7ea26417 100644 --- a/trunk/inc/complib/cl_timer.h +++ b/trunk/inc/complib/cl_timer.h @@ -348,7 +348,31 @@ cl_get_time_stamp( void ); * 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 *********/ @@ -373,6 +397,48 @@ cl_get_time_stamp_sec( void ); *********/ +/****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_frequency +*********/ + + +/****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 uint64_t CL_API +cl_get_frequency( 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 diff --git a/trunk/inc/kernel/complib/cl_timer_osd.h b/trunk/inc/kernel/complib/cl_timer_osd.h index c7c51151..e09813b3 100644 --- a/trunk/inc/kernel/complib/cl_timer_osd.h +++ b/trunk/inc/kernel/complib/cl_timer_osd.h @@ -77,6 +77,24 @@ cl_get_time_stamp_sec( void ) 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_frequency( void ) +{ + LARGE_INTEGER frequency; + + KeQueryPerformanceCounter( &frequency ); + return frequency.QuadPart; +} + #ifdef __cplusplus } /* extern "C" */ #endif