Skip to content

Commit

Permalink
Use the OPAL timers toi report timers as accurately as possible.
Browse files Browse the repository at this point in the history
This commit was SVN r11442.
  • Loading branch information
bosilca committed Aug 27, 2006
1 parent a33f63d commit ee75c45
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
10 changes: 9 additions & 1 deletion ompi/mpi/c/wtick.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#endif
#include <stdio.h>

#include MCA_timer_IMPLEMENTATION_HEADER
#include "ompi/mpi/c/bindings.h"
#include "ompi/runtime/mpiruntime.h"

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

double MPI_Wtick(void)
{
return (double)0.000001;
#if OPAL_TIMER_USEC_NATIVE
return 0.000001;
#else
if( (opal_timer_t)0 == opal_timer_base_get_freq() ) {
opal_output( 0, "No timer frequency\n" );
}
return (double)opal_timer_base_get_freq();
#endif /* OPAL_TIMER_USEC_NATIVE */
}
15 changes: 8 additions & 7 deletions ompi/mpi/c/wtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#endif
#include <stdio.h>

#include MCA_timer_IMPLEMENTATION_HEADER
#include "opal/prefetch.h"
#include "ompi/mpi/c/bindings.h"
#include "ompi/runtime/mpiruntime.h"

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

double MPI_Wtime(void)
{
struct timeval tv;
double wtime;
gettimeofday(&tv, NULL);
wtime = tv.tv_sec;
wtime += (double)tv.tv_usec / 1000000.0;
return wtime;
}
#if OPAL_TIMER_USEC_NATIVE
return (double)opal_timer_base_get_usec();
#else
return (double)opal_timer_base_get_cycles();
#endif /* OPAL_TIMER_USEC_NATIVE */
}

0 comments on commit ee75c45

Please sign in to comment.