Add float and struct timeval fields to the opal_value_t object, and provide dss support for those data types
This commit was SVN r27705.
Этот коммит содержится в:
родитель
b29b852281
Коммит
6046812952
@ -169,6 +169,15 @@ int opal_dss_compare_uint64(uint64_t *value1, uint64_t *value2, opal_data_type_t
|
||||
return OPAL_EQUAL;
|
||||
}
|
||||
|
||||
int opal_dss_compare_float(float *value1, float *value2, opal_data_type_t type)
|
||||
{
|
||||
if (*value1 > *value2) return OPAL_VALUE1_GREATER;
|
||||
|
||||
if (*value2 > *value1) return OPAL_VALUE2_GREATER;
|
||||
|
||||
return OPAL_EQUAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* NON-NUMERIC SYSTEM TYPES
|
||||
*/
|
||||
@ -200,6 +209,19 @@ int opal_dss_compare_string(char *value1, char *value2, opal_data_type_t type)
|
||||
return OPAL_EQUAL;
|
||||
}
|
||||
|
||||
/* TIMEVAL */
|
||||
int opal_dss_compare_timeval(struct timeval *value1, struct timeval *value2, opal_data_type_t type)
|
||||
{
|
||||
if (value1->tv_sec > value2->tv_sec) return OPAL_VALUE1_GREATER;
|
||||
if (value2->tv_sec > value1->tv_sec) return OPAL_VALUE2_GREATER;
|
||||
|
||||
/* seconds were equal - check usec's */
|
||||
if (value1->tv_usec > value2->tv_usec) return OPAL_VALUE1_GREATER;
|
||||
if (value2->tv_usec > value1->tv_usec) return OPAL_VALUE2_GREATER;
|
||||
|
||||
return OPAL_EQUAL;
|
||||
}
|
||||
|
||||
/* COMPARE FUNCTIONS FOR GENERIC OPAL TYPES */
|
||||
/* OPAL_DATA_TYPE */
|
||||
int opal_dss_compare_dt(opal_data_type_t *value1, opal_data_type_t *value2, opal_data_type_t type)
|
||||
|
@ -51,50 +51,58 @@ int opal_dss_std_copy(void **dest, void *src, opal_data_type_t type)
|
||||
uint8_t *val = NULL;
|
||||
|
||||
switch(type) {
|
||||
case OPAL_BOOL:
|
||||
datasize = sizeof(bool);
|
||||
break;
|
||||
case OPAL_BOOL:
|
||||
datasize = sizeof(bool);
|
||||
break;
|
||||
|
||||
case OPAL_INT:
|
||||
case OPAL_UINT:
|
||||
datasize = sizeof(int);
|
||||
break;
|
||||
case OPAL_INT:
|
||||
case OPAL_UINT:
|
||||
datasize = sizeof(int);
|
||||
break;
|
||||
|
||||
case OPAL_SIZE:
|
||||
datasize = sizeof(size_t);
|
||||
break;
|
||||
case OPAL_SIZE:
|
||||
datasize = sizeof(size_t);
|
||||
break;
|
||||
|
||||
case OPAL_PID:
|
||||
datasize = sizeof(pid_t);
|
||||
break;
|
||||
case OPAL_PID:
|
||||
datasize = sizeof(pid_t);
|
||||
break;
|
||||
|
||||
case OPAL_BYTE:
|
||||
case OPAL_INT8:
|
||||
case OPAL_UINT8:
|
||||
datasize = 1;
|
||||
break;
|
||||
case OPAL_BYTE:
|
||||
case OPAL_INT8:
|
||||
case OPAL_UINT8:
|
||||
datasize = 1;
|
||||
break;
|
||||
|
||||
case OPAL_INT16:
|
||||
case OPAL_UINT16:
|
||||
datasize = 2;
|
||||
break;
|
||||
case OPAL_INT16:
|
||||
case OPAL_UINT16:
|
||||
datasize = 2;
|
||||
break;
|
||||
|
||||
case OPAL_INT32:
|
||||
case OPAL_UINT32:
|
||||
datasize = 4;
|
||||
break;
|
||||
case OPAL_INT32:
|
||||
case OPAL_UINT32:
|
||||
datasize = 4;
|
||||
break;
|
||||
|
||||
case OPAL_INT64:
|
||||
case OPAL_UINT64:
|
||||
datasize = 8;
|
||||
break;
|
||||
case OPAL_INT64:
|
||||
case OPAL_UINT64:
|
||||
datasize = 8;
|
||||
break;
|
||||
|
||||
case OPAL_DATA_TYPE:
|
||||
datasize = sizeof(opal_data_type_t);
|
||||
break;
|
||||
case OPAL_DATA_TYPE:
|
||||
datasize = sizeof(opal_data_type_t);
|
||||
break;
|
||||
|
||||
default:
|
||||
return OPAL_ERR_UNKNOWN_DATA_TYPE;
|
||||
case OPAL_FLOAT:
|
||||
datasize = sizeof(float);
|
||||
break;
|
||||
|
||||
case OPAL_TIMEVAL:
|
||||
datasize = sizeof(struct timeval);
|
||||
break;
|
||||
|
||||
default:
|
||||
return OPAL_ERR_UNKNOWN_DATA_TYPE;
|
||||
}
|
||||
|
||||
val = (uint8_t*)malloc(datasize);
|
||||
|
@ -304,6 +304,12 @@ int opal_dss_pack_value(opal_buffer_t *buffer, const void *src,
|
||||
int opal_dss_pack_buffer_contents(opal_buffer_t *buffer, const void *src,
|
||||
int32_t num_vals, opal_data_type_t type);
|
||||
|
||||
int opal_dss_pack_float(opal_buffer_t *buffer, const void *src,
|
||||
int32_t num_vals, opal_data_type_t type);
|
||||
|
||||
int opal_dss_pack_timeval(opal_buffer_t *buffer, const void *src,
|
||||
int32_t num_vals, opal_data_type_t type);
|
||||
|
||||
/*
|
||||
* Internal unpack functions
|
||||
*/
|
||||
@ -352,6 +358,12 @@ int opal_dss_unpack_value(opal_buffer_t *buffer, void *dest,
|
||||
int opal_dss_unpack_buffer_contents(opal_buffer_t *buffer, void *dest,
|
||||
int32_t *num_vals, opal_data_type_t type);
|
||||
|
||||
int opal_dss_unpack_float(opal_buffer_t *buffer, void *dest,
|
||||
int32_t *num_vals, opal_data_type_t type);
|
||||
|
||||
int opal_dss_unpack_timeval(opal_buffer_t *buffer, void *dest,
|
||||
int32_t *num_vals, opal_data_type_t type);
|
||||
|
||||
/*
|
||||
* Internal copy functions
|
||||
*/
|
||||
@ -420,6 +432,10 @@ int opal_dss_compare_value(opal_value_t *value1, opal_value_t *value2, opal_data
|
||||
|
||||
int opal_dss_compare_buffer_contents(opal_buffer_t *value1, opal_buffer_t *value2, opal_data_type_t type);
|
||||
|
||||
int opal_dss_compare_float(float *value1, float *value2, opal_data_type_t type);
|
||||
|
||||
int opal_dss_compare_timeval(struct timeval *value1, struct timeval *value2, opal_data_type_t type);
|
||||
|
||||
/*
|
||||
* Internal print functions
|
||||
*/
|
||||
@ -452,6 +468,8 @@ 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);
|
||||
int opal_dss_print_value(char **output, char *prefix, opal_value_t *src, opal_data_type_t type);
|
||||
int opal_dss_print_buffer_contents(char **output, char *prefix, opal_buffer_t *src, opal_data_type_t type);
|
||||
int opal_dss_print_float(char **output, char *prefix, float *src, opal_data_type_t type);
|
||||
int opal_dss_print_timeval(char **output, char *prefix, struct timeval *src, opal_data_type_t type);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -444,6 +444,26 @@ int opal_dss_open(void)
|
||||
"OPAL_BUFFER", &tmp))) {
|
||||
return rc;
|
||||
}
|
||||
tmp = OPAL_FLOAT;
|
||||
if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_float,
|
||||
opal_dss_unpack_float,
|
||||
(opal_dss_copy_fn_t)opal_dss_std_copy,
|
||||
(opal_dss_compare_fn_t)opal_dss_compare_float,
|
||||
(opal_dss_print_fn_t)opal_dss_print_float,
|
||||
OPAL_DSS_UNSTRUCTURED,
|
||||
"OPAL_FLOAT", &tmp))) {
|
||||
return rc;
|
||||
}
|
||||
tmp = OPAL_TIMEVAL;
|
||||
if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_timeval,
|
||||
opal_dss_unpack_timeval,
|
||||
(opal_dss_copy_fn_t)opal_dss_std_copy,
|
||||
(opal_dss_compare_fn_t)opal_dss_compare_timeval,
|
||||
(opal_dss_print_fn_t)opal_dss_print_timeval,
|
||||
OPAL_DSS_UNSTRUCTURED,
|
||||
"OPAL_TIMEVAL", &tmp))) {
|
||||
return rc;
|
||||
}
|
||||
/* All done */
|
||||
|
||||
opal_dss_initialized = true;
|
||||
|
@ -324,6 +324,47 @@ int opal_dss_pack_string(opal_buffer_t *buffer, const void *src,
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
/* FLOAT */
|
||||
int opal_dss_pack_float(opal_buffer_t *buffer, const void *src,
|
||||
int32_t num_vals, opal_data_type_t type)
|
||||
{
|
||||
int64_t tmp[2];
|
||||
int ret = OPAL_SUCCESS;
|
||||
int32_t i;
|
||||
float *ssrc = (float*)src;
|
||||
|
||||
for (i = 0; i < num_vals; ++i) {
|
||||
tmp[0] = (int64_t)ssrc[i];
|
||||
tmp[1] = (int64_t)(1000000.0 * (ssrc[i] - tmp[0]));
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_int64(buffer, tmp, 2, OPAL_INT64))) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
/* TIMEVAL */
|
||||
int opal_dss_pack_timeval(opal_buffer_t *buffer, const void *src,
|
||||
int32_t num_vals, opal_data_type_t type)
|
||||
{
|
||||
int64_t tmp[2];
|
||||
int ret = OPAL_SUCCESS;
|
||||
int32_t i;
|
||||
struct timeval *ssrc = (struct timeval *)src;
|
||||
|
||||
for (i = 0; i < num_vals; ++i) {
|
||||
tmp[0] = (int64_t)ssrc[i].tv_sec;
|
||||
tmp[1] = (int64_t)ssrc[i].tv_usec;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_int64(buffer, tmp, 2, OPAL_INT64))) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* PACK FUNCTIONS FOR GENERIC OPAL TYPES */
|
||||
|
||||
/*
|
||||
@ -369,22 +410,6 @@ int opal_dss_pack_byte_object(opal_buffer_t *buffer, const void *src, int32_t nu
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static int opal_dss_pack_float(opal_buffer_t *buffer, float val)
|
||||
{
|
||||
int32_t tmp1, tmp2;
|
||||
int ret;
|
||||
|
||||
tmp1 = (int)val;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &tmp1, 1, OPAL_INT32))) {
|
||||
return ret;
|
||||
}
|
||||
tmp2 = (int)(1000.0 * (val - (int)val));
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &tmp2, 1, OPAL_INT32))) {
|
||||
return ret;
|
||||
}
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* OPAL_PSTAT
|
||||
*/
|
||||
@ -393,7 +418,6 @@ int opal_dss_pack_pstat(opal_buffer_t *buffer, const void *src,
|
||||
{
|
||||
opal_pstats_t **ptr;
|
||||
int32_t i;
|
||||
int64_t tmp;
|
||||
int ret;
|
||||
char *cptr;
|
||||
|
||||
@ -417,12 +441,7 @@ int opal_dss_pack_pstat(opal_buffer_t *buffer, const void *src,
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->state[0], 1, OPAL_BYTE))) {
|
||||
return ret;
|
||||
}
|
||||
tmp = ptr[i]->time.tv_sec;
|
||||
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_INT64))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->time, 1, OPAL_TIMEVAL))) {
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->priority, 1, OPAL_INT32))) {
|
||||
@ -431,24 +450,19 @@ int opal_dss_pack_pstat(opal_buffer_t *buffer, const void *src,
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->num_threads, 1, OPAL_INT16))) {
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, ptr[i]->vsize))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->vsize, 1, OPAL_FLOAT))) {
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, ptr[i]->rss))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->rss, 1, OPAL_FLOAT))) {
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, ptr[i]->peak_vsize))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->peak_vsize, 1, OPAL_FLOAT))) {
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->processor, 1, OPAL_INT16))) {
|
||||
return ret;
|
||||
}
|
||||
tmp = ptr[i]->sample_time.tv_sec;
|
||||
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_INT64))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->sample_time, 1, OPAL_TIMEVAL))) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -463,51 +477,46 @@ int opal_dss_pack_node_stat(opal_buffer_t *buffer, const void *src,
|
||||
int32_t num_vals, opal_data_type_t type)
|
||||
{
|
||||
opal_node_stats_t **ptr;
|
||||
int32_t i, tmp;
|
||||
int32_t i;
|
||||
int ret;
|
||||
|
||||
ptr = (opal_node_stats_t **) src;
|
||||
|
||||
for (i = 0; i < num_vals; ++i) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, ptr[i]->la))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->la, 1, OPAL_FLOAT))) {
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, ptr[i]->la5))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->la5, 1, OPAL_FLOAT))) {
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, ptr[i]->la15))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->la15, 1, OPAL_FLOAT))) {
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, ptr[i]->total_mem))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->total_mem, 1, OPAL_FLOAT))) {
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, ptr[i]->free_mem))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->free_mem, 1, OPAL_FLOAT))) {
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, ptr[i]->buffers))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->buffers, 1, OPAL_FLOAT))) {
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, ptr[i]->cached))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->cached, 1, OPAL_FLOAT))) {
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, ptr[i]->swap_cached))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->swap_cached, 1, OPAL_FLOAT))) {
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, ptr[i]->swap_total))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->swap_total, 1, OPAL_FLOAT))) {
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, ptr[i]->swap_free))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->swap_free, 1, OPAL_FLOAT))) {
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, ptr[i]->mapped))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_float(buffer, &ptr[i]->mapped, 1, OPAL_FLOAT))) {
|
||||
return ret;
|
||||
}
|
||||
tmp = ptr[i]->sample_time.tv_sec;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &tmp, 1, OPAL_INT32))) {
|
||||
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, &ptr[i]->sample_time, 1, OPAL_TIMEVAL))) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -614,6 +623,14 @@ int opal_dss_pack_value(opal_buffer_t *buffer, const void *src,
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OPAL_FLOAT:
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.fval, 1, OPAL_FLOAT))) {
|
||||
return ret;
|
||||
}
|
||||
case OPAL_TIMEVAL:
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.tv, 1, OPAL_TIMEVAL))) {
|
||||
return ret;
|
||||
}
|
||||
default:
|
||||
opal_output(0, "PACK-OPAL-VALUE: UNSUPPORTED TYPE %d", (int)ptr[i]->type);
|
||||
return OPAL_ERROR;
|
||||
|
@ -349,6 +349,47 @@ int opal_dss_print_int64(char **output, char *prefix,
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
int opal_dss_print_float(char **output, char *prefix,
|
||||
float *src, opal_data_type_t type)
|
||||
{
|
||||
char *prefx;
|
||||
|
||||
/* deal with NULL prefix */
|
||||
if (NULL == prefix) asprintf(&prefx, " ");
|
||||
else prefx = prefix;
|
||||
|
||||
/* if src is NULL, just print data type and return */
|
||||
if (NULL == src) {
|
||||
asprintf(output, "%sData type: OPAL_FLOAT\tValue: NULL pointer", prefx);
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
asprintf(output, "%sData type: OPAL_FLOAT\tValue: %f", prefx, *src);
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
int opal_dss_print_timeval(char **output, char *prefix,
|
||||
struct timeval *src, opal_data_type_t type)
|
||||
{
|
||||
char *prefx;
|
||||
|
||||
/* deal with NULL prefix */
|
||||
if (NULL == prefix) asprintf(&prefx, " ");
|
||||
else prefx = prefix;
|
||||
|
||||
/* if src is NULL, just print data type and return */
|
||||
if (NULL == src) {
|
||||
asprintf(output, "%sData type: OPAL_TIMEVAL\tValue: NULL pointer", prefx);
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
asprintf(output, "%sData type: OPAL_TIMEVAL\tValue: %ld.%06ld", prefx,
|
||||
(long)src->tv_sec, (long)src->tv_usec);
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
int opal_dss_print_null(char **output, char *prefix, void *src, opal_data_type_t type)
|
||||
{
|
||||
char *prefx;
|
||||
@ -430,8 +471,8 @@ 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;
|
||||
}
|
||||
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",
|
||||
asprintf(output, "%sOPAL_PSTATS SAMPLED AT: %ld.%06ld\n%snode: %s rank: %d pid: %d cmd: %s state: %c pri: %d #threads: %d Processor: %d\n"
|
||||
"%s\ttime: %ld.%06ld 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, (long)src->time.tv_sec, (long)src->time.tv_usec, src->percent_cpu, src->vsize, src->peak_vsize, src->rss);
|
||||
@ -455,7 +496,7 @@ 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;
|
||||
}
|
||||
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"
|
||||
asprintf(output, "%sOPAL_NODE_STATS SAMPLED AT: %ld.%06ld\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, (long)src->sample_time.tv_sec, (long)src->sample_time.tv_usec,
|
||||
|
@ -68,16 +68,19 @@ typedef struct {
|
||||
#define OPAL_UINT16 (opal_data_type_t) 13 /**< a 16-bit unsigned integer */
|
||||
#define OPAL_UINT32 (opal_data_type_t) 14 /**< a 32-bit unsigned integer */
|
||||
#define OPAL_UINT64 (opal_data_type_t) 15 /**< a 64-bit unsigned integer */
|
||||
/* we don't support floating point types */
|
||||
/* General types */
|
||||
#define OPAL_BYTE_OBJECT (opal_data_type_t) 16 /**< byte object structure */
|
||||
#define OPAL_DATA_TYPE (opal_data_type_t) 17 /**< data type */
|
||||
#define OPAL_NULL (opal_data_type_t) 18 /**< don't interpret data type */
|
||||
#define OPAL_PSTAT (opal_data_type_t) 19 /**< process statistics */
|
||||
#define OPAL_NODE_STAT (opal_data_type_t) 20 /**< node statistics */
|
||||
#define OPAL_HWLOC_TOPO (opal_data_type_t) 21 /**< hwloc topology */
|
||||
#define OPAL_VALUE (opal_data_type_t) 22 /**< opal value structure */
|
||||
#define OPAL_BUFFER (opal_data_type_t) 23 /**< pack the remaining contents of a buffer as an object */
|
||||
/* simple floating point type */
|
||||
#define OPAL_FLOAT (opal_data_type_t) 16
|
||||
/* system types */
|
||||
#define OPAL_TIMEVAL (opal_data_type_t) 17
|
||||
/* OPAL types */
|
||||
#define OPAL_BYTE_OBJECT (opal_data_type_t) 18 /**< byte object structure */
|
||||
#define OPAL_DATA_TYPE (opal_data_type_t) 19 /**< data type */
|
||||
#define OPAL_NULL (opal_data_type_t) 20 /**< don't interpret data type */
|
||||
#define OPAL_PSTAT (opal_data_type_t) 21 /**< process statistics */
|
||||
#define OPAL_NODE_STAT (opal_data_type_t) 22 /**< node statistics */
|
||||
#define OPAL_HWLOC_TOPO (opal_data_type_t) 23 /**< hwloc topology */
|
||||
#define OPAL_VALUE (opal_data_type_t) 24 /**< opal value structure */
|
||||
#define OPAL_BUFFER (opal_data_type_t) 25 /**< pack the remaining contents of a buffer as an object */
|
||||
|
||||
#define OPAL_DSS_ID_DYNAMIC (opal_data_type_t) 30
|
||||
|
||||
@ -107,6 +110,8 @@ typedef struct {
|
||||
uint32_t uint32;
|
||||
uint64_t uint64;
|
||||
opal_byte_object_t bo;
|
||||
float fval;
|
||||
struct timeval tv;
|
||||
} data;
|
||||
} opal_value_t;
|
||||
OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_value_t);
|
||||
|
@ -394,6 +394,58 @@ int opal_dss_unpack_string(opal_buffer_t *buffer, void *dest,
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
int opal_dss_unpack_float(opal_buffer_t *buffer, void *dest,
|
||||
int32_t *num_vals, opal_data_type_t type)
|
||||
{
|
||||
int32_t i, n;
|
||||
int64_t tmp[2];
|
||||
float *desttmp = (float*) dest;
|
||||
int ret;
|
||||
|
||||
OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_unpack_float * %d\n", (int)*num_vals ) );
|
||||
/* check to see if there's enough data in buffer */
|
||||
if (opal_dss_too_small(buffer, (*num_vals)*sizeof(float))) {
|
||||
return OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER;
|
||||
}
|
||||
|
||||
/* unpack the data */
|
||||
for (i = 0; i < (*num_vals); ++i) {
|
||||
n=2;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_int64(buffer, tmp, &n, OPAL_INT64))) {
|
||||
return ret;
|
||||
}
|
||||
desttmp[i] = (float)tmp[0] + (float)tmp[1]/1000000.0;
|
||||
}
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
int opal_dss_unpack_timeval(opal_buffer_t *buffer, void *dest,
|
||||
int32_t *num_vals, opal_data_type_t type)
|
||||
{
|
||||
int32_t i, n;
|
||||
int64_t tmp[2];
|
||||
struct timeval *desttmp = (struct timeval *) dest;
|
||||
int ret;
|
||||
|
||||
OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_unpack_timeval * %d\n", (int)*num_vals ) );
|
||||
/* check to see if there's enough data in buffer */
|
||||
if (opal_dss_too_small(buffer, (*num_vals)*sizeof(struct timeval))) {
|
||||
return OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER;
|
||||
}
|
||||
|
||||
/* unpack the data */
|
||||
for (i = 0; i < (*num_vals); ++i) {
|
||||
n=2;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_int64(buffer, tmp, &n, OPAL_INT64))) {
|
||||
return ret;
|
||||
}
|
||||
desttmp[i].tv_sec = tmp[0];
|
||||
desttmp[i].tv_usec = tmp[1];
|
||||
}
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* UNPACK FUNCTIONS FOR GENERIC OPAL TYPES */
|
||||
|
||||
@ -448,26 +500,6 @@ int opal_dss_unpack_byte_object(opal_buffer_t *buffer, void *dest, int32_t *num,
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static int opal_dss_unpack_float(opal_buffer_t *buffer, float *value)
|
||||
{
|
||||
int32_t m, tmp1, tmp2;
|
||||
int ret;
|
||||
|
||||
*value = 0.0;
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &tmp1, &m, OPAL_INT32))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &tmp2, &m, OPAL_INT32))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
*value = (float)tmp1 + (float)tmp2/1000.0;
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* OPAL_PSTAT
|
||||
*/
|
||||
@ -476,7 +508,6 @@ int opal_dss_unpack_pstat(opal_buffer_t *buffer, void *dest,
|
||||
{
|
||||
opal_pstats_t **ptr;
|
||||
int32_t i, n, m;
|
||||
int64_t tmp1, tmp2;
|
||||
int ret;
|
||||
char *cptr;
|
||||
|
||||
@ -519,18 +550,11 @@ 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_INT64))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->time, &m, OPAL_TIMEVAL))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &tmp2, &m, OPAL_INT64))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
ptr[i]->time.tv_sec = tmp1;
|
||||
ptr[i]->time.tv_usec = tmp2;
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->priority, &m, OPAL_INT32))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
@ -541,15 +565,17 @@ int opal_dss_unpack_pstat(opal_buffer_t *buffer, void *dest,
|
||||
return ret;
|
||||
}
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->vsize))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->vsize, &m, OPAL_FLOAT))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->rss))) {
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->rss, &m, OPAL_FLOAT))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->peak_vsize))) {
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->peak_vsize, &m, OPAL_FLOAT))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
@ -559,17 +585,10 @@ 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_INT64))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->sample_time, &m, OPAL_TIMEVAL))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &tmp2, &m, OPAL_INT64))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
ptr[i]->sample_time.tv_sec = tmp1;
|
||||
ptr[i]->sample_time.tv_usec = tmp2;
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
@ -582,7 +601,7 @@ int opal_dss_unpack_node_stat(opal_buffer_t *buffer, void *dest,
|
||||
int32_t *num_vals, opal_data_type_t type)
|
||||
{
|
||||
opal_node_stats_t **ptr;
|
||||
int32_t i, n, m, tmp1, tmp2;
|
||||
int32_t i, n, m;
|
||||
int ret;
|
||||
|
||||
ptr = (opal_node_stats_t **) dest;
|
||||
@ -594,62 +613,66 @@ int opal_dss_unpack_node_stat(opal_buffer_t *buffer, void *dest,
|
||||
if (NULL == ptr[i]) {
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->la))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->la5))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->la15))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->total_mem))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->free_mem))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->buffers))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->cached))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->swap_cached))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->swap_total))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->swap_free))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->mapped))) {
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->la, &m, OPAL_FLOAT))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &tmp1, &m, OPAL_INT32))) {
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->la5, &m, OPAL_FLOAT))) {
|
||||
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_float(buffer, &ptr[i]->la15, &m, OPAL_FLOAT))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->total_mem, &m, OPAL_FLOAT))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->free_mem, &m, OPAL_FLOAT))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->buffers, &m, OPAL_FLOAT))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->cached, &m, OPAL_FLOAT))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->swap_cached, &m, OPAL_FLOAT))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->swap_total, &m, OPAL_FLOAT))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->swap_free, &m, OPAL_FLOAT))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_float(buffer, &ptr[i]->mapped, &m, OPAL_FLOAT))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
m=1;
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->sample_time, &m, OPAL_TIMEVAL))) {
|
||||
OPAL_ERROR_LOG(ret);
|
||||
return ret;
|
||||
}
|
||||
ptr[i]->sample_time.tv_sec = tmp1;
|
||||
ptr[i]->sample_time.tv_usec = tmp2;
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
@ -769,6 +792,16 @@ int opal_dss_unpack_value(opal_buffer_t *buffer, void *dest,
|
||||
ptr[i]->data.bo.bytes = NULL;
|
||||
}
|
||||
break;
|
||||
case OPAL_FLOAT:
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.fval, &m, OPAL_FLOAT))) {
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
case OPAL_TIMEVAL:
|
||||
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.tv, &m, OPAL_TIMEVAL))) {
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
opal_output(0, "PACK-OPAL-VALUE: UNSUPPORTED TYPE");
|
||||
return OPAL_ERROR;
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user