Skip to content

Commit 531dded

Browse files
hppritchakingshuk00
authored andcommitted
pr feedback - switch to opal_clock_gettime
Signed-off-by: Howard Pritchard <howardp@lanl.gov>
1 parent 9d042e5 commit 531dded

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

opal/mca/base/mca_base_source.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "opal/class/opal_pointer_array.h"
2626
#include "opal/class/opal_hash_table.h"
27+
#include "opal/util/clock_gettime.h"
2728

2829
static opal_pointer_array_t registered_sources;
2930
static bool mca_base_source_initialized = false;
@@ -36,29 +37,23 @@ int mca_base_source_default_source = -1;
3637
static uint64_t mca_base_source_default_time_source (void)
3738
{
3839
uint64_t time_value;
39-
40-
#if OPAL_HAVE_CLOCK_GETTIME
4140
struct timespec current;
4241

43-
clock_gettime (CLOCK_MONOTONIC, &current);
42+
(void)opal_clock_gettime(&current);
4443
time_value = 1000000000ul * current.tv_sec + current.tv_nsec;
45-
#else
46-
struct timeval current;
47-
48-
gettimeofday (&current, NULL);
49-
time_value = 1000000ul * current.tv_sec + current.tv_usec;
50-
#endif
5144

5245
return time_value;
5346
}
5447

5548
static uint64_t mca_base_source_default_time_source_ticks (void)
5649
{
57-
#if OPAL_HAVE_CLOCK_GETTIME
58-
return 1000000000;
59-
#else
60-
return 1000000;
61-
#endif
50+
struct timespec spec;
51+
if (0 == opal_clock_getres(&spec)){
52+
return (uint64_t)(spec.tv_sec + spec.tv_nsec);
53+
} else {
54+
/* guess */
55+
return 1000000;
56+
}
6257
}
6358

6459
/***************************************************************************************************/

0 commit comments

Comments
 (0)