From 885fc8432d8531111c8898c726c90e3b0c8ba632 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Tue, 18 Dec 2012 03:45:09 +0000 Subject: [PATCH] Fix the printing and handling of sample times in stats objects This commit was SVN r27681. --- opal/dss/dss_pack.c | 13 +++++++------ opal/dss/dss_print.c | 17 ++++++----------- opal/dss/dss_unpack.c | 13 +++++++------ 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/opal/dss/dss_pack.c b/opal/dss/dss_pack.c index 0305753ff3..d8ce2b35c0 100644 --- a/opal/dss/dss_pack.c +++ b/opal/dss/dss_pack.c @@ -378,7 +378,7 @@ static int opal_dss_pack_float(opal_buffer_t *buffer, float val) if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &tmp1, 1, OPAL_INT32))) { return ret; } - tmp2 = (int)(100.0 * (val - (int)val)); + tmp2 = (int)(1000.0 * (val - (int)val)); if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &tmp2, 1, OPAL_INT32))) { return ret; } @@ -392,7 +392,8 @@ int opal_dss_pack_pstat(opal_buffer_t *buffer, const void *src, int32_t num_vals, opal_data_type_t type) { opal_pstats_t **ptr; - int32_t i, tmp; + int32_t i; + int64_t tmp; int ret; char *cptr; @@ -417,11 +418,11 @@ int opal_dss_pack_pstat(opal_buffer_t *buffer, const void *src, return ret; } tmp = ptr[i]->time.tv_sec; - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &tmp, 1, OPAL_INT32))) { + if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &tmp, 1, OPAL_INT64))) { return ret; } tmp = ptr[i]->time.tv_usec; - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &tmp, 1, OPAL_INT32))) { + if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &tmp, 1, OPAL_INT64))) { return ret; } if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->priority, 1, OPAL_INT32))) { @@ -443,11 +444,11 @@ int opal_dss_pack_pstat(opal_buffer_t *buffer, const void *src, return ret; } tmp = ptr[i]->sample_time.tv_sec; - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &tmp, 1, OPAL_INT32))) { + if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &tmp, 1, OPAL_INT64))) { return ret; } tmp = ptr[i]->sample_time.tv_usec; - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &tmp, 1, OPAL_INT32))) { + if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &tmp, 1, OPAL_INT64))) { return ret; } } diff --git a/opal/dss/dss_print.c b/opal/dss/dss_print.c index 1a63d007c5..dca324bb76 100644 --- a/opal/dss/dss_print.c +++ b/opal/dss/dss_print.c @@ -420,7 +420,6 @@ int opal_dss_print_byte_object(char **output, char *prefix, opal_byte_object_t * int opal_dss_print_pstat(char **output, char *prefix, opal_pstats_t *src, opal_data_type_t type) { char *prefx; - float ftime, ftime1; /* deal with NULL prefix */ if (NULL == prefix) asprintf(&prefx, " "); @@ -431,13 +430,11 @@ int opal_dss_print_pstat(char **output, char *prefix, opal_pstats_t *src, opal_d asprintf(output, "%sData type: OPAL_PSTATS\tValue: NULL pointer", prefx); return OPAL_SUCCESS; } - ftime = (float)src->time.tv_sec + ((float)src->time.tv_usec / 1000000.0); - ftime1 = (float)src->sample_time.tv_sec + ((float)src->sample_time.tv_usec / 1000000.0); - asprintf(output, "%sOPAL_PSTATS SAMPLED AT: %f\n%snode: %s rank: %d pid: %d cmd: %s state: %c pri: %d #threads: %d Processor: %d\n" - "%s\ttime: %f cpu: %5.2f VMsize: %8.2f PeakVMSize: %8.2f RSS: %8.2f\n", - prefx, ftime1, + asprintf(output, "%sOPAL_PSTATS SAMPLED AT: %ld.%ld\n%snode: %s rank: %d pid: %d cmd: %s state: %c pri: %d #threads: %d Processor: %d\n" + "%s\ttime: %ld.%ld cpu: %5.2f VMsize: %8.2f PeakVMSize: %8.2f RSS: %8.2f\n", + prefx, (long)src->sample_time.tv_sec, (long)src->sample_time.tv_usec, prefx, src->node, src->rank, src->pid, src->cmd, src->state[0], src->priority, src->num_threads, src->processor, - prefx, ftime, src->percent_cpu, src->vsize, src->peak_vsize, src->rss); + prefx, (long)src->time.tv_sec, (long)src->time.tv_usec, src->percent_cpu, src->vsize, src->peak_vsize, src->rss); return OPAL_SUCCESS; } @@ -448,7 +445,6 @@ int opal_dss_print_pstat(char **output, char *prefix, opal_pstats_t *src, opal_d int opal_dss_print_node_stat(char **output, char *prefix, opal_node_stats_t *src, opal_data_type_t type) { char *prefx; - float ftime1; /* deal with NULL prefix */ if (NULL == prefix) asprintf(&prefx, " "); @@ -459,11 +455,10 @@ int opal_dss_print_node_stat(char **output, char *prefix, opal_node_stats_t *src asprintf(output, "%sData type: OPAL_NODE_STATS\tValue: NULL pointer", prefx); return OPAL_SUCCESS; } - ftime1 = (float)src->sample_time.tv_sec + ((float)src->sample_time.tv_usec / 1000000.0); - asprintf(output, "%sOPAL_NODE_STATS SAMPLED AT: %f\n%sTotal Mem: %5.2f Free Mem: %5.2f Buffers: %5.2f Cached: %5.2f\n" + asprintf(output, "%sOPAL_NODE_STATS SAMPLED AT: %ld.%ld\n%sTotal Mem: %5.2f Free Mem: %5.2f Buffers: %5.2f Cached: %5.2f\n" "%sSwapCached: %5.2f SwapTotal: %5.2f SwapFree: %5.2f Mapped: %5.2f\n" "%s\tla: %5.2f\tla5: %5.2f\tla15: %5.2f\n", - prefx, ftime1, + prefx, (long)src->sample_time.tv_sec, (long)src->sample_time.tv_usec, prefx, src->total_mem, src->free_mem, src->buffers, src->cached, prefx, src->swap_cached, src->swap_total, src->swap_free, src->mapped, prefx, src->la, src->la5, src->la15); diff --git a/opal/dss/dss_unpack.c b/opal/dss/dss_unpack.c index bc1f185f27..3a7f56f83d 100644 --- a/opal/dss/dss_unpack.c +++ b/opal/dss/dss_unpack.c @@ -464,7 +464,7 @@ static int opal_dss_unpack_float(opal_buffer_t *buffer, float *value) OPAL_ERROR_LOG(ret); return ret; } - *value = (float)tmp1 + (float)tmp2/100.0; + *value = (float)tmp1 + (float)tmp2/1000.0; return OPAL_SUCCESS; } @@ -475,7 +475,8 @@ int opal_dss_unpack_pstat(opal_buffer_t *buffer, void *dest, int32_t *num_vals, opal_data_type_t type) { opal_pstats_t **ptr; - int32_t i, n, m, tmp1, tmp2; + int32_t i, n, m; + int64_t tmp1, tmp2; int ret; char *cptr; @@ -518,12 +519,12 @@ int opal_dss_unpack_pstat(opal_buffer_t *buffer, void *dest, return ret; } m=1; - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &tmp1, &m, OPAL_INT32))) { + if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &tmp1, &m, OPAL_INT64))) { OPAL_ERROR_LOG(ret); return ret; } m=1; - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &tmp2, &m, OPAL_INT32))) { + if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &tmp2, &m, OPAL_INT64))) { OPAL_ERROR_LOG(ret); return ret; } @@ -558,12 +559,12 @@ int opal_dss_unpack_pstat(opal_buffer_t *buffer, void *dest, return ret; } m=1; - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &tmp1, &m, OPAL_INT32))) { + if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &tmp1, &m, OPAL_INT64))) { OPAL_ERROR_LOG(ret); return ret; } m=1; - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &tmp2, &m, OPAL_INT32))) { + if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &tmp2, &m, OPAL_INT64))) { OPAL_ERROR_LOG(ret); return ret; }