* add support for reading the PowerPC timebase
* add support to Linux timer for getting the frequency of the Timebase on a PPC Linux box This commit was SVN r6947.
Этот коммит содержится в:
родитель
1fe9356d37
Коммит
edbcdf0dac
48
opal/include/sys/powerpc/timer.h
Обычный файл
48
opal/include/sys/powerpc/timer.h
Обычный файл
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef OMPI_SYS_ARCH_TIMER_H
|
||||
#define OMPI_SYS_ARCH_TIMER_H 1
|
||||
|
||||
|
||||
typedef uint64_t opal_timer_t;
|
||||
|
||||
|
||||
#if OMPI_GCC_INLINE_ASSEMBLY
|
||||
|
||||
static inline opal_timer_t
|
||||
opal_sys_timer_get_cycles(void)
|
||||
{
|
||||
unsigned int tbl, tbu0, tbu1;
|
||||
|
||||
do {
|
||||
__asm__ __volatile__ ("mftbu %0" : "=r"(tbu0));
|
||||
__asm__ __volatile__ ("mftb %0" : "=r"(tbl));
|
||||
__asm__ __volatile__ ("mftbu %0" : "=r"(tbu1));
|
||||
} while (tbu0 != tbu1);
|
||||
|
||||
return (((unsigned long long)tbu0) << 32) | tbl;
|
||||
}
|
||||
|
||||
#define OPAL_HAVE_SYS_TIMER_GET_CYCLES 1
|
||||
|
||||
#else
|
||||
|
||||
#define OPAL_HAVE_SYS_TIMER_GET_CYCLES 0
|
||||
|
||||
#endif /* OMPI_GCC_INLINE_ASSEMBLY */
|
||||
|
||||
#endif /* ! OMPI_SYS_ARCH_TIMER_H */
|
@ -76,6 +76,10 @@
|
||||
#include "opal/include/sys/ia32/timer.h"
|
||||
#elif OMPI_ASSEMBLY_ARCH == OMPI_IA64
|
||||
#include "opal/include/sys/ia64/timer.h"
|
||||
#elif OMPI_ASSEMBLY_ARCH == OMPI_POWERPC32
|
||||
#include "include/sys/powerpc/timer.h"
|
||||
#elif OMPI_ASSEMBLY_ARCH == OMPI_POWERPC64
|
||||
#include "include/sys/powerpc/timer.h"
|
||||
#endif
|
||||
|
||||
#ifndef DOXYGEN
|
||||
|
@ -55,6 +55,7 @@ find_info(FILE* fp, char *str, char *buf, size_t buflen)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
rewind(fp);
|
||||
while (NULL != fgets(buf, 1024, fp)) {
|
||||
if (strncmp(buf, str, strlen(str)) == 0) {
|
||||
/* we found the line. Now eat everything up to,
|
||||
@ -84,16 +85,36 @@ opal_timer_linux_open(void)
|
||||
return OPAL_ERR_IN_ERRNO;
|
||||
}
|
||||
|
||||
loc = find_info(fp, "cpu MHz", buf, 1024);
|
||||
if (NULL == loc) {
|
||||
opal_timer_linux_freq = 0;
|
||||
|
||||
if (0 == opal_timer_linux_freq) {
|
||||
/* first, look for a timebase field. probably only on PPC,
|
||||
but one never knows */
|
||||
loc = find_info(fp, "timebase", buf, 1024);
|
||||
if (NULL != loc) {
|
||||
int freq;
|
||||
ret = sscanf(loc, "%d", &freq);
|
||||
if (1 == ret) {
|
||||
opal_timer_linux_freq = freq;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == opal_timer_linux_freq) {
|
||||
/* find the CPU speed - most timers are 1:1 with CPU speed */
|
||||
loc = find_info(fp, "cpu MHz", buf, 1024);
|
||||
if (NULL != loc) {
|
||||
ret = sscanf(loc, "%f", &cpu_f);
|
||||
if (1 == ret) {
|
||||
/* numer is in MHz - convert to Hz and make an integer */
|
||||
opal_timer_linux_freq = (opal_timer_t) cpu_f * 1000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == opal_timer_linux_freq) {
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
ret = sscanf(loc, "%f", &cpu_f);
|
||||
if (1 != ret) return OPAL_ERR_NOT_FOUND;
|
||||
|
||||
/* numer is in MHz - convert to Hz and make an integer */
|
||||
opal_timer_linux_freq = (opal_timer_t) cpu_f * 1000000;
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user