1
1

* high resolution, low latency timers for a number of platforms, plus mods

to opal_progress() to use the timers instead of a tick count for deciding
  whether to call the event loop or not.  Currently supported platforms are:

     - solaris (x86 / sparc)
     - Linux (x86 / x86_64 / IA64)
     - Mac OS X (x86 / Power PC)

This commit was SVN r6922.
Этот коммит содержится в:
Brian Barrett 2005-08-18 05:34:22 +00:00
родитель 1134d9b7d7
Коммит dfdb5dc12a
39 изменённых файлов: 1479 добавлений и 19 удалений

Просмотреть файл

@ -865,10 +865,10 @@ EOF
-r "${framework_path}/${framework}.h" ; then -r "${framework_path}/${framework}.h" ; then
framework_list="$framework_list $framework" framework_list="$framework_list $framework"
# Add the framework's options file into configure, # Add the framework's configure file into configure,
# if there is one # if there is one
if test -r "${framework_path}/configure.options" ; then if test -r "${framework_path}/configure.m4" ; then
echo "m4_include(${framework_path}/configure.options)" >> "$mca_m4_include_file" echo "m4_include(${framework_path}/configure.m4)" >> "$mca_m4_include_file"
fi fi
rm -f "$mca_no_config_env_file" "$mca_m4_config_env_file" rm -f "$mca_no_config_env_file" "$mca_m4_config_env_file"

Просмотреть файл

@ -273,7 +273,9 @@ AC_DEFUN([MCA_CONFIGURE_PROJECT],[
MCA_$1_FRAMEWORK_LIBS="$MCA_$1_FRAMEWORK_LIBS [mca/]mca_framework[/base/libmca_]mca_framework[_base.la]" MCA_$1_FRAMEWORK_LIBS="$MCA_$1_FRAMEWORK_LIBS [mca/]mca_framework[/base/libmca_]mca_framework[_base.la]"
fi fi
MCA_$1_FRAMEWORK_LIBS="$MCA_$1_FRAMEWORK_LIBS [\$(MCA_]mca_framework[_STATIC_LTLIBS)]" MCA_$1_FRAMEWORK_LIBS="$MCA_$1_FRAMEWORK_LIBS [\$(MCA_]mca_framework[_STATIC_LTLIBS)]"
MCA_CONFIGURE_FRAMEWORK($1, mca_framework)])]) m4_ifdef([MCA_]mca_framework[_CONFIG],
[MCA_]mca_framework[_CONFIG]($1, mca_framework),
[MCA_CONFIGURE_FRAMEWORK($1, mca_framework)])])])
AC_SUBST(MCA_$1_FRAMEWORKS) AC_SUBST(MCA_$1_FRAMEWORKS)
AC_SUBST(MCA_$1_FRAMEWORK_LIBS) AC_SUBST(MCA_$1_FRAMEWORK_LIBS)

Просмотреть файл

@ -81,7 +81,7 @@ int ompi_mpi_register_params(void)
"Yield the processor when waiting for MPI communication (for MPI processes, will default to 1 when oversubscribing nodes)", "Yield the processor when waiting for MPI communication (for MPI processes, will default to 1 when oversubscribing nodes)",
false, false, 0, NULL); false, false, 0, NULL);
mca_base_param_reg_int_name("mpi", "event_tick_rate", mca_base_param_reg_int_name("mpi", "event_tick_rate",
"How often to progress TCP communications (0 = never, all positive integers [N] indicate a fraction of progression time that is devoted to TCP progression [i.e., 1/N])", "How often to progress TCP communications (0 = never, otherwise specified in microseconds)",
false, false, -1, NULL); false, false, -1, NULL);
/* Whether or not to show MPI handle leaks */ /* Whether or not to show MPI handle leaks */

26
opal/dynamic-mca/timer/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,26 @@
#
# 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$
#
include $(top_srcdir)/config/Makefile.options
SUBDIRS = $(MCA_timer_DSO_SUBDIRS)
DISTCLEANFILES = $(SUBDIRS)
# Every directory under here is a sym link to something in the main
# src/mca tree. Hence, we don't want to distribute anything under
# here.
DIST_SUBDIRS =

Просмотреть файл

@ -18,7 +18,11 @@ include $(top_srcdir)/config/Makefile.options
SUBDIRS = alpha amd64 ia32 ia64 mips powerpc sparc sparcv9 win32 SUBDIRS = alpha amd64 ia32 ia64 mips powerpc sparc sparcv9 win32
noinst_HEADERS = atomic.h architecture.h atomic_impl.h cache.h noinst_HEADERS = architecture.h \
atomic.h \
atomic_impl.h \
cache.h \
timer.h
# Conditionally install the header files # Conditionally install the header files

Просмотреть файл

@ -16,7 +16,7 @@
include $(top_srcdir)/config/Makefile.options include $(top_srcdir)/config/Makefile.options
noinst_HEADERS = atomic.h noinst_HEADERS = atomic.h timer.h
# Conditionally install the header files # Conditionally install the header files

57
opal/include/sys/amd64/timer.h Обычный файл
Просмотреть файл

@ -0,0 +1,57 @@
/*
* 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
#if 0
static inline opal_timer_t
opal_sys_timer_get_cycles(void)
{
opal_timer_t ret;
__asm__ __volatile__("rdtsc" : "=A"(ret));
return ret;
}
#else
static inline opal_timer_t
opal_sys_timer_get_cycles(void)
{
unsigned a, d;
__asm__ __volatile__ ("rdtsc" : "=a" (a), "=d" (d));
return ((opal_timer_t)a) | (((opal_timer_t)d) << 32);
}
#endif
#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 */

Просмотреть файл

@ -16,7 +16,7 @@
include $(top_srcdir)/config/Makefile.options include $(top_srcdir)/config/Makefile.options
noinst_HEADERS = atomic.h noinst_HEADERS = atomic.h timer.h
# Conditionally install the header files # Conditionally install the header files

44
opal/include/sys/ia32/timer.h Обычный файл
Просмотреть файл

@ -0,0 +1,44 @@
/*
* 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)
{
opal_timer_t ret;
__asm__ __volatile__("rdtsc" : "=A"(ret));
return ret;
}
#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 */

Просмотреть файл

@ -16,7 +16,7 @@
include $(top_srcdir)/config/Makefile.options include $(top_srcdir)/config/Makefile.options
noinst_HEADERS = atomic.h noinst_HEADERS = atomic.h timer.h
# Conditionally install the header files # Conditionally install the header files

44
opal/include/sys/ia64/timer.h Обычный файл
Просмотреть файл

@ -0,0 +1,44 @@
/*
* 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)
{
opal_timer_t ret;
__asm__ __volatile__ ("mov %0=ar.itc" : "=r"(ret));
return ret;
}
#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 */

93
opal/include/sys/timer.h Обычный файл
Просмотреть файл

@ -0,0 +1,93 @@
/*
* 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$
*/
/** @file
*
* Cycle counter reading instructions. Do not use directly - see the
* timer interface instead
*/
#ifndef OPAL_SYS_TIMER_H
#define OPAL_SYS_TIMER_H 1
#include "ompi_config.h"
#include "include/sys/architecture.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
/* do some quick #define cleanup in cases where we are doing
testing... */
#ifdef OMPI_DISABLE_INLINE_ASM
#undef OMPI_C_GCC_INLINE_ASSEMBLY
#define OMPI_C_GCC_INLINE_ASSEMBLY 0
#undef OMPI_CXX_GCC_INLINE_ASSEMBLY
#define OMPI_CXX_GCC_INLINE_ASSEMBLY 0
#undef OMPI_C_DEC_INLINE_ASSEMBLY
#define OMPI_C_DEC_INLINE_ASSEMBLY 0
#undef OMPI_CXX_DEC_INLINE_ASSEMBLY
#define OMPI_CXX_DEC_INLINE_ASSEMBLY 0
#undef OMPI_C_XLC_INLINE_ASSEMBLY
#define OMPI_C_XLC_INLINE_ASSEMBLY 0
#undef OMPI_CXX_XLC_INLINE_ASSEMBLY
#define OMPI_CXX_XLC_INLINE_ASSEMBLY 0
#endif
/* define OMPI_{GCC,DEC,XLC}_INLINE_ASSEMBLY based on the
OMPI_{C,CXX}_{GCC,DEC,XLC}_INLINE_ASSEMBLY defines and whether we
are in C or C++ */
#if defined(c_plusplus) || defined(__cplusplus)
#define OMPI_GCC_INLINE_ASSEMBLY OMPI_CXX_GCC_INLINE_ASSEMBLY
#define OMPI_DEC_INLINE_ASSEMBLY OMPI_CXX_DEC_INLINE_ASSEMBLY
#define OMPI_XLC_INLINE_ASSEMBLY OMPI_CXX_XLC_INLINE_ASSEMBLY
#else
#define OMPI_GCC_INLINE_ASSEMBLY OMPI_C_GCC_INLINE_ASSEMBLY
#define OMPI_DEC_INLINE_ASSEMBLY OMPI_C_DEC_INLINE_ASSEMBLY
#define OMPI_XLC_INLINE_ASSEMBLY OMPI_C_XLC_INLINE_ASSEMBLY
#endif
/**********************************************************************
*
* Load the appropriate architecture files and set some reasonable
* default values for our support
*
*********************************************************************/
#if defined(DOXYGEN)
/* don't include system-level gorp when generating doxygen files */
#elif OMPI_ASSEMBLY_ARCH == OMPI_AMD64
#include "opal/include/sys/amd64/timer.h"
#elif OMPI_ASSEMBLY_ARCH == OMPI_IA32
#include "opal/include/sys/ia32/timer.h"
#elif OMPI_ASSEMBLY_ARCH == OMPI_IA64
#include "opal/include/sys/ia64/timer.h"
#endif
#ifndef DOXYGEN
#ifndef OPAL_HAVE_SYS_TIMER_GET_CYCLES
#define OPAL_HAVE_SYS_TIMER_GET_CYCLES 0
typedef int opal_timer_t;
#endif
#endif
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* OPAL_SYS_TIMER_H */

32
opal/mca/timer/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,32 @@
#
# 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$
#
include $(top_srcdir)/config/Makefile.options
SUBDIRS = base $(MCA_timer_STATIC_SUBDIRS)
DIST_SUBDIRS = base $(MCA_timer_ALL_SUBDIRS)
# Source code files
headers = timer.h
# Conditionally install the header files
if WANT_INSTALL_HEADERS
ompidir = $(includedir)/openmpi/opal/mca/timer
ompi_HEADERS = $(headers)
else
ompidir = $(includedir)
endif

39
opal/mca/timer/base/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,39 @@
#
# 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$
#
include $(top_srcdir)/config/Makefile.options
noinst_LTLIBRARIES = libmca_timer_base.la
headers = \
base.h
libmca_timer_base_la_SOURCES = \
$(headers) \
timer_base_close.c \
timer_base_open.c
# Conditionally install the header files
if WANT_INSTALL_HEADERS
ompidir = $(includedir)/openmpi/ompi/mca/timer/base
ompi_HEADERS = $(headers)
else
ompidir = $(includedir)
endif
distclean-local:
rm -f static-components.h

79
opal/mca/timer/base/base.h Обычный файл
Просмотреть файл

@ -0,0 +1,79 @@
/*
* 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 OPAL_TIMER_BASE_H
#define OPAL_TIMER_BASE_H
#include "ompi_config.h"
#include "mca/timer/timer.h"
/*
* Global functions for MCA overall timer open and close
*/
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
/**
* Initialize the timer MCA framework
*
* @retval OPAL_SUCCESS Upon success
* @retval OPAL_ERROR Upon failure
*
* This must be the first function invoked in the timer MCA
* framework. It initializes the timer MCA framework, finds
* and opens timer components, etc.
*
* This function is invoked during opal_init() and during the
* initialization of the special case of the laminfo command.
*
* This function fills in the internal global variable
* opal_timer_base_components_opened, which is a list of all
* timer components that were successfully opened. This
* variable should \em only be used by other timer base
* functions -- it is not considered a public interface member --
* and is only mentioned here for completeness.
*/
OMPI_DECLSPEC int opal_timer_base_open(void);
/**
* Shut down the timer MCA framework.
*
* @retval OPAL_SUCCESS Always
*
* This function shuts down everything in the timer MCA
* framework, and is called during opal_finalize() and the
* special case of the laminfo command.
*
* It must be the last function invoked on the timer MCA framework.
*/
OMPI_DECLSPEC int opal_timer_base_close(void);
extern opal_list_t opal_timer_base_components_opened;
/* include implementation to call */
#include "opal/mca/timer/base/base_impl.h"
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* OPAL_BASE_TIMER_H */

35
opal/mca/timer/base/timer_base_close.c Обычный файл
Просмотреть файл

@ -0,0 +1,35 @@
/*
* 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$
*/
#include "ompi_config.h"
#include "opal/include/constants.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/base.h"
#include "opal/mca/timer/timer.h"
#include "opal/mca/timer/base/base.h"
int opal_timer_base_close(void)
{
/* Close all components that are still open (this should only
happen during laminfo). */
mca_base_components_close(0, &opal_timer_base_components_opened, NULL);
OBJ_DESTRUCT(&opal_timer_base_components_opened);
/* All done */
return OPAL_SUCCESS;
}

60
opal/mca/timer/base/timer_base_open.c Обычный файл
Просмотреть файл

@ -0,0 +1,60 @@
/*
* 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$
*/
#include "ompi_config.h"
#include "opal/include/constants.h"
#include "opal/util/output.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/base.h"
#include "opal/mca/base/mca_base_param.h"
#include "opal/mca/timer/timer.h"
#include "opal/mca/timer/base/base.h"
/*
* The following file was created by configure. It contains extern
* statements and the definition of an array of pointers to each
* component's public mca_base_component_t struct.
*/
#include "opal/mca/timer/base/static-components.h"
/*
* Globals
*/
opal_list_t opal_timer_base_components_opened;
/*
* Function for finding and opening either all MCA components, or the one
* that was specifically requested via a MCA parameter.
*/
int opal_timer_base_open(void)
{
/* Open up all available components */
if (OMPI_SUCCESS !=
mca_base_components_open("timer", 0,
mca_timer_base_static_components,
&opal_timer_base_components_opened,
true)) {
return OPAL_ERROR;
}
/* All done */
return OPAL_SUCCESS;
}

15
opal/mca/timer/configure.m4 Обычный файл
Просмотреть файл

@ -0,0 +1,15 @@
m4_define(MCA_timer_CONFIGURE_MODE, STOP_AT_FIRST)
AC_DEFUN([MCA_timer_CONFIG],[
timer_base_include=
# first, compile all the components
MCA_CONFIGURE_FRAMEWORK($1, $2)
# someone should have set this...
if test "$timer_base_include" == "" ; then
timer_base_include="base/base_null.h"
fi
AC_CONFIG_LINKS([opal/mca/timer/base/base_impl.h:opal/mca/timer/$timer_base_include])
])

26
opal/mca/timer/darwin/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,26 @@
#
# 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$
#
include $(top_srcdir)/config/Makefile.options
noinst_LTLIBRARIES = libmca_timer_darwin.la
libmca_timer_darwin_la_SOURCES = \
timer_darwin.h \
timer_darwin_component.c
EXTRA_DIST = \
$(doc_DATA)

55
opal/mca/timer/darwin/configure.m4 Обычный файл
Просмотреть файл

@ -0,0 +1,55 @@
# -*- shell-script -*-
#
# 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$
#
AC_DEFUN([MCA_timer_darwin_COMPILE_MODE], [
AC_MSG_CHECKING([for MCA component $2:$3 compile mode])
$4="static"
AC_MSG_RESULT([$$4])
])
# MCA_timer_darwin_CONFIG(action-if-can-compile,
# [action-if-cant-compile])
# ------------------------------------------------
AC_DEFUN([MCA_timer_darwin_CONFIG],[
AC_ARG_WITH([timer],
[AC_HELP_STRING([--with-timer=TYPE],
[blah blah blah])])
AS_IF([test "$with_timer" = "darwin"],
[timer_darwin_happy="yes"
timer_darwin_should_use=1],
[timer_darwin_should_use=0
AS_IF([test "$with_timer" = ""],
[timer_darwin_happy="yes"],
[timer_darwin_happy="no"])])
AS_IF([test "$timer_darwin_happy" = "yes"],
[AC_CHECK_HEADERS([mach/mach_time.h])
AC_CHECK_FUNC([mach_absolute_time],
[timer_darwin_happy="yes"],
[timer_darwin_happy="no"])])
AS_IF([test "$timer_darwin_happy" = "no" -a \
"$timer_darwin_should_use" = "1"],
[AC_MSG_ERROR([Darwin timer requested but not available. Aborting.])])
AS_IF([test "$timer_darwin_happy" = "yes"],
[timer_base_include="darwin/timer_darwin.h"
$1],
[$2])
])

21
opal/mca/timer/darwin/configure.params Обычный файл
Просмотреть файл

@ -0,0 +1,21 @@
# -*- shell-script -*-
#
# 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$
#
# Specific to this module
PARAM_CONFIG_PRIORITY=30
PARAM_CONFIG_FILES="Makefile"

58
opal/mca/timer/darwin/timer_darwin.h Обычный файл
Просмотреть файл

@ -0,0 +1,58 @@
/*
* 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 OPAL_MCA_TIMER_DARWIN_TIMER_DARWIN_H
#define OPAL_MCA_TIMER_DARWIN_TIMER_DARWIN_H
#include <mach/mach_time.h>
typedef uint64_t opal_timer_t;
/* frequency in mhz */
extern opal_timer_t opal_timer_darwin_freq;
static inline opal_timer_t
opal_timer_base_get_cycles(void)
{
/* this is basically a wrapper around the "right" assembly to get
the tick counter off the PowerPC Time Base. I believe it's
something similar on x86 */
return mach_absolute_time();
}
static inline opal_timer_t
opal_timer_base_get_usec(void)
{
/* freq is in Hz, so this gives usec */
return mach_absolute_time() * 1000000 / opal_timer_darwin_freq;
}
static inline opal_timer_t
opal_timer_base_get_freq(void)
{
return opal_timer_darwin_freq;
}
#define OPAL_TIMER_CYCLE_NATIVE 1
#define OPAL_TIMER_CYCLE_SUPPORTED 1
#define OPAL_TIMER_USEC_NATIVE 0
#define OPAL_TIMER_USEC_SUPPORTED 1
#endif

Просмотреть файл

@ -0,0 +1,66 @@
/*
* 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$
*/
#include "ompi_config.h"
#include <mach/mach_time.h>
#include "opal/mca/timer/timer.h"
#include "opal/mca/timer/darwin/timer_darwin.h"
#include "opal/include/constants.h"
opal_timer_t opal_timer_darwin_freq;
static int opal_timer_darwin_open(void);
const opal_timer_base_component_1_0_0_t mca_timer_darwin_component = {
/* First, the mca_component_t struct containing meta information
about the component itself */
{
/* Indicate that we are a timer v1.0.0 component (which also
implies a specific MCA version) */
OPAL_TIMER_BASE_VERSION_1_0_0,
/* Component name and version */
"darwin",
OPAL_MAJOR_VERSION,
OPAL_MINOR_VERSION,
OPAL_RELEASE_VERSION,
/* Component open and close functions */
opal_timer_darwin_open,
NULL
},
/* Next the MCA v1.0.0 component meta data */
{
/* Whether the component is checkpointable or not */
true
},
};
int opal_timer_darwin_open(void)
{
mach_timebase_info_data_t sTBI;
mach_timebase_info(&sTBI);
opal_timer_darwin_freq = sTBI.denom;
return OPAL_SUCCESS;
}

26
opal/mca/timer/linux/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,26 @@
#
# 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$
#
include $(top_srcdir)/config/Makefile.options
noinst_LTLIBRARIES = libmca_timer_linux.la
libmca_timer_linux_la_SOURCES = \
timer_linux.h \
timer_linux_component.c
EXTRA_DIST = \
$(doc_DATA)

54
opal/mca/timer/linux/configure.m4 Обычный файл
Просмотреть файл

@ -0,0 +1,54 @@
# -*- shell-script -*-
#
# 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$
#
AC_DEFUN([MCA_timer_linux_COMPILE_MODE], [
AC_MSG_CHECKING([for MCA component $2:$3 compile mode])
$4="static"
AC_MSG_RESULT([$$4])
])
# MCA_timer_linux_CONFIG(action-if-can-compile,
# [action-if-cant-compile])
# ------------------------------------------------
AC_DEFUN([MCA_timer_linux_CONFIG],[
AC_ARG_WITH([timer],
[AC_HELP_STRING([--with-timer=TYPE],
[blah blah blah])])
AS_IF([test "$with_timer" = "linux"],
[timer_linux_happy="yes"
timer_linux_should_use=1],
[timer_linux_should_use=0
AS_IF([test "$with_timer" = ""],
[timer_linux_happy="yes"],
[timer_linux_happy="no"])])
AS_IF([test "$timer_linux_happy" = "yes"],
[AS_IF([test -r "/proc/cpuinfo"],
[timer_linux_happy="yes"],
[timer_linux_happy="no"])])
AS_IF([test "$timer_linux_happy" = "no" -a \
"$timer_linux_should_use" = "1"],
[AC_MSG_ERROR([Linux timer requested but not available. Aborting.])])
AS_IF([test "$timer_linux_happy" = "yes"],
[timer_base_include="linux/timer_linux.h"
$1],
[$2])
])

21
opal/mca/timer/linux/configure.params Обычный файл
Просмотреть файл

@ -0,0 +1,21 @@
# -*- shell-script -*-
#
# 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$
#
# Specific to this module
PARAM_CONFIG_PRIORITY=10
PARAM_CONFIG_FILES="Makefile"

59
opal/mca/timer/linux/timer_linux.h Обычный файл
Просмотреть файл

@ -0,0 +1,59 @@
/*
* 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 OPAL_MCA_TIMER_LINUX_TIMER_LINUX_H
#define OPAL_MCA_TIMER_LINUX_TIMER_LINUX_H
#include <opal/include/sys/timer.h>
extern opal_timer_t opal_timer_linux_freq;
static inline opal_timer_t
opal_timer_base_get_cycles(void)
{
#if OPAL_HAVE_SYS_TIMER_GET_CYCLES
return opal_sys_timer_get_cycles();
#else
return 0;
#endif
}
static inline opal_timer_t
opal_timer_base_get_usec(void)
{
#if OPAL_HAVE_SYS_TIMER_GET_CYCLES
/* freq is in Hz, so this gives usec */
return opal_sys_timer_get_cycles() * 1000000 / opal_timer_linux_freq;
#else
return 0;
#endif
}
static inline opal_timer_t
opal_timer_base_get_freq(void)
{
return opal_timer_linux_freq;
}
#define OPAL_TIMER_CYCLE_NATIVE OPAL_HAVE_SYS_TIMER_GET_CYCLES
#define OPAL_TIMER_CYCLE_SUPPORTED OPAL_HAVE_SYS_TIMER_GET_CYCLES
#define OPAL_TIMER_USEC_NATIVE 0
#define OPAL_TIMER_USEC_SUPPORTED OPAL_HAVE_SYS_TIMER_GET_CYCLES
#endif

Просмотреть файл

@ -0,0 +1,99 @@
/*
* 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$
*/
#include "ompi_config.h"
#include "opal/mca/timer/timer.h"
#include "opal/mca/timer/linux/timer_linux.h"
#include "opal/include/constants.h"
opal_timer_t opal_timer_linux_freq;
static int opal_timer_linux_open(void);
const opal_timer_base_component_1_0_0_t mca_timer_linux_component = {
/* First, the mca_component_t struct containing meta information
about the component itself */
{
/* Indicate that we are a timer v1.0.0 component (which also
implies a specific MCA version) */
OPAL_TIMER_BASE_VERSION_1_0_0,
/* Component name and version */
"linux",
OPAL_MAJOR_VERSION,
OPAL_MINOR_VERSION,
OPAL_RELEASE_VERSION,
/* Component open and close functions */
opal_timer_linux_open,
NULL
},
/* Next the MCA v1.0.0 component meta data */
{
/* Whether the component is checkpointable or not */
true
},
};
static char *
find_info(FILE* fp, char *str, char *buf, size_t buflen)
{
char *tmp;
while (NULL != fgets(buf, 1024, fp)) {
if (strncmp(buf, str, strlen(str)) == 0) {
/* we found the line. Now eat everything up to,
including, and one past the : */
for (tmp = buf ; (*tmp != '\0') && (*tmp != ':') ; ++tmp) ;
for ( ++tmp ; *tmp == ' ' ; ++tmp);
if (NULL != tmp && '\0' != *tmp) {
return tmp;
}
}
}
return NULL;
}
int
opal_timer_linux_open(void)
{
FILE *fp;
char *loc;
float cpu_f;
int ret;
char buf[1024];
fp = fopen("/proc/cpuinfo", "r");
if (NULL == fp) {
return OPAL_ERR_IN_ERRNO;
}
loc = find_info(fp, "cpu MHz", buf, 1024);
if (NULL == loc) {
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;
}

26
opal/mca/timer/solaris/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,26 @@
#
# 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$
#
include $(top_srcdir)/config/Makefile.options
noinst_LTLIBRARIES = libmca_timer_solaris.la
libmca_timer_solaris_la_SOURCES = \
timer_solaris.h \
timer_solaris_component.c
EXTRA_DIST = \
$(doc_DATA)

54
opal/mca/timer/solaris/configure.m4 Обычный файл
Просмотреть файл

@ -0,0 +1,54 @@
# -*- shell-script -*-
#
# 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$
#
AC_DEFUN([MCA_timer_solaris_COMPILE_MODE], [
AC_MSG_CHECKING([for MCA component $2:$3 compile mode])
$4="static"
AC_MSG_RESULT([$$4])
])
# MCA_timer_solaris_CONFIG(action-if-can-compile,
# [action-if-cant-compile])
# ------------------------------------------------
AC_DEFUN([MCA_timer_solaris_CONFIG],[
AC_ARG_WITH([timer],
[AC_HELP_STRING([--with-timer=TYPE],
[blah blah blah])])
AS_IF([test "$with_timer" = "solaris"],
[timer_solaris_happy="yes"
timer_solaris_should_use=1],
[timer_solaris_should_use=0
AS_IF([test "$with_timer" = ""],
[timer_solaris_happy="yes"],
[timer_solaris_happy="no"])])
AS_IF([test "$timer_solaris_happy" = "yes"],
[AC_CHECK_FUNC([gethrtime],
[timer_solaris_happy="yes"],
[timer_solaris_happy="no"])])
AS_IF([test "$timer_solaris_happy" = "no" -a \
"$timer_solaris_should_use" = "1"],
[AC_MSG_ERROR([Solaris timer requested but not available. Aborting.])])
AS_IF([test "$timer_solaris_happy" = "yes"],
[timer_base_include="darwin/timer_darwin.h"
$1],
[$2])
])

21
opal/mca/timer/solaris/configure.params Обычный файл
Просмотреть файл

@ -0,0 +1,21 @@
# -*- shell-script -*-
#
# 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$
#
# Specific to this module
PARAM_CONFIG_PRIORITY=30
PARAM_CONFIG_FILES="Makefile"

50
opal/mca/timer/solaris/timer_solaris.h Обычный файл
Просмотреть файл

@ -0,0 +1,50 @@
/*
* 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 OPAL_MCA_TIMER_SOLARIS_TIMER_SOLARIS_H
#define OPAL_MCA_TIMER_SOLARIS_TIMER_SOLARIS_H
#include <mach/mach_time.h>
typedef hrtime_t opal_timer_t;
static inline opal_timer_t
opal_timer_base_get_cycles()
{
return 0;
}
static inline opal_timer_t
opal_timer_base_get_usec()
{
/* gethrtime returns nanoseconds */
return gethrtime() / 1000;
}
static inline opal_timer_t
opal_timer_base_get_freq()
{
return 0;
}
#define OPAL_TIMER_CYCLE_NATIVE 0
#define OPAL_TIMER_CYCLE_SUPPORTED 0
#define OPAL_TIMER_USEC_NATIVE 1
#define OPAL_TIMER_USEC_SUPPORTED 1
#endif

Просмотреть файл

@ -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$
*/
#include "ompi_config.h"
#include "opal/mca/timer/timer.h"
#include "opal/mca/timer/solaris/timer_solaris.h"
static int opal_timer_solaris_open(void);
const opal_timer_base_component_1_0_0_t mca_timer_solaris_component = {
/* First, the mca_component_t struct containing meta information
about the component itself */
{
/* Indicate that we are a timer v1.0.0 component (which also
implies a specific MCA version) */
OPAL_TIMER_BASE_VERSION_1_0_0,
/* Component name and version */
"solaris",
OPAL_MAJOR_VERSION,
OPAL_MINOR_VERSION,
OPAL_RELEASE_VERSION,
/* Component open and close functions */
NULL,
NULL
},
/* Next the MCA v1.0.0 component meta data */
{
/* Whether the component is checkpointable or not */
true
},
};

95
opal/mca/timer/timer.h Обычный файл
Просмотреть файл

@ -0,0 +1,95 @@
/*
* 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$
*/
/**
* @file
*
* High resolution timer / cycle counter
*
* High resolution timer / cycle counter interface. This interface is
* intended to hide the system-dependent nature of timers that provide
* higher resolution and lower calling cost than gettimeofday().
* Unlike most component interfaces, there should only ever be one
* component available to be built on a particular platform.
* Therefore, a number of #defines are available to determine how well
* the platform supports high resolution timers:
*
* <UL>
* <LI><PRE>OPAL_TIMER_CYCLE_NATIVE</PRE> Whether
* opal_timer_base_get_cycle() is implemented directly or computed
* from some other data (such as a high res timer)</LI>
* <LI><PRE>OPAL_TIMER_CYCLE_SUPPORTED</PRE> Whether
* opal_timer_base_get_cycle() is supported on the current
* platform.</LI>
* <LI><PRE>OPAL_TIMER_USEC_SUPPORTED</PRE> Whether
* opal_timer_base_get_usec() is supported on the current
* platform or implemented on top of gettimeofday(), which
* may be unsuitable for some uses.
* </UL>
*
* The cycle count may not be the cycle count of the CPU itself, if
* there is another sufficiently close counter with better behavior
* characteristics (like the Time Base counter on many Power/PowerPC
* platforms). The function opal_timer_base_get_freq() returns the
* frequency of the cycle counter in use, *NOT* the frequency of the
* main CPU.
*
* Unless otherwise noted, no attempt is made to cope with the the
* differences in counters on SMP machines. If your process switches
* CPUs, your timer results may change.
*
* Build time priorities are allocated as follows:
*
* - 0 gettimeofday() wrapper
* - 10 Assembly timers with bad frequency search (Linux)
* - 20 NIC software stack (QSNet, Myrinet?)
* - 30 Operating systems with native interfaces
*/
#ifndef OPAL_MCA_TIMER_TIMER_H
#define OPAL_MCA_TIMER_TIMER_H
#include "ompi_config.h"
#include "mca/mca.h"
#include "mca/base/base.h"
/**
* Structure for timer v1.0.0 components.
* Chained to MCA v1.0.0
*/
struct opal_timer_base_component_1_0_0_t {
/** MCA base component */
mca_base_component_t timerc_version;
/** MCA base data */
mca_base_component_data_1_0_0_t timerc_data;
};
/**
* Convenience typedef
*/
typedef struct opal_timer_base_component_1_0_0_t opal_timer_base_component_1_0_0_t;
/*
* Macro for use in components that are of type timer v1.0.0
*/
#define OPAL_TIMER_BASE_VERSION_1_0_0 \
/* timer v1.0 is chained to MCA v1.0 */ \
MCA_BASE_VERSION_1_0_0, \
/* timer v1.0 */ \
"timer", 1, 0, 0
#endif /* OPAL_MCA_TIMER_TIMER_H */

Просмотреть файл

@ -26,6 +26,7 @@
#include "opal/runtime/opal.h" #include "opal/runtime/opal.h"
#include "orte/include/orte_constants.h" #include "orte/include/orte_constants.h"
#include "opal/mca/memory/base/base.h" #include "opal/mca/memory/base/base.h"
#include "opal/mca/timer/base/base.h"
/** /**
* Finalize the OPAL utilities * Finalize the OPAL utilities
@ -37,6 +38,7 @@
*/ */
int opal_finalize(void) int opal_finalize(void)
{ {
opal_timer_base_close();
/* close the memory manager components. Registered hooks can /* close the memory manager components. Registered hooks can
still be fired any time between now and the call to still be fired any time between now and the call to

Просмотреть файл

@ -26,6 +26,8 @@
#include "opal/runtime/opal.h" #include "opal/runtime/opal.h"
#include "opal/mca/memory/base/base.h" #include "opal/mca/memory/base/base.h"
#include "opal/mca/paffinity/base/base.h" #include "opal/mca/paffinity/base/base.h"
#include "opal/mca/timer/base/base.h"
/** /**
* Initialize the OPAL utilities * Initialize the OPAL utilities
@ -59,6 +61,8 @@ int opal_init(void)
without good initialization routine support */ without good initialization routine support */
opal_memory_base_open(); opal_memory_base_open();
opal_timer_base_open();
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }

Просмотреть файл

@ -24,12 +24,19 @@
#include "opal/event/event.h" #include "opal/event/event.h"
#include "opal/mca/base/mca_base_param.h" #include "opal/mca/base/mca_base_param.h"
#include "ompi/include/constants.h" #include "ompi/include/constants.h"
#include "opal/mca/timer/base/base.h"
#define OPAL_PROGRESS_USE_TIMERS (OPAL_TIMER_CYCLE_SUPPORTED || OPAL_TIMER_USEC_SUPPORTED)
/* /*
* default parameters * default parameters
*/ */
static int opal_progress_event_flag = OPAL_EVLOOP_ONCE; static int opal_progress_event_flag = OPAL_EVLOOP_ONCE;
static const int opal_progress_default_tick_rate = 10000; #if OPAL_PROGRESS_USE_TIMERS
static const opal_timer_t opal_progress_default_tick_rate = 10000; /* 10ms */
#else
static const int opal_progress_default_tick_rate = 10000; /* 10k calls to opal_progress */
#endif
/* /*
* Local variables * Local variables
@ -46,10 +53,15 @@ static size_t callbacks_size = 0;
/* do we want to call sched_yield() if nothing happened */ /* do we want to call sched_yield() if nothing happened */
static int call_yield = 1; static int call_yield = 1;
#if OPAL_PROGRESS_USE_TIMERS
static opal_timer_t event_progress_last_time = 0;
static opal_timer_t event_progress_delta = 0;
#else
/* current count down until we tick the event library */ /* current count down until we tick the event library */
static int32_t event_progress_counter = 0; static int32_t event_progress_counter = 0;
/* reset value for counter when it hits 0 */ /* reset value for counter when it hits 0 */
static int32_t event_progress_counter_reset = 0; static int32_t event_progress_delta = 0;
#endif
/* users of the event library from MPI cause the tick rate to /* users of the event library from MPI cause the tick rate to
be every time */ be every time */
static int32_t event_num_mpi_users = 0; static int32_t event_num_mpi_users = 0;
@ -67,7 +79,16 @@ opal_progress_init(void)
/* always call sched yield when in the rte only... */ /* always call sched yield when in the rte only... */
call_yield = 1; call_yield = 1;
event_progress_counter = event_progress_counter_reset = 0; #if OPAL_PROGRESS_USE_TIMERS
event_progress_delta = 0;
#if OPAL_TIMER_USEC_NATIVE
event_progress_last_time = opal_timer_base_get_usec();
#else
event_progress_last_time = opal_timer_base_get_cycles();
#endif
#else
event_progress_counter = event_progress_delta = 0;
#endif
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -104,21 +125,42 @@ opal_progress_mpi_enable(void)
if (value < 0) { if (value < 0) {
/* user didn't specify - default tick rate */ /* user didn't specify - default tick rate */
event_progress_counter_reset = opal_progress_default_tick_rate; event_progress_delta = opal_progress_default_tick_rate;
} else if (value == 0) { } else if (value == 0) {
#if OPAL_PROGRESS_USE_TIMERS
/* user specified as never tick - tick once per minute */
event_progress_delta = 60 * 1000000;
#else
/* user specified as never tick - don't count often */ /* user specified as never tick - don't count often */
event_progress_counter_reset = INT_MAX; event_progress_delta = INT_MAX;
#endif
} else { } else {
#if OPAL_PROGRESS_USE_TIMERS
event_progress_delta = value;
#else
/* subtract one so that we can do post-fix subtraction /* subtract one so that we can do post-fix subtraction
in the inner loop and go faster */ in the inner loop and go faster */
event_progress_counter_reset = value - 1; event_progress_delta = value - 1;
#endif
} }
#if OPAL_PROGRESS_USE_TIMERS && !OPAL_TIMER_USEC_NATIVE
/* going to use cycles for counter. Adjust specified usec into cycles */
event_progress_delta = event_progress_delta * opal_timer_base_get_freq() / 1000000;
#endif
#if OPAL_PROGRESS_USE_TIMERS
#if OPAL_TIMER_USEC_NATIVE
event_progress_last_time = opal_timer_base_get_usec();
#else
event_progress_last_time = opal_timer_base_get_cycles();
#endif
#else
/* it's possible that an init function bumped up our tick rate. /* it's possible that an init function bumped up our tick rate.
* If so, set the event_progress counter to 0. Otherwise, set it to * If so, set the event_progress counter to 0. Otherwise, set it to
* the reset value */ * the reset value */
event_progress_counter = (event_num_mpi_users > 0) ? event_progress_counter = (event_num_mpi_users > 0) ?
0 : event_progress_counter_reset; 0 : event_progress_delta;
#endif
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -131,7 +173,10 @@ opal_progress_mpi_disable(void)
call_yield = 1; call_yield = 1;
/* always tick the event library */ /* always tick the event library */
event_progress_counter = event_progress_counter_reset = 0; event_progress_delta = 0;
#if !OPAL_PROGRESS_USE_TIMERS
event_progress_counter = 0;
#endif
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -186,8 +231,34 @@ opal_progress(void)
{ {
size_t i; size_t i;
int events = 0; int events = 0;
#if OPAL_PROGRESS_USE_TIMERS
#if OPAL_TIMER_USEC_NATIVE
opal_timer_t now = opal_timer_base_get_usec();
#else
opal_timer_t now = opal_timer_base_get_cycles();
#endif
#endif
#if (OMPI_ENABLE_PROGRESS_THREADS == 0) && OPAL_HAVE_WORKING_EVENTOPS #if (OMPI_ENABLE_PROGRESS_THREADS == 0) && OPAL_HAVE_WORKING_EVENTOPS
#if OPAL_PROGRESS_USE_TIMERS
/* trip the event library if we've reached our tick rate and we are
enabled */
if (now - event_progress_last_time > event_progress_delta &&
opal_progress_event_flag != 0) {
#if OMPI_HAVE_THREAD_SUPPORT
if (opal_atomic_trylock(&progress_lock)) {
#endif /* OMPI_HAVE_THREAD_SUPPORT */
event_progress_last_time = (event_num_mpi_users > 0) ?
now - event_progress_delta : now;
events += opal_event_loop(opal_progress_event_flag);
#if OMPI_HAVE_THREAD_SUPPORT
opal_atomic_unlock(&progress_lock);
}
#endif /* OMPI_HAVE_THREAD_SUPPORT */
}
#else /* OPAL_PROGRESS_USE_TIMERS */
/* trip the event library if we've reached our tick rate and we are /* trip the event library if we've reached our tick rate and we are
enabled */ enabled */
if (OPAL_THREAD_ADD32(&event_progress_counter, -1) <= 0 && if (OPAL_THREAD_ADD32(&event_progress_counter, -1) <= 0 &&
@ -196,15 +267,18 @@ opal_progress(void)
if (opal_atomic_trylock(&progress_lock)) { if (opal_atomic_trylock(&progress_lock)) {
#endif /* OMPI_HAVE_THREAD_SUPPORT */ #endif /* OMPI_HAVE_THREAD_SUPPORT */
event_progress_counter = event_progress_counter =
(event_num_mpi_users > 0) ? 0 : event_progress_counter_reset; (event_num_mpi_users > 0) ? 0 : event_progress_delta;
events += opal_event_loop(opal_progress_event_flag); events += opal_event_loop(opal_progress_event_flag);
#if OMPI_HAVE_THREAD_SUPPORT #if OMPI_HAVE_THREAD_SUPPORT
opal_atomic_unlock(&progress_lock); opal_atomic_unlock(&progress_lock);
} }
#endif /* OMPI_HAVE_THREAD_SUPPORT */ #endif /* OMPI_HAVE_THREAD_SUPPORT */
} }
#endif /* OPAL_PROGRESS_USE_TIMERS */
#endif /* OMPI_ENABLE_PROGRESS_THREADS == 0 && OPAL_HAVE_WORKING_EVENTOPS */ #endif /* OMPI_ENABLE_PROGRESS_THREADS == 0 && OPAL_HAVE_WORKING_EVENTOPS */
/* progress all registered callbacks */ /* progress all registered callbacks */
for (i = 0 ; i < callbacks_len ; ++i) { for (i = 0 ; i < callbacks_len ; ++i) {
#if OMPI_ENABLE_DEBUG #if OMPI_ENABLE_DEBUG
@ -313,8 +387,14 @@ opal_progress_event_increment()
{ {
int32_t val; int32_t val;
val = opal_atomic_add_32(&event_num_mpi_users, 1); val = opal_atomic_add_32(&event_num_mpi_users, 1);
#if OPAL_PROGRESS_USE_TIMERS
/* force an update next round (we'll be past the delta) */
event_progress_last_time -= event_progress_delta;
#else
/* always reset the tick rate - can't hurt */ /* always reset the tick rate - can't hurt */
event_progress_counter = 0; event_progress_counter = 0;
#endif
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -325,9 +405,13 @@ opal_progress_event_decrement()
{ {
int32_t val; int32_t val;
val = opal_atomic_sub_32(&event_num_mpi_users, 1); val = opal_atomic_sub_32(&event_num_mpi_users, 1);
#if !OPAL_PROGRESS_USE_TIMERS
/* start now in delaying if it's easy */
if (val >= 0) { if (val >= 0) {
event_progress_counter = event_progress_counter_reset; event_progress_counter = event_progress_delta;
} }
#endif
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -20,6 +20,7 @@ check_PROGRAMS = \
ompi_numtostr \ ompi_numtostr \
opal_if \ opal_if \
opal_os_path \ opal_os_path \
opal_timer \
orte_sys_info \ orte_sys_info \
opal_os_create_dirpath \ opal_os_create_dirpath \
orte_session_dir \ orte_session_dir \
@ -60,6 +61,12 @@ opal_os_path_LDADD = \
$(top_builddir)/test/support/libsupport.a $(top_builddir)/test/support/libsupport.a
opal_os_path_DEPENDENCIES = $(opal_os_path_LDADD) opal_os_path_DEPENDENCIES = $(opal_os_path_LDADD)
opal_timer_SOURCES = opal_timer.c
opal_timer_LDADD = \
$(top_builddir)/opal/libopal.la \
$(top_builddir)/test/support/libsupport.a
opal_timer_DEPENDENCIES = $(opal_timer_LDADD)
orte_sys_info_SOURCES = orte_sys_info.c orte_sys_info_SOURCES = orte_sys_info.c
orte_sys_info_LDADD = \ orte_sys_info_LDADD = \

54
test/util/opal_timer.c Обычный файл
Просмотреть файл

@ -0,0 +1,54 @@
/*
* 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$
*/
#include "ompi_config.h"
#include <unistd.h>
#include "opal/runtime/opal.h"
#include "opal/include/constants.h"
#include "opal/mca/timer/base/base.h"
int
main(int argc, char *argv[])
{
opal_timer_t start, end, diff;
opal_init();
printf("--> frequency: %llu\n", (unsigned long long) opal_timer_base_get_freq());
printf("--> cycle count\n");
start = opal_timer_base_get_cycles();
start = opal_timer_base_get_cycles();
sleep(1);
end = opal_timer_base_get_cycles();
diff = end - start;
printf(" Slept approximately %llu cycles, or %llu us\n",
(unsigned long long) diff,
(unsigned long long) ((diff * 1000000) / opal_timer_base_get_freq()));
printf("--> usecs\n");
start = opal_timer_base_get_usec();
sleep(1);
end = opal_timer_base_get_usec();
diff = end - start;
printf(" Slept approximately %llu us\n", (unsigned long long) diff);
opal_finalize();
return 0;
}