Skip to content

Commit ee75c45

Browse files
committed
Use the OPAL timers toi report timers as accurately as possible.
This commit was SVN r11442.
1 parent a33f63d commit ee75c45

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

ompi/mpi/c/wtick.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#endif
2323
#include <stdio.h>
2424

25+
#include MCA_timer_IMPLEMENTATION_HEADER
2526
#include "ompi/mpi/c/bindings.h"
2627
#include "ompi/runtime/mpiruntime.h"
2728

@@ -38,5 +39,12 @@ static const char FUNC_NAME[] = "MPI_Wtick";
3839

3940
double MPI_Wtick(void)
4041
{
41-
return (double)0.000001;
42+
#if OPAL_TIMER_USEC_NATIVE
43+
return 0.000001;
44+
#else
45+
if( (opal_timer_t)0 == opal_timer_base_get_freq() ) {
46+
opal_output( 0, "No timer frequency\n" );
47+
}
48+
return (double)opal_timer_base_get_freq();
49+
#endif /* OPAL_TIMER_USEC_NATIVE */
4250
}

ompi/mpi/c/wtime.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#endif
2323
#include <stdio.h>
2424

25+
#include MCA_timer_IMPLEMENTATION_HEADER
26+
#include "opal/prefetch.h"
2527
#include "ompi/mpi/c/bindings.h"
2628
#include "ompi/runtime/mpiruntime.h"
2729

@@ -38,10 +40,9 @@ static const char FUNC_NAME[] = "MPI_Wtime";
3840

3941
double MPI_Wtime(void)
4042
{
41-
struct timeval tv;
42-
double wtime;
43-
gettimeofday(&tv, NULL);
44-
wtime = tv.tv_sec;
45-
wtime += (double)tv.tv_usec / 1000000.0;
46-
return wtime;
47-
}
43+
#if OPAL_TIMER_USEC_NATIVE
44+
return (double)opal_timer_base_get_usec();
45+
#else
46+
return (double)opal_timer_base_get_cycles();
47+
#endif /* OPAL_TIMER_USEC_NATIVE */
48+
}

0 commit comments

Comments
 (0)