diff --git a/opal/mca/timer/windows/Makefile.am b/opal/mca/timer/windows/Makefile.am new file mode 100644 index 0000000000..5a06f7b667 --- /dev/null +++ b/opal/mca/timer/windows/Makefile.am @@ -0,0 +1,28 @@ +# +# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. All rights reserved. +# Copyright (c) 2004-2005 The University of Tennessee and The University +# of Tennessee Research Foundation. 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$ +# + + + +noinst_LTLIBRARIES = libmca_timer_windows.la + +libmca_timer_windows_la_SOURCES = \ + timer_windows.h \ + timer_windows_component.c + +EXTRA_DIST = \ + $(doc_DATA) diff --git a/opal/mca/timer/windows/configure.m4 b/opal/mca/timer/windows/configure.m4 new file mode 100644 index 0000000000..980c13fe3e --- /dev/null +++ b/opal/mca/timer/windows/configure.m4 @@ -0,0 +1,58 @@ +# -*- shell-script -*- +# +# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. All rights reserved. +# Copyright (c) 2004-2005 The University of Tennessee and The University +# of Tennessee Research Foundation. 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_windows_COMPILE_MODE], [ + AC_MSG_CHECKING([for MCA component $2:$3 compile mode]) + $4="static" + AC_MSG_RESULT([$$4]) +]) + + +# MCA_timer_windows_CONFIG(action-if-can-compile, +# [action-if-cant-compile]) +# ------------------------------------------------ +AC_DEFUN([MCA_timer_windows_CONFIG],[ + AC_ARG_WITH([timer], + [AC_HELP_STRING([--with-timer=TYPE], + [Build high resolution timer component TYPE])]) + + AS_IF([test "$with_timer" = "windows"], + [timer_windows_happy="yes" + timer_windows_should_use=1], + [timer_windows_should_use=0 + AS_IF([test "$with_timer" = ""], + [timer_windows_happy="yes"], + [timer_windows_happy="no"])]) + + AS_IF([test "$timer_windows_happy" = "yes"], + [AC_TRY_COMPILE([#include ], + [LARGE_INTEGER now; + QueryPerformanceCounter( &now );], + [timer_windows_happy="yes"], + [timer_windows_happy="no"])]) + + AS_IF([test "$timer_windows_happy" = "no" -a \ + "$timer_windows_should_use" = "1"], + [AC_MSG_ERROR([Windows timer requested but not available. Aborting.])]) + + AS_IF([test "$timer_windows_happy" = "yes"], + [timer_base_include="windows/timer_windows.h" + $1], + [$2]) +]) diff --git a/opal/mca/timer/windows/configure.params b/opal/mca/timer/windows/configure.params new file mode 100644 index 0000000000..69b56bdc40 --- /dev/null +++ b/opal/mca/timer/windows/configure.params @@ -0,0 +1,23 @@ +# -*- shell-script -*- +# +# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. All rights reserved. +# Copyright (c) 2004-2005 The University of Tennessee and The University +# of Tennessee Research Foundation. 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" diff --git a/opal/mca/timer/windows/timer_windows.h b/opal/mca/timer/windows/timer_windows.h new file mode 100644 index 0000000000..d2c76d164b --- /dev/null +++ b/opal/mca/timer/windows/timer_windows.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2005 The University of Tennessee and The University + * of Tennessee Research Foundation. 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_WINDOWS_H +#define OPAL_MCA_TIMER_WINDOWS_H + +#include "windows.h" + +#include + +OMPI_DECLSPEC opal_timer_t opal_timer_windows_freq; + +static inline opal_timer_t +opal_timer_base_get_cycles(void) +{ + LARGE_INTEGER now; + QueryPerformanceCounter( &now ); + return (opal_timer_t)now; +} + + +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_windows_freq; +#else + return 0; +#endif +} + + +static inline opal_timer_t +opal_timer_base_get_freq(void) +{ + return opal_timer_windows_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 diff --git a/opal/mca/timer/windows/timer_windows_component.c b/opal/mca/timer/windows/timer_windows_component.c new file mode 100644 index 0000000000..1caa47eb30 --- /dev/null +++ b/opal/mca/timer/windows/timer_windows_component.c @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2005 The University of Tennessee and The University + * of Tennessee Research Foundation. 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/windows/timer_windows.h" +#include "opal/include/constants.h" + +opal_timer_t opal_timer_windows_freq; + +static int opal_timer_windows_open(void); + +OMPI_DECLSPEC const +opal_timer_base_component_1_0_0_t mca_timer_windows_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 */ + "windows", + OPAL_MAJOR_VERSION, + OPAL_MINOR_VERSION, + OPAL_RELEASE_VERSION, + + /* Component open and close functions */ + opal_timer_windows_open, + NULL + }, + + /* Next the MCA v1.0.0 component meta data */ + { + /* Whether the component is checkpointable or not */ + true + }, +}; + +int +opal_timer_windows_open(void) +{ + QueryPerformanceFrequency( &opal_timer_windows_freq ); + + return OPAL_SUCCESS; +}