opal timing: added ability to choose the timer type
Этот коммит содержится в:
родитель
97444d82f1
Коммит
116169c38a
@ -99,7 +99,7 @@ int ompi_mpi_finalize(void)
|
||||
ompi_proc_t** procs;
|
||||
size_t nprocs;
|
||||
OPAL_TIMING_DECLARE(tm);
|
||||
OPAL_TIMING_INIT(&tm);
|
||||
OPAL_TIMING_INIT_EXT(&tm, OPAL_TIMING_GET_TIME_OF_DAY);
|
||||
|
||||
|
||||
/* Be a bit social if an erroneous program calls MPI_FINALIZE in
|
||||
|
@ -388,7 +388,7 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided)
|
||||
char *error = NULL;
|
||||
char *cmd=NULL, *av=NULL;
|
||||
OPAL_TIMING_DECLARE(tm);
|
||||
OPAL_TIMING_INIT(&tm);
|
||||
OPAL_TIMING_INIT_EXT(&tm, OPAL_TIMING_GET_TIME_OF_DAY);
|
||||
|
||||
/* bitflag of the thread level support provided. To be used
|
||||
* for the modex in order to work in heterogeneous environments. */
|
||||
|
@ -59,10 +59,6 @@ struct interval_descr{
|
||||
double interval, overhead;
|
||||
};
|
||||
|
||||
opal_timing_event_t *opal_timing_event_alloc(opal_timing_t *t);
|
||||
void opal_timing_init(opal_timing_t *t);
|
||||
opal_timing_prep_t opal_timing_prep_ev(opal_timing_t *t, const char *fmt, ...);
|
||||
|
||||
static OBJ_CLASS_INSTANCE(opal_timing_event_t, opal_list_item_t, NULL, NULL);
|
||||
|
||||
|
||||
@ -165,26 +161,45 @@ static double get_ts_cycle(void)
|
||||
{
|
||||
return ((double) opal_timer_base_get_cycles()) / opal_timer_base_get_freq();
|
||||
}
|
||||
#elif OPAL_TIMER_USEC_NATIVE
|
||||
#endif
|
||||
|
||||
#if OPAL_TIMER_USEC_NATIVE
|
||||
static double get_ts_usec(void)
|
||||
{
|
||||
return ((double) opal_timer_base_get_usec()) / 1000000.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static get_ts_t _init_timestamping(void)
|
||||
static get_ts_t _init_timestamping(opal_timer_type_t type)
|
||||
{
|
||||
if( !opal_initialized ){
|
||||
return get_ts_gettimeofday;
|
||||
}
|
||||
#if OPAL_TIMER_CYCLE_NATIVE
|
||||
return get_ts_cycle;
|
||||
#elif OPAL_TIMER_USEC_NATIVE
|
||||
return get_ts_usec;
|
||||
#endif
|
||||
return get_ts_gettimeofday;
|
||||
}
|
||||
switch (type) {
|
||||
case OPAL_TIMING_GET_TIME_OF_DAY:
|
||||
return get_ts_gettimeofday;
|
||||
|
||||
case OPAL_TIMING_CYCLE_NATIVE:
|
||||
#if OPAL_TIMER_CYCLE_NATIVE
|
||||
return get_ts_cycle;
|
||||
#else
|
||||
return NULL;
|
||||
#endif // OPAL_TIMER_CYCLE_NATIVE
|
||||
case OPAL_TIMING_USEC_NATIVE:
|
||||
#if OPAL_TIMER_USEC_NATIVE
|
||||
return get_ts_usec;
|
||||
#else
|
||||
return NULL;
|
||||
#endif // OPAL_TIMER_USEC_NATIVE
|
||||
default:
|
||||
if( !opal_initialized ){
|
||||
return get_ts_gettimeofday;
|
||||
}
|
||||
#if OPAL_TIMER_CYCLE_NATIVE
|
||||
return get_ts_cycle;
|
||||
#elif OPAL_TIMER_USEC_NATIVE
|
||||
return get_ts_usec;
|
||||
#endif
|
||||
return get_ts_gettimeofday;
|
||||
}
|
||||
}
|
||||
|
||||
opal_timing_event_t *opal_timing_event_alloc(opal_timing_t *t)
|
||||
{
|
||||
@ -209,7 +224,7 @@ opal_timing_event_t *opal_timing_event_alloc(opal_timing_t *t)
|
||||
return t->buffer + tmp;
|
||||
}
|
||||
|
||||
void opal_timing_init(opal_timing_t *t)
|
||||
int opal_timing_init(opal_timing_t *t, opal_timer_type_t type)
|
||||
{
|
||||
memset(t,0,sizeof(*t));
|
||||
|
||||
@ -223,8 +238,11 @@ void opal_timing_init(opal_timing_t *t)
|
||||
* will be allocated at first event report */
|
||||
t->buffer_offset = t->buffer_size;
|
||||
/* initialize gettime function */
|
||||
t->get_ts = _init_timestamping();
|
||||
|
||||
t->get_ts = _init_timestamping(type);
|
||||
if (NULL == t->get_ts) {
|
||||
return OPAL_ERR_BAD_PARAM;
|
||||
}
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
opal_timing_prep_t opal_timing_prep_ev(opal_timing_t *t, const char *fmt, ...)
|
||||
|
@ -16,6 +16,13 @@
|
||||
#include "opal/class/opal_list.h"
|
||||
#include "opal/runtime/opal_params.h"
|
||||
|
||||
typedef enum {
|
||||
OPAL_TIMING_AUTOMATIC_TIMER,
|
||||
OPAL_TIMING_GET_TIME_OF_DAY,
|
||||
OPAL_TIMING_CYCLE_NATIVE,
|
||||
OPAL_TIMING_USEC_NATIVE
|
||||
} opal_timer_type_t;
|
||||
|
||||
#if OPAL_ENABLE_TIMING
|
||||
|
||||
#define OPAL_TIMING_DESCR_MAX 1024
|
||||
@ -94,7 +101,7 @@ int opal_timing_set_jobid(char *jid);
|
||||
* @retval OPAL_SUCCESS On success
|
||||
* @retval OPAL_ERROR On failure
|
||||
*/
|
||||
void opal_timing_init(opal_timing_t *t);
|
||||
int opal_timing_init(opal_timing_t *t, opal_timer_type_t type);
|
||||
|
||||
/**
|
||||
* Prepare timing event, do all printf-like processing.
|
||||
@ -278,7 +285,16 @@ void opal_timing_release(opal_timing_t *t);
|
||||
*
|
||||
* @see opal_timing_init()
|
||||
*/
|
||||
#define OPAL_TIMING_INIT(t) opal_timing_init(t)
|
||||
#define OPAL_TIMING_INIT(t) opal_timing_init(t, OPAL_TIMING_AUTOMATIC_TIMER)
|
||||
|
||||
/**
|
||||
* Main macro for use in initializing opal timing handler;
|
||||
* will be "compiled out" when OPAL is configured without
|
||||
* --enable-timing.
|
||||
*
|
||||
* @see opal_timing_init()
|
||||
*/
|
||||
#define OPAL_TIMING_INIT_EXT(t, type) opal_timing_init(t, type)
|
||||
|
||||
/**
|
||||
* Macro that enqueues event with its description to the specified
|
||||
@ -408,6 +424,8 @@ void opal_timing_release(opal_timing_t *t);
|
||||
|
||||
#define OPAL_TIMING_INIT(t)
|
||||
|
||||
#define OPAL_TIMING_INIT_EXT(t, type)
|
||||
|
||||
#define OPAL_TIMING_EVENT(x)
|
||||
|
||||
#define OPAL_TIMING_MDESCR(x)
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user