timer: hack use of clock_gettime
better solution needed later workaround for #3003 Signed-off-by: Howard Pritchard <howardp@lanl.gov>
Этот коммит содержится в:
родитель
48d13aa8ef
Коммит
b9331527f5
@ -13,6 +13,8 @@
|
|||||||
* Copyright (c) 2015-2016 Research Organization for Information Science
|
* Copyright (c) 2015-2016 Research Organization for Information Science
|
||||||
* and Technology (RIST). All rights reserved.
|
* and Technology (RIST). All rights reserved.
|
||||||
* Copyright (c) 2017 IBM Corporation. All rights reserved.
|
* Copyright (c) 2017 IBM Corporation. All rights reserved.
|
||||||
|
* Copyright (c) 2017 Los Alamos National Security, LLC. All rights
|
||||||
|
* reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -25,6 +27,9 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#ifdef HAVE_TIME_H
|
||||||
|
#include <time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include MCA_timer_IMPLEMENTATION_HEADER
|
#include MCA_timer_IMPLEMENTATION_HEADER
|
||||||
#include "ompi/mpi/c/bindings.h"
|
#include "ompi/mpi/c/bindings.h"
|
||||||
@ -43,8 +48,7 @@ double MPI_Wtick(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* See https://github.com/open-mpi/ompi/issues/3003
|
* See https://github.com/open-mpi/ompi/issues/3003
|
||||||
* For now we are forcing the use of gettimeofday() until we find a
|
* to get an idea what's going on here.
|
||||||
* more portable solution.
|
|
||||||
*/
|
*/
|
||||||
#if 0
|
#if 0
|
||||||
#if OPAL_TIMER_CYCLE_NATIVE
|
#if OPAL_TIMER_CYCLE_NATIVE
|
||||||
@ -60,8 +64,20 @@ double MPI_Wtick(void)
|
|||||||
#elif OPAL_TIMER_USEC_NATIVE
|
#elif OPAL_TIMER_USEC_NATIVE
|
||||||
return 0.000001;
|
return 0.000001;
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
#if defined(__linux__) && OPAL_HAVE_CLOCK_GETTIME
|
||||||
|
struct timespec spec;
|
||||||
|
double wtick = 0.0;
|
||||||
|
if (0 == clock_getres(CLOCK_MONOTONIC, &spec)){
|
||||||
|
wtick = spec.tv_sec + spec.tv_nsec * 1.0e-09;
|
||||||
|
} else {
|
||||||
|
/* guess */
|
||||||
|
wtick = 1.0e-09;
|
||||||
|
}
|
||||||
|
return wtick;
|
||||||
#else
|
#else
|
||||||
/* Otherwise, we already return usec precision. */
|
/* Otherwise, we already return usec precision. */
|
||||||
return 0.000001;
|
return 0.000001;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
* Copyright (c) 2015 Research Organization for Information Science
|
* Copyright (c) 2015 Research Organization for Information Science
|
||||||
* and Technology (RIST). All rights reserved.
|
* and Technology (RIST). All rights reserved.
|
||||||
* Copyright (c) 2017 IBM Corporation. All rights reserved.
|
* Copyright (c) 2017 IBM Corporation. All rights reserved.
|
||||||
|
* Copyright (c) 2017 Los Alamos National Security, LLC. All rights
|
||||||
|
* reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -25,6 +27,9 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#ifdef HAVE_TIME_H
|
||||||
|
#include <time.h>
|
||||||
|
#endif /* HAVE_TIME_H */
|
||||||
|
|
||||||
#include MCA_timer_IMPLEMENTATION_HEADER
|
#include MCA_timer_IMPLEMENTATION_HEADER
|
||||||
#include "ompi/mpi/c/bindings.h"
|
#include "ompi/mpi/c/bindings.h"
|
||||||
@ -42,9 +47,8 @@ double MPI_Wtime(void)
|
|||||||
double wtime;
|
double wtime;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See https://github.com/open-mpi/ompi/issues/3003
|
* See https://github.com/open-mpi/ompi/issues/3003 to find out
|
||||||
* For now we are forcing the use of gettimeofday() until we find a
|
* what's happening here.
|
||||||
* more portable solution.
|
|
||||||
*/
|
*/
|
||||||
#if 0
|
#if 0
|
||||||
#if OPAL_TIMER_CYCLE_NATIVE
|
#if OPAL_TIMER_CYCLE_NATIVE
|
||||||
@ -52,12 +56,19 @@ double MPI_Wtime(void)
|
|||||||
#elif OPAL_TIMER_USEC_NATIVE
|
#elif OPAL_TIMER_USEC_NATIVE
|
||||||
wtime = ((double) opal_timer_base_get_usec()) / 1000000.0;
|
wtime = ((double) opal_timer_base_get_usec()) / 1000000.0;
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
#if defined(__linux__) && OPAL_HAVE_CLOCK_GETTIME
|
||||||
|
struct timespec tp = {.tv_sec = 0, .tv_nsec = 0};
|
||||||
|
(void) clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||||
|
wtime = tp.tv_sec;
|
||||||
|
wtime += tp.tv_nsec/1.0e+9;
|
||||||
#else
|
#else
|
||||||
/* Fall back to gettimeofday() if we have nothing else */
|
/* Fall back to gettimeofday() if we have nothing else */
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
wtime = tv.tv_sec;
|
wtime = tv.tv_sec;
|
||||||
wtime += (double)tv.tv_usec / 1000000.0;
|
wtime += (double)tv.tv_usec / 1000000.0;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OPAL_CR_NOOP_PROGRESS();
|
OPAL_CR_NOOP_PROGRESS();
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user