コード例 #1
0
ファイル: vt_pform_ibm.c プロジェクト: bringhurst/ompi
/* platform specific initialization */
void vt_pform_init() {
  int  pid = getpid();
  char exec_proc[512];
  int  hostid_retries;

#if TIMER == TIMER_SWITCH_CLOCK
  int i;
  for (i=0; i<NUMRETRY; i++) {
    if ( (vt_swclk = swclockInit()) != 0 ) break;
  }
#elif TIMER == TIMER_POWER_REALTIME
  timebasestruct_t t;
  read_real_time(&t, TIMEBASE_SZ);
  time_base_to_time(&t, TIMEBASE_SZ);
  vt_time_base = t.tb_high - (t.tb_high & 0xFFFF);
#elif TIMER == TIMER_PAPI_REAL_USEC
  vt_time_base = vt_metric_real_usec();
#endif

  /* get full path of executable */
  snprintf(exec_proc, sizeof (exec_proc), VT_PROCDIR"%d/object/a.out", pid);
  vt_exec = strdup(exec_proc);

  /* get unique numeric SMP-node identifier */
  hostid_retries = 0;
  while( !vt_node_id && (hostid_retries++ < VT_MAX_GETHOSTID_RETRIES) ) {
    vt_node_id = gethostid();
  }
  if (!vt_node_id)
    vt_error_msg("Maximum retries (%i) for gethostid exceeded!",
		 VT_MAX_GETHOSTID_RETRIES);
}
コード例 #2
0
ファイル: aix.c プロジェクト: 559210/libpomelo
uint64_t uv__hrtime(void) {
  uint64_t G = 1000000000;
  timebasestruct_t t;
  read_wall_time(&t, TIMEBASE_SZ);
  time_base_to_time(&t, TIMEBASE_SZ);
  return (uint64_t) t.tb_high * G + t.tb_low;
}
コード例 #3
0
ファイル: aix.c プロジェクト: AbrahamJewowich/FreeSWITCH
static void _MD_AixIntervalInit(void)
{
    timebasestruct_t real_time;
    read_real_time(&real_time, TIMEBASE_SZ);
    (void)time_base_to_time(&real_time, TIMEBASE_SZ);
    _aix_baseline_epoch = real_time.tb_high;
}  /* _MD_AixIntervalInit */
コード例 #4
0
long long
vec_dummy_get_real_usec( void )
{
#if defined(__bgp__)
	return ( long long ) ( _bgp_GetTimeBase(  ) / frequency );
#elif defined(_WIN32)
	/*** NOTE: This differs from the code in win32.c ***/
	LARGE_INTEGER PerformanceCount, Frequency;
	QueryPerformanceCounter( &PerformanceCount );
	QueryPerformanceFrequency( &Frequency );
	return ( ( PerformanceCount.QuadPart * 1000000 ) / Frequency.QuadPart );
#elif defined(_AIX)   /* Heike: TODO: This needs to be tested on AIX with --with-no-cpu-counters */
	long long aix_usec;
	timebasestruct_t t;
	t = getticks(  );
	/* converts time base information to real time, if necessary.
	   It's recommended that applications unconditionally call time_base_to_time */
	time_base_to_time( &t, TIMEBASE_SZ );
	/* convert sec to micro-sec and nano-sec to micro-sec */
	aix_usec = ( t.tb_high * 1000000 ) + t.tb_low / 1000;
	/* return real time in micro-sec */
	return ( aix_usec );
#else
	return ( long long ) getticks(  ) / frequency;
#endif
}
コード例 #5
0
ファイル: time.cpp プロジェクト: Dykam/coreclr
BOOL
PALAPI
QueryPerformanceCounter(
    OUT LARGE_INTEGER *lpPerformanceCount
    )
{
    BOOL retval = TRUE;

    PERF_ENTRY(QueryPerformanceCounter);
    ENTRY("QueryPerformanceCounter()\n");
#if HAVE_CLOCK_MONOTONIC
    {
        struct timespec ts;
        if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0)
        {
            ASSERT("clock_gettime(CLOCK_MONOTONIC) failed; errno is %d (%s)\n", errno, strerror(errno));
            retval = FALSE;
            goto EXIT;
        }
        lpPerformanceCount->QuadPart = 
            (LONGLONG)ts.tv_sec * (LONGLONG)tccSecondsToNanoSeconds + (LONGLONG)ts.tv_nsec;
    }
#elif HAVE_GETHRTIME
    {
        lpPerformanceCount->QuadPart = (LONGLONG)gethrtime();
    }
#elif HAVE_READ_REAL_TIME
    {
        timebasestruct_t tb;
        read_real_time(&tb, TIMEBASE_SZ);
        if (time_base_to_time(&tb, TIMEBASE_SZ) != 0)
        {
            ASSERT("time_base_to_time() failed; errno is %d (%s)\n", errno, strerror(errno));
            retval = FALSE;
            goto EXIT;
        }
        lpPerformanceCount->QuadPart = 
            (LONGLONG)tb.tb_high * (LONGLONG)tccSecondsToNanoSeconds + (LONGLONG)tb.tb_low;
    }
#else
    {
        struct timeval tv;    
        if (gettimeofday(&tv, NULL) == -1)
        {
            ASSERT("gettimeofday() failed; errno is %d (%s)\n", errno, strerror(errno));
            retval = FALSE;
            goto EXIT;
        }
        lpPerformanceCount->QuadPart = 
            (LONGLONG)tv.tv_sec * (LONGLONG)tccSecondsToMicroSeconds + (LONGLONG)tv.tv_usec;    
    }
#endif // HAVE_CLOCK_MONOTONIC 
EXIT:
    LOGEXIT("QueryPerformanceCounter\n");
    PERF_EXIT(QueryPerformanceCounter);
    return retval;
}
コード例 #6
0
ファイル: timer.cpp プロジェクト: langou/latl
double LATL::Timer::Clock()
{
   double t;
   timebasestruct_t T;
   read_real_time(&T,TIMEBASE_SZ);
   time_base_to_time(&T,TIMEBASE_SZ);
   t=(double)(T.tb_low)*1.0e-03+(double)(T.tb_high)*1.0e+6;
   return t;
}
コード例 #7
0
ファイル: aix.c プロジェクト: AbrahamJewowich/FreeSWITCH
PRIntervalTime _MD_AixGetInterval(void)
{
    PRIntn rv;
    PRUint64 temp;
    timebasestruct_t real_time;
    read_real_time(&real_time, TIMEBASE_SZ);
    (void)time_base_to_time(&real_time, TIMEBASE_SZ);
    /* tb_high is in seconds, tb_low in 10(-9)seconds */
    temp = 1000000000ULL * (PRUint64)(real_time.tb_high - _aix_baseline_epoch);
    temp += (PRUint64)real_time.tb_low;  /* everything's 10(-9) seconds */
    temp >>= 16;  /* now it's something way different */
    return (PRIntervalTime)temp;
}  /* _MD_AixGetInterval */
コード例 #8
0
/* platform specific initialization */
void elg_pform_init() {
#ifdef USE_SWITCH_CLOCK
  int i;
  for (i=0; i<NUMRETRY; i++) {
    if ( (elg_swclk = swclockInit()) != 0 ) break;
  }
#else
  timebasestruct_t t;
  read_real_time(&t, TIMEBASE_SZ);
  time_base_to_time(&t, TIMEBASE_SZ);
  elg_time_base = t.tb_high - (t.tb_high & 0xFFFF);
#endif
}
コード例 #9
0
/* local or global wall-clock time in seconds */
double elg_pform_wtime() {
#ifdef USE_SWITCH_CLOCK
  int i;
  double t;
  for (i=0; i<NUMRETRY; i++) {
    if ( (t = swclockReadSec(elg_swclk)) != -1.0 ) return t;
  }
  return -1.0;
#else
  timebasestruct_t t;
  read_real_time(&t, TIMEBASE_SZ);
  time_base_to_time(&t, TIMEBASE_SZ);
  return (t.tb_high - elg_time_base) + (t.tb_low * 1.0e-9);
#endif
}
コード例 #10
0
ファイル: time.cpp プロジェクト: Dykam/coreclr
/*++
Function:
  GetTickCount64

Returns a 64-bit tick count with a millisecond resolution. It tries its best
to return monotonically increasing counts and avoid being affected by changes
to the system clock (either due to drift or due to explicit changes to system
time).
--*/
PALAPI
ULONGLONG
GetTickCount64()
{
    ULONGLONG retval = 0;

#if HAVE_CLOCK_MONOTONIC
    {
        struct timespec ts;
        if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0)
        {
            ASSERT("clock_gettime(CLOCK_MONOTONIC) failed; errno is %d (%s)\n", errno, strerror(errno));
            goto EXIT;
        }
        retval = (ts.tv_sec * tccSecondsToMillieSeconds)+(ts.tv_nsec / tccMillieSecondsToNanoSeconds);
    }
#elif HAVE_GETHRTIME
    {
        retval = (ULONGLONG)(gethrtime() / tccMillieSecondsToNanoSeconds);
    }
#elif HAVE_READ_REAL_TIME
    {
        timebasestruct_t tb;
        read_real_time(&tb, TIMEBASE_SZ);
        if (time_base_to_time(&tb, TIMEBASE_SZ) != 0)
        {
            ASSERT("time_base_to_time() failed; errno is %d (%s)\n", errno, strerror(errno));
            goto EXIT;
        }
        retval = (tb.tb_high * tccSecondsToMillieSeconds)+(tb.tb_low / tccMillieSecondsToNanoSeconds);
    }
#else
    {
        struct timeval tv;    
        if (gettimeofday(&tv, NULL) == -1)
        {
            ASSERT("gettimeofday() failed; errno is %d (%s)\n", errno, strerror(errno));
            goto EXIT;
        }
        retval = (tv.tv_sec * tccSecondsToMillieSeconds) + (tv.tv_usec / tccMillieSecondsToMicroSeconds);
    }
#endif // HAVE_CLOCK_MONOTONIC 
EXIT:    
    return retval;
}
コード例 #11
0
ファイル: rs6000_time.c プロジェクト: ZJLi2013/petsc
PetscLogDouble  PetscReadRealTime(void)
{
  timebasestruct_t t;
  PetscLogDouble   time;

  PetscFunctionBegin;
  /* read in the register values */
  read_real_time(&t,TIMEBASE_SZ);

  /*
   * Call the conversion routines unconditionally, to ensure
   * that both values are in seconds and nanoseconds regardless
   * of the hardware platform.
   */
  time_base_to_time(&t,TIMEBASE_SZ);
  time = t.tb_high + t.tb_low*1.0e-9;
  PetscFunctionReturn(time);
}
コード例 #12
0
ファイル: vt_pform_ibm.c プロジェクト: bringhurst/ompi
/* local or global wall-clock time */
uint64_t vt_pform_wtime() {
#if TIMER == TIMER_SWITCH_CLOCK
  int i;
  int64_t t;
  for (i=0; i<NUMRETRY; i++) {
    if ( (t = swclockRead(vt_swclk)) != -1 ) return t;
  }
  return 0;
#elif TIMER == TIMER_POWER_REALTIME
  timebasestruct_t t;
  read_real_time(&t, TIMEBASE_SZ);
  time_base_to_time(&t, TIMEBASE_SZ);
  return ((t.tb_high - vt_time_base) * 1e9) + t.tb_low;
#elif TIMER == TIMER_PAPI_REAL_CYC
  return vt_metric_real_cyc();
#elif TIMER == TIMER_PAPI_REAL_USEC
  return vt_metric_real_usec() - vt_time_base;
#endif
}
コード例 #13
0
long long
vec_dummy_get_real_cycles( void )
{
#if defined(__bgp__)
	return _bgp_GetTimeBase(  );
#elif defined(_WIN32)
#elif defined(_AIX)   /* Heike: TODO: This needs to be tested on AIX with --with-no-cpu-counters */
	long long aix_usec;
	timebasestruct_t t;
	t = getticks(  );
	/* converts time base information to real time, if necessary.
	 It's recommended that applications unconditionally call time_base_to_time */
	time_base_to_time( &t, TIMEBASE_SZ );
	/* convert sec to micro-sec and nano-sec to micro-sec */
	aix_usec = ( t.tb_high * 1000000 ) + t.tb_low / 1000;
	return ( aix_usec * frequency );
#else
	return ( long long ) getticks(  );
#endif
}
コード例 #14
0
long long
vec_dummy_get_virt_usec( hwd_context_t * zero )
{
	( void ) zero;			 /*unused */
#if defined(__bgp__)
	return ( long long ) ( _bgp_GetTimeBase(  ) / frequency );
#elif defined(_WIN32)
	/*** NOTE: This differs from the code in win32.c ***/
	long long retval;
	HANDLE p;
	BOOL ret;
	FILETIME Creation, Exit, Kernel, User;
	long long virt;
	p = GetCurrentProcess(  );
	ret = GetProcessTimes( p, &Creation, &Exit, &Kernel, &User );
	if ( ret ) {
		virt =
			( ( ( long long ) ( Kernel.dwHighDateTime +
								User.dwHighDateTime ) ) << 32 )
			+ Kernel.dwLowDateTime + User.dwLowDateTime;
		retval = virt / 1000;
	} else
		return ( PAPI_ESBSTR );
#elif defined(_AIX)   /* Heike: TODO: This needs to be tested on AIX with --with-no-cpu-counters */
	long long aix_usec;
	timebasestruct_t t;
	t = getticks(  );
	/* converts time base information to real time, if necessary.
	 It's recommended that applications unconditionally call time_base_to_time */
	time_base_to_time( &t, TIMEBASE_SZ );
	/* convert sec to micro-sec and nano-sec to micro-sec */
	aix_usec = ( t.tb_high * 1000000 ) + t.tb_low / 1000;
	/* return real time in micro-sec */
	return ( aix_usec );
#else
	return ( long long ) getticks(  ) / frequency;
#endif
}
コード例 #15
0
ファイル: hrtime.c プロジェクト: AllenJB/php-src
static zend_always_inline php_hrtime_t _timer_current(void)
{/*{{{*/
#if PHP_HRTIME_PLATFORM_WINDOWS
	LARGE_INTEGER lt = {0};
	QueryPerformanceCounter(&lt);
	return (php_hrtime_t)((php_hrtime_t)lt.QuadPart * _timer_scale);
#elif PHP_HRTIME_PLATFORM_APPLE
	return (php_hrtime_t)mach_absolute_time() * _timerlib_info.numer / _timerlib_info.denom;
#elif PHP_HRTIME_PLATFORM_POSIX
	struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 };
	if (0 == clock_gettime(CLOCK_MONOTONIC, &ts)) {
		return ((php_hrtime_t) ts.tv_sec * (php_hrtime_t)NANO_IN_SEC) + ts.tv_nsec;
	}
	return 0;
#elif PHP_HRTIME_PLATFORM_HPUX
	return (php_hrtime_t) gethrtime();
#elif  PHP_HRTIME_PLATFORM_AIX
	timebasestruct_t t;
	read_wall_time(&t, TIMEBASE_SZ);
	time_base_to_time(&t, TIMEBASE_SZ);
	return (php_hrtime_t) t.tb_high * (php_hrtime_t)NANO_IN_SEC + t.tb_low;
#else
	return 0;
#endif
}/*}}}*/

#if ZEND_ENABLE_ZVAL_LONG64
#define PHP_RETURN_HRTIME(t) RETURN_LONG((zend_long)t)
#else
#ifdef _WIN32
# define HRTIME_U64A(i, s, len) _ui64toa_s(i, s, len, 10)
#else
# define HRTIME_U64A(i, s, len) \
	do { \
		int st = snprintf(s, len, "%llu", i); \
		s[st] = '\0'; \
	} while (0)
#endif
#define PHP_RETURN_HRTIME(t) do { \
	char _a[ZEND_LTOA_BUF_LEN]; \
	double _d; \
	HRTIME_U64A(t, _a, ZEND_LTOA_BUF_LEN); \
	_d = zend_strtod(_a, NULL); \
	RETURN_DOUBLE(_d); \
	} while (0)
#endif

/* {{{ proto mixed hrtime([bool get_as_number = false])
	Returns an array of integers in form [seconds, nanoseconds] counted
	from an arbitrary point in time. If an optional boolean argument is
	passed, returns an integer on 64-bit platforms or float on 32-bit
	containing the current high-resolution time in nanoseconds. The
	delivered timestamp is monotonic and can not be adjusted. */
PHP_FUNCTION(hrtime)
{
#if HRTIME_AVAILABLE
	zend_bool get_as_num = 0;
	php_hrtime_t t = _timer_current();

	ZEND_PARSE_PARAMETERS_START(0, 1)
		Z_PARAM_OPTIONAL
		Z_PARAM_BOOL(get_as_num)
	ZEND_PARSE_PARAMETERS_END();

	if (UNEXPECTED(get_as_num)) {
		PHP_RETURN_HRTIME(t);
	} else {
		array_init_size(return_value, 2);
		zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
		add_next_index_long(return_value, (zend_long)(t / (php_hrtime_t)NANO_IN_SEC));
		add_next_index_long(return_value, (zend_long)(t % (php_hrtime_t)NANO_IN_SEC));
	}
#else
	RETURN_FALSE
#endif
}
/* }}} */

PHPAPI php_hrtime_t php_hrtime_current(void)
{/*{{{*/
	return _timer_current();
}/*}}}*/