1
1

Cleanup timing macros for portability across compilers. Rename the --enable-timing configure option to be --enable-pmix-timing so it doesn't pickup external timing requests. Remove a stale function reference in PMIx so it can compile with timing enabled.

Signed-off-by: Ralph Castain <rhc@open-mpi.org>
Этот коммит содержится в:
Ralph Castain 2017-04-07 12:15:46 -07:00 коммит произвёл Boris Karasev
родитель 36a0e71f2d
Коммит 95ae0d1df3
8 изменённых файлов: 325 добавлений и 326 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -244,6 +244,7 @@ ompi/mpiext/cuda/c/mpiext_cuda_c.h
ompi/tools/mpisync/mpisync
ompi/tools/mpisync/mpirun_prof
ompi/tools/mpisync/ompi_timing_post
ompi/tools/mpisync/mpisync.1
ompi/tools/ompi_info/ompi_info
ompi/tools/ompi_info/ompi_info.1

Просмотреть файл

@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 Artem Polyakov <artpol84@gmail.com>
* Copyright (c) 2014 Intel, Inc. All rights reserved.
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -139,7 +139,6 @@ int main(int argc, char **argv)
MPI_Gather(hname,sizeof(hname),MPI_CHAR,hnames,sizeof(hname),MPI_CHAR, 0, MPI_COMM_WORLD);
MPI_Gather(send,2,MPI_DOUBLE,measure,2, MPI_DOUBLE, 0, MPI_COMM_WORLD);
char tmpname[128];
FILE *fp = fopen(filename,"w");
if( fp == NULL ){
fprintf(stderr, "Fail to open the file %s. Abort\n", filename);

Просмотреть файл

@ -33,7 +33,7 @@ typedef struct {
#define OMPI_TIMING_INIT(_size) \
ompi_timing_t OMPI_TIMING; \
OMPI_TIMING.prefix = __FUNCTION__; \
OMPI_TIMING.prefix = __func__; \
OMPI_TIMING.size = _size; \
OMPI_TIMING.get_ts = opal_timing_ts_func(OPAL_TIMING_AUTOMATIC_TIMER); \
OMPI_TIMING.cnt = 0; \
@ -55,21 +55,23 @@ typedef struct {
} \
}
#define OMPI_TIMING_ITEM_EXTEND ({ \
#define OMPI_TIMING_ITEM_EXTEND \
do { \
if (OMPI_TIMING.enabled) { \
OMPI_TIMING.cur_timing->next = (struct ompi_timing_list_t*)malloc(sizeof(ompi_timing_list_t)); \
OMPI_TIMING.cur_timing = (ompi_timing_list_t*)OMPI_TIMING.cur_timing->next; \
memset(OMPI_TIMING.cur_timing, 0, sizeof(ompi_timing_list_t)); \
OMPI_TIMING.cur_timing->val = malloc(sizeof(ompi_timing_val_t) * OMPI_TIMING.size); \
} \
})
} while(0)
#define OMPI_TIMING_FINALIZE ({ \
#define OMPI_TIMING_FINALIZE \
do { \
if (OMPI_TIMING.enabled) { \
ompi_timing_list_t *t = OMPI_TIMING.timing, *tmp; \
while ( NULL != t) { \
tmp = t; \
t = t->next; \
t = (ompi_timing_list_t*)t->next; \
free(tmp->val); \
free(tmp); \
} \
@ -77,9 +79,10 @@ typedef struct {
OMPI_TIMING.cur_timing = NULL; \
OMPI_TIMING.cnt = 0; \
} \
})
} while(0)
#define OMPI_TIMING_NEXT(fmt, ...) ({ \
#define OMPI_TIMING_NEXT(...) \
do { \
if (!OMPI_TIMING.error && OMPI_TIMING.enabled) { \
char *f = strrchr(__FILE__, '/') + 1; \
int len = 0; \
@ -87,20 +90,21 @@ typedef struct {
OMPI_TIMING_ITEM_EXTEND; \
} \
len = snprintf(OMPI_TIMING.cur_timing->val[OMPI_TIMING.cur_timing->use].desc, \
OPAL_TIMING_STR_LEN, fmt, ##__VA_ARGS__); \
OPAL_TIMING_STR_LEN, ##__VA_ARGS__); \
if (len >= OPAL_TIMING_STR_LEN) { \
OMPI_TIMING.error = 1; \
} \
OMPI_TIMING.cur_timing->val[OMPI_TIMING.cur_timing->use].file = f; \
OMPI_TIMING.cur_timing->val[OMPI_TIMING.cur_timing->use].prefix = __FUNCTION__; \
OMPI_TIMING.cur_timing->val[OMPI_TIMING.cur_timing->use].file = strdup(f); \
OMPI_TIMING.cur_timing->val[OMPI_TIMING.cur_timing->use].prefix = strdup(__func__); \
OMPI_TIMING.cur_timing->val[OMPI_TIMING.cur_timing->use++].ts = \
OMPI_TIMING.get_ts() - OMPI_TIMING.ts; \
OMPI_TIMING.cnt++; \
OMPI_TIMING.ts = OMPI_TIMING.get_ts(); \
} \
})
} while(0)
#define OMPI_TIMING_APPEND(filename,func,desc,ts) { \
#define OMPI_TIMING_APPEND(filename,func,desc,ts) \
do { \
if (OMPI_TIMING.cur_timing->use >= OMPI_TIMING.size){ \
OMPI_TIMING_ITEM_EXTEND; \
} \
@ -115,27 +119,31 @@ typedef struct {
OMPI_TIMING.get_ts() - OMPI_TIMING.ts; \
OMPI_TIMING.cnt++; \
OMPI_TIMING.ts = OMPI_TIMING.get_ts(); \
}
} while(0)
#define OMPI_TIMING_IMPORT_OPAL_PREFIX(_prefix, func) { \
#define OMPI_TIMING_IMPORT_OPAL_PREFIX(_prefix, func) \
do { \
if (!OMPI_TIMING.error && OMPI_TIMING.enabled) { \
int cnt = OPAL_TIMING_ENV_CNT(func); \
int cnt; \
int i; \
OMPI_TIMING.error = OPAL_TIMING_ENV_ERROR_PREFIX(_prefix, func); \
double ts; \
OPAL_TIMING_ENV_CNT(func, cnt); \
OPAL_TIMING_ENV_ERROR_PREFIX(_prefix, func, OMPI_TIMING.error); \
for(i = 0; i < cnt; i++){ \
char *desc, *filename; \
double ts = OPAL_TIMING_ENV_GETDESC_PREFIX(_prefix, &filename, func, i, &desc); \
OPAL_TIMING_ENV_GETDESC_PREFIX(_prefix, &filename, func, i, &desc, ts); \
OMPI_TIMING_APPEND(filename, func, desc, ts); \
} \
} \
}
} while(0)
#define OMPI_TIMING_IMPORT_OPAL(func) \
OMPI_TIMING_IMPORT_OPAL_PREFIX("", func)
#define OMPI_TIMING_OUT ({ \
#define OMPI_TIMING_OUT \
do { \
if (OMPI_TIMING.enabled) { \
int i, size, rank; \
MPI_Comm_size(MPI_COMM_WORLD, &size); \
@ -204,7 +212,7 @@ typedef struct {
free(file); \
} \
} \
})
} while(0)
#else
#define OMPI_TIMING_INIT(size)

Просмотреть файл

@ -49,7 +49,19 @@ AC_DEFUN([MCA_opal_pmix_pmix2x_CONFIG],[
opal_pmix_pmix2x_sm_flag=--disable-dstore
fi
opal_pmix_pmix2x_args="--with-pmix-symbol-rename=OPAL_MCA_PMIX2X_ $opal_pmix_pmix2x_sm_flag --without-tests-examples --disable-visibility --enable-embedded-libevent --with-libevent-header=\\\"opal/mca/event/$opal_event_base_include\\\""
AC_ARG_ENABLE([pmix-timing],
[AC_HELP_STRING([--enable-pmix-timing],
[Enable PMIx timing measurements (default: disabled)])])
AC_MSG_CHECKING([if PMIx timing is enabled])
if test "$enable_pmix_timing" == "yes"; then
AC_MSG_RESULT([yes])
opal_pmix_pmix2x_timing_flag=--enable-pmix-timing
else
AC_MSG_RESULT([no (disabled)])
opal_pmix_pmix2x_timing_flag=--disable-pmix-timing
fi
opal_pmix_pmix2x_args="--with-pmix-symbol-rename=OPAL_MCA_PMIX2X_ $opal_pmix_pmix2x_sm_flag $opal_pmix_pmix2x_timing_flag --without-tests-examples --disable-visibility --enable-embedded-libevent --with-libevent-header=\\\"opal/mca/event/$opal_event_base_include\\\""
AS_IF([test "$enable_debug" = "yes"],
[opal_pmix_pmix2x_args="--enable-debug $opal_pmix_pmix2x_args"
CFLAGS="$OPAL_CFLAGS_BEFORE_PICKY $OPAL_VISIBILITY_CFLAGS -g"],

Просмотреть файл

@ -950,18 +950,18 @@ AC_MSG_RESULT([$with_ident_string])
# Timing support
#
AC_MSG_CHECKING([if want developer-level timing support])
AC_ARG_ENABLE(timing,
AC_HELP_STRING([--enable-timing],
AC_ARG_ENABLE(pmix-timing,
AC_HELP_STRING([--enable-pmix-timing],
[enable developer-level timing code (default: disabled)]))
if test "$enable_timing" = "yes"; then
if test "$enable_pmix_timing" = "yes"; then
AC_MSG_RESULT([yes])
WANT_TIMING=1
WANT_PMIX_TIMING=1
else
AC_MSG_RESULT([no])
WANT_TIMING=0
WANT_PMIX_TIMING=0
fi
AC_DEFINE_UNQUOTED([PMIX_ENABLE_TIMING], [$WANT_TIMING],
AC_DEFINE_UNQUOTED([PMIX_ENABLE_TIMING], [$WANT_PMIX_TIMING],
[Whether we want developer-level timing support or not])
#

Просмотреть файл

@ -21,7 +21,7 @@
* and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Mellanox Technologies, Inc.
* All rights reserved.
* Copyright (c) 2016 Intel, Inc. All rights reserved.
* Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -37,7 +37,6 @@
#include "src/util/timings.h"
#if PMIX_ENABLE_TIMING
char *pmix_timing_sync_file = NULL;
char *pmix_timing_output = NULL;
bool pmix_timing_overhead = true;
#endif
@ -56,16 +55,6 @@ pmix_status_t pmix_register_params(void)
pmix_register_done = true;
#if PMIX_ENABLE_TIMING
pmix_timing_sync_file = NULL;
(void) pmix_mca_base_var_register ("pmix", "pmix", NULL, "timing_sync_file",
"Clock synchronisation information generated by mpisync tool. You don't need to touch this if you use mpirun_prof tool.",
PMIX_MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
PMIX_INFO_LVL_9, PMIX_MCA_BASE_VAR_SCOPE_ALL,
&pmix_timing_sync_file);
if( pmix_timing_clocksync_read(pmix_timing_sync_file) ){
pmix_output(0, "Cannot read file %s containing clock synchronisation information\n", pmix_timing_sync_file);
}
pmix_timing_output = NULL;
(void) pmix_mca_base_var_register ("pmix", "pmix", NULL, "timing_output",
"The name of output file for timing information. If this parameter is not set then output will be directed into PMIX debug channel.",

Просмотреть файл

@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 Artem Polyakov <artpol84@gmail.com>
* Copyright (c) 2014 Intel, Inc. All rights reserved.
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -39,47 +39,46 @@ typedef struct {
opal_timing_ts_func_t opal_timing_ts_func(opal_timer_type_t type);
#define OPAL_TIMING_ENV_START_TYPE(func, type, prefix) ({ \
opal_timing_env_t h; \
#define OPAL_TIMING_ENV_START_TYPE(func, _nm, type, prefix) \
do { \
char *ptr = NULL; \
char *_prefix = prefix; \
int n; \
if( NULL == prefix ){ \
_prefix = ""; \
} \
h.error = 0; \
n = snprintf(h.id, OPAL_TIMING_STR_LEN, "%s%s", _prefix, func); \
(_nm)->error = 0; \
n = snprintf((_nm)->id, OPAL_TIMING_STR_LEN, "%s%s", _prefix, func); \
if( n > OPAL_TIMING_STR_LEN ){ \
h.error = 1; \
(_nm)->error = 1; \
} \
n = sprintf(h.cntr_env,"OMPI_TIMING_%s%s_CNT", prefix, h.id); \
n = sprintf((_nm)->cntr_env,"OMPI_TIMING_%s%s_CNT", prefix, (_nm)->id); \
if( n > OPAL_TIMING_STR_LEN ){ \
h.error = 1; \
(_nm)->error = 1; \
} \
ptr = getenv(h.id); \
ptr = getenv((_nm)->id); \
if( NULL == ptr || strcmp(ptr, "1")){ \
h.enabled = 0; \
(_nm)->enabled = 0; \
} \
h.get_ts = opal_timing_ts_func(type); \
(_nm)->get_ts = opal_timing_ts_func(type); \
ptr = getenv("OPAL_TIMING_ENABLE"); \
if (NULL != ptr) { \
h.enabled = atoi(ptr); \
(_nm)->enabled = atoi(ptr); \
} \
h.cntr = 0; \
ptr = getenv(h.id); \
(_nm)->cntr = 0; \
ptr = getenv((_nm)->id); \
if( NULL != ptr ){ \
h.cntr = atoi(ptr); \
(_nm)->cntr = atoi(ptr); \
} \
h.ts = h.get_ts(); \
if ( 0 != h.error ){ \
h.enabled = 0; \
(_nm)->ts = (_nm)->get_ts(); \
if ( 0 != (_nm)->error ){ \
(_nm)->enabled = 0; \
} \
h; \
})
} while(0)
#define OPAL_TIMING_ENV_INIT(name) \
opal_timing_env_t name ## _val, *name = &(name ## _val); \
*name = OPAL_TIMING_ENV_START_TYPE(__FUNCTION__, OPAL_TIMING_AUTOMATIC_TIMER, "");
OPAL_TIMING_ENV_START_TYPE(__func__, name, OPAL_TIMING_AUTOMATIC_TIMER, "");
/* We use function names for identification
* however this might be a problem for the private
@ -88,10 +87,13 @@ opal_timing_ts_func_t opal_timing_ts_func(opal_timer_type_t type);
* Use prefix to do a finer-grained identification if needed
*/
#define OPAL_TIMING_ENV_INIT_PREFIX(prefix, name) \
do { \
opal_timing_env_t name ## _val, *name = &(name ## _val); \
*name = OPAL_TIMING_ENV_START_TYPE(__FUNCTION__, OPAL_TIMING_AUTOMATIC_TIMER, prefix);
*name = OPAL_TIMING_ENV_START_TYPE(__func__, OPAL_TIMING_AUTOMATIC_TIMER, prefix); \
} while(0)
#define OPAL_TIMING_ENV_NEXT(h, fmt, ...) ({ \
#define OPAL_TIMING_ENV_NEXT(h, ...) \
do { \
int n; \
char buf1[OPAL_TIMING_STR_LEN], buf2[OPAL_TIMING_STR_LEN]; \
double time; \
@ -103,7 +105,7 @@ opal_timing_ts_func_t opal_timing_ts_func(opal_timer_type_t type);
if ( n > OPAL_TIMING_STR_LEN ){ \
h->error = 1; \
} \
n = snprintf(buf2, OPAL_TIMING_STR_LEN, fmt, ## __VA_ARGS__ ); \
n = snprintf(buf2, OPAL_TIMING_STR_LEN, __VA_ARGS__ ); \
if ( n > OPAL_TIMING_STR_LEN ){ \
h->error = 1; \
} \
@ -146,42 +148,43 @@ opal_timing_ts_func_t opal_timing_ts_func(opal_timer_type_t type);
} \
setenv(buf1, buf2, 1); \
} \
})
} while(0)
/* This function supposed to be called from the code that will
* do the postprocessing, i.e. OMPI timing portion that will
* do the reduction of accumulated values
*/
#define OPAL_TIMING_ENV_CNT_PREFIX(prefix, func) ({ \
#define OPAL_TIMING_ENV_CNT_PREFIX(prefix, func, _cnt) \
do { \
char ename[OPAL_TIMING_STR_LEN]; \
int cnt = 0; \
char *ptr = NULL; \
int n = snprintf(ename, OPAL_TIMING_STR_LEN, "OMPI_TIMING_%s%s_CNT", prefix, func); \
(_cnt) = 0; \
if ( n <= OPAL_TIMING_STR_LEN ){ \
ptr = getenv(ename); \
if( NULL != ptr ){ cnt = atoi(ptr); }; \
if( NULL != ptr ){ (_cnt) = atoi(ptr); }; \
} \
cnt; \
})
} while(0)
#define OPAL_TIMING_ENV_ERROR_PREFIX(prefix, func) ({ \
#define OPAL_TIMING_ENV_ERROR_PREFIX(prefix, func, _err) \
do { \
char ename[OPAL_TIMING_STR_LEN]; \
int error = 0; \
(_err) = 0; \
char *ptr = NULL; \
int n = snprintf(ename, OPAL_TIMING_STR_LEN, "OMPI_TIMING_%s%s_ERROR", prefix, func); \
if ( n <= OPAL_TIMING_STR_LEN ){ \
ptr = getenv(ename); \
if( NULL != ptr ){ error = atoi(ptr); }; \
if( NULL != ptr ){ (_err) = atoi(ptr); }; \
} \
error; \
})
} while(0)
#define OPAL_TIMING_ENV_CNT(func) \
OPAL_TIMING_ENV_CNT_PREFIX("", func)
#define OPAL_TIMING_ENV_CNT(func, _cnt) \
OPAL_TIMING_ENV_CNT_PREFIX("", func, _cnt)
#define OPAL_TIMING_ENV_GETDESC_PREFIX(prefix, filename, func, i, desc) ({ \
#define OPAL_TIMING_ENV_GETDESC_PREFIX(prefix, filename, func, i, desc, _t) \
do { \
char vname[OPAL_TIMING_STR_LEN]; \
double ts = 0.0; \
(_t) = 0.0; \
sprintf(vname, "OMPI_TIMING_%s%s_FILE_%d", prefix, func, i); \
*filename = getenv(vname); \
sprintf(vname, "OMPI_TIMING_%s%s_DESC_%d", prefix, func, i); \
@ -189,10 +192,9 @@ opal_timing_ts_func_t opal_timing_ts_func(opal_timer_type_t type);
sprintf(vname, "OMPI_TIMING_%s%s_VAL_%d", prefix, func, i); \
char *ptr = getenv(vname); \
if ( NULL != ptr ) { \
sscanf(ptr,"%lf", &ts); \
sscanf(ptr,"%lf", &(_t)); \
} \
ts; \
})
} while(0)
#define OPAL_TIMING_ENV_GETDESC(file, func, index, desc) \
OPAL_TIMING_ENV_GETDESC_PREFIX("", file, func, index, desc)

Просмотреть файл

@ -343,9 +343,6 @@ void mca_oob_tcp_send_handler(int sd, short flags, void *cbdata)
static int read_bytes(mca_oob_tcp_peer_t* peer)
{
int rc;
#if OPAL_ENABLE_TIMING
int to_read = peer->recv_msg->rdbytes;
#endif
/* read until all bytes recvd or error */
while (0 < peer->recv_msg->rdbytes) {
@ -431,9 +428,6 @@ void mca_oob_tcp_recv_handler(int sd, short flags, void *cbdata)
mca_oob_tcp_peer_t* peer = (mca_oob_tcp_peer_t*)cbdata;
int rc;
orte_rml_send_t *snd;
#if OPAL_ENABLE_TIMING
bool timing_same_as_hdr = false;
#endif
opal_output_verbose(OOB_TCP_DEBUG_CONNECT, orte_oob_base_framework.framework_output,
"%s:tcp:recv:handler called for peer %s",
@ -503,13 +497,7 @@ void mca_oob_tcp_recv_handler(int sd, short flags, void *cbdata)
opal_output_verbose(OOB_TCP_DEBUG_CONNECT, orte_oob_base_framework.framework_output,
"%s:tcp:recv:handler read hdr",
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME));
#if OPAL_ENABLE_TIMING
int to_recv = peer->recv_msg->rdbytes;
#endif
if (ORTE_SUCCESS == (rc = read_bytes(peer))) {
#if OPAL_ENABLE_TIMING
timing_same_as_hdr = true;
#endif
/* completed reading the header */
peer->recv_msg->hdr_recvd = true;
/* convert the header */