diff --git a/src/api/block_info.c b/src/api/block_info.c index e6b414c11d7620fa87c753973f3ca64e94cf8f81..84b2e4f8ce7cc5d6df512d12a6fe5380a254680d 100644 --- a/src/api/block_info.c +++ b/src/api/block_info.c @@ -125,10 +125,11 @@ char *slurm_sprint_block_info( /****** Line 1 ******/ convert_num_unit((float)block_ptr->cnode_cnt, tmp1, sizeof(tmp1), - UNIT_NONE); + UNIT_NONE, CONVERT_NUM_UNIT_EXACT); if (cluster_flags & CLUSTER_FLAG_BGQ) { convert_num_unit((float)block_ptr->cnode_err_cnt, tmp2, - sizeof(tmp2), UNIT_NONE); + sizeof(tmp2), UNIT_NONE, + CONVERT_NUM_UNIT_EXACT); tmp_char = xstrdup_printf("%s/%s", tmp1, tmp2); } else tmp_char = tmp1; diff --git a/src/api/job_info.c b/src/api/job_info.c index e1d918157a8e7e94e4e0c88b75b378bc67df368e..6a64b639bcbaa22cc01e220ddc35428cf21e0a79 100644 --- a/src/api/job_info.c +++ b/src/api/job_info.c @@ -284,7 +284,8 @@ static void _sprint_range(char *str, uint32_t str_size, uint32_t cluster_flags = slurmdb_setup_cluster_flags(); if (cluster_flags & CLUSTER_FLAG_BG) { - convert_num_unit((float)lower, tmp, sizeof(tmp), UNIT_NONE); + convert_num_unit((float)lower, tmp, sizeof(tmp), UNIT_NONE, + CONVERT_NUM_UNIT_EXACT); } else { snprintf(tmp, sizeof(tmp), "%u", lower); } @@ -292,7 +293,8 @@ static void _sprint_range(char *str, uint32_t str_size, char tmp2[128]; if (cluster_flags & CLUSTER_FLAG_BG) { convert_num_unit((float)upper, tmp2, - sizeof(tmp2), UNIT_NONE); + sizeof(tmp2), UNIT_NONE, + CONVERT_NUM_UNIT_EXACT); } else { snprintf(tmp2, sizeof(tmp2), "%u", upper); } @@ -912,7 +914,8 @@ line15: if (cluster_flags & CLUSTER_FLAG_BG) { convert_num_unit((float)job_ptr->pn_min_cpus, - tmp1, sizeof(tmp1), UNIT_NONE); + tmp1, sizeof(tmp1), UNIT_NONE, + CONVERT_NUM_UNIT_EXACT); snprintf(tmp_line, sizeof(tmp_line), "MinCPUsNode=%s", tmp1); } else { snprintf(tmp_line, sizeof(tmp_line), "MinCPUsNode=%u", @@ -921,9 +924,9 @@ line15: xstrcat(out, tmp_line); convert_num_unit((float)job_ptr->pn_min_memory, tmp1, sizeof(tmp1), - UNIT_MEGA); + UNIT_MEGA, CONVERT_NUM_UNIT_EXACT); convert_num_unit((float)job_ptr->pn_min_tmp_disk, tmp2, sizeof(tmp2), - UNIT_MEGA); + UNIT_MEGA, CONVERT_NUM_UNIT_EXACT); snprintf(tmp_line, sizeof(tmp_line), " MinMemory%s=%s MinTmpDiskNode=%s", tmp6_ptr, tmp1, tmp2); diff --git a/src/api/job_step_info.c b/src/api/job_step_info.c index 119e83d0532c29d016f338d2a2880cfadda2574d..f8f769a7798c11c0da33fa7c8844b61f33aba784 100644 --- a/src/api/job_step_info.c +++ b/src/api/job_step_info.c @@ -237,11 +237,12 @@ slurm_sprint_job_step_info ( job_step_info_t * job_step_ptr, SELECT_JOBDATA_NODE_CNT, &nodes); convert_num_unit((float)nodes, tmp_node_cnt, - sizeof(tmp_node_cnt), UNIT_NONE); + sizeof(tmp_node_cnt), UNIT_NONE, + CONVERT_NUM_UNIT_EXACT); } else { convert_num_unit((float)_nodes_in_list(job_step_ptr->nodes), tmp_node_cnt, sizeof(tmp_node_cnt), - UNIT_NONE); + UNIT_NONE, CONVERT_NUM_UNIT_EXACT); } snprintf(tmp_line, sizeof(tmp_line), diff --git a/src/api/partition_info.c b/src/api/partition_info.c index 9e88739e140835b8d29fae741d083d34f3f1d2f8..92260b06d841fc172b0d4b1c6b04bcd96a1912e6 100644 --- a/src/api/partition_info.c +++ b/src/api/partition_info.c @@ -256,7 +256,8 @@ char *slurm_sprint_partition_info ( partition_info_t * part_ptr, else { if (cluster_flags & CLUSTER_FLAG_BG) convert_num_unit((float)part_ptr->max_nodes, - tmp1, sizeof(tmp1), UNIT_NONE); + tmp1, sizeof(tmp1), UNIT_NONE, + CONVERT_NUM_UNIT_EXACT); else snprintf(tmp1, sizeof(tmp1),"%u", part_ptr->max_nodes); @@ -274,7 +275,8 @@ char *slurm_sprint_partition_info ( partition_info_t * part_ptr, xstrcat(out, tmp_line); if (cluster_flags & CLUSTER_FLAG_BG) convert_num_unit((float)part_ptr->min_nodes, tmp1, sizeof(tmp1), - UNIT_NONE); + UNIT_NONE, + CONVERT_NUM_UNIT_EXACT); else snprintf(tmp1, sizeof(tmp1), "%u", part_ptr->min_nodes); sprintf(tmp_line, " MinNodes=%s", tmp1); @@ -366,7 +368,8 @@ char *slurm_sprint_partition_info ( partition_info_t * part_ptr, if (cluster_flags & CLUSTER_FLAG_BG) convert_num_unit((float)part_ptr->total_cpus, tmp1, - sizeof(tmp1), UNIT_NONE); + sizeof(tmp1), UNIT_NONE, + CONVERT_NUM_UNIT_EXACT); else snprintf(tmp1, sizeof(tmp1), "%u", part_ptr->total_cpus); @@ -375,7 +378,8 @@ char *slurm_sprint_partition_info ( partition_info_t * part_ptr, if (cluster_flags & CLUSTER_FLAG_BG) convert_num_unit((float)part_ptr->total_nodes, tmp2, - sizeof(tmp2), UNIT_NONE); + sizeof(tmp2), UNIT_NONE, + CONVERT_NUM_UNIT_EXACT); else snprintf(tmp2, sizeof(tmp2), "%u", part_ptr->total_nodes); diff --git a/src/common/cpu_frequency.c b/src/common/cpu_frequency.c index 8e3905a7012fdcba38fb5c5d2efbcbbc78af0b86..8ff335b8b654b8d4f3c5cdbd16b6a5ec4bb5fbb1 100644 --- a/src/common/cpu_frequency.c +++ b/src/common/cpu_frequency.c @@ -1228,7 +1228,7 @@ cpu_freq_to_string(char *buf, int buf_size, uint32_t cpu_freq) buf[0] = '\0'; } else convert_num_unit2((double)cpu_freq, buf, buf_size, - UNIT_KILO, 1000, false); + UNIT_KILO, 1000, 0); } /* diff --git a/src/common/slurm_protocol_api.c b/src/common/slurm_protocol_api.c index 0620fd98905ae55b038cb1758e6158d4159e9f82..eebaf9e9e3aa8f251d837f53dc4d0efe6f50443f 100644 --- a/src/common/slurm_protocol_api.c +++ b/src/common/slurm_protocol_api.c @@ -4312,7 +4312,7 @@ extern int nodelist_find(const char *nodelist, const char *name) } extern void convert_num_unit2(double num, char *buf, int buf_size, - int orig_type, int divisor, bool exact) + int orig_type, int divisor, uint32_t flags) { char *unit = "\0KMGTP?"; uint64_t i; @@ -4320,7 +4320,7 @@ extern void convert_num_unit2(double num, char *buf, int buf_size, if ((int64_t)num == 0) { snprintf(buf, buf_size, "0"); return; - } else if (exact) { + } else if (flags & CONVERT_NUM_UNIT_EXACT) { i = (uint64_t)num % (divisor / 2); if (i > 0) { @@ -4330,9 +4330,11 @@ extern void convert_num_unit2(double num, char *buf, int buf_size, } } - while (num > divisor) { - num /= divisor; - orig_type++; + if (!(flags & CONVERT_NUM_UNIT_NO)) { + while (num > divisor) { + num /= divisor; + orig_type++; + } } if (orig_type < UNIT_NONE || orig_type > UNIT_PETA) @@ -4348,9 +4350,10 @@ extern void convert_num_unit2(double num, char *buf, int buf_size, snprintf(buf, buf_size, "%.2f%c", num, unit[orig_type]); } -extern void convert_num_unit(double num, char *buf, int buf_size, int orig_type) +extern void convert_num_unit(double num, char *buf, int buf_size, + int orig_type, uint32_t flags) { - convert_num_unit2(num, buf, buf_size, orig_type, 1024, true); + convert_num_unit2(num, buf, buf_size, orig_type, 1024, flags); } extern int revert_num_unit(const char *buf) diff --git a/src/common/slurm_protocol_api.h b/src/common/slurm_protocol_api.h index b8f1cd6da16133171984b00b2ef83569acf54238..9999c770b3077efb205b15955fe6c8146ccdcc53 100644 --- a/src/common/slurm_protocol_api.h +++ b/src/common/slurm_protocol_api.h @@ -69,6 +69,9 @@ #define MIN_NOALLOC_JOBID ((uint32_t) 0xffff0000) #define MAX_NOALLOC_JOBID ((uint32_t) 0xfffffffd) +#define CONVERT_NUM_UNIT_EXACT 0x00000001 +#define CONVERT_NUM_UNIT_NO 0x00000002 + enum controller_id { PRIMARY_CONTROLLER = 1, SECONDARY_CONTROLLER = 2 @@ -1210,9 +1213,9 @@ extern void slurm_free_msg(slurm_msg_t * msg); extern char *nodelist_nth_host(const char *nodelist, int inx); extern int nodelist_find(const char *nodelist, const char *name); extern void convert_num_unit2(double num, char *buf, int buf_size, - int orig_type, int divisor, bool exact); + int orig_type, int divisor, uint32_t flags); extern void convert_num_unit(double num, char *buf, int buf_size, - int orig_type); + int orig_type, uint32_t flags); extern int revert_num_unit(const char *buf); extern void parse_int_to_array(int in, int *out); diff --git a/src/plugins/select/bluegene/bg_job_place.c b/src/plugins/select/bluegene/bg_job_place.c index 9c43502d45649c54a14fc8e960a63311572bee7a..7745cb6f580d08481d88e0b473b178846efd8fe4 100644 --- a/src/plugins/select/bluegene/bg_job_place.c +++ b/src/plugins/select/bluegene/bg_job_place.c @@ -479,7 +479,8 @@ static bg_record_t *_find_matching_block(List block_list, convert_num_unit( (float)bg_record->cpu_cnt, tmp_char, - sizeof(tmp_char), UNIT_NONE); + sizeof(tmp_char), UNIT_NONE, + CONVERT_NUM_UNIT_EXACT); info("block %s CPU count (%u) " "not suitable, asking for %u-%u", bg_record->bg_block_id, diff --git a/src/sacct/options.c b/src/sacct/options.c index 765bae7fdda76fe559fdfdf92b45f6548b5ff13d..d4c88da07b403c0e7045664269c4af5b58f7d8ce 100644 --- a/src/sacct/options.c +++ b/src/sacct/options.c @@ -545,6 +545,8 @@ void parse_command_line(int argc, char **argv) params.opt_uid = getuid(); params.opt_gid = getgid(); + params.convert_flags = CONVERT_NUM_UNIT_EXACT; + verbosity = 0; log_init("sacct", opts, SYSLOG_FACILITY_DAEMON, NULL); opterr = 1; /* Let getopt report problems to the user */ @@ -666,7 +668,7 @@ void parse_command_line(int argc, char **argv) long_output = true; break; case OPT_LONG_NOCONVERT: - params.no_convert = true; + params.convert_flags |= CONVERT_NUM_UNIT_NO; break; case 'n': print_fields_have_header = 0; diff --git a/src/sacct/print.c b/src/sacct/print.c index 7264ba0e65bbc3cab82d553b7e0cde2378030933..a359d541378a475ec886a8edaae9b6916ea5fc9c 100644 --- a/src/sacct/print.c +++ b/src/sacct/print.c @@ -105,36 +105,6 @@ static char *_find_qos_name_from_list( return "Unknown"; } -static void _print_num_unit(double num, char *buf, int buf_size, int orig_type) -{ - char *unit = "\0KMGTP?"; - uint64_t i = (uint64_t)num; - - if ((double)i == num) - snprintf(buf, buf_size, "%"PRIu64"%c", i, unit[orig_type]); - else - snprintf(buf, buf_size, "%.2f%c", num, unit[orig_type]); -} - -static void _local_convert_num_unit(double num, char *buf, int buf_size, - int orig_type) -{ - if (params.no_convert) { - _print_num_unit(num, buf, buf_size, orig_type); - } else - convert_num_unit2(num, buf, buf_size, orig_type, 1024, true); -} - - -static void _local_convert_num_unit2(double num, char *buf, int buf_size, - int orig_type, int divisor, bool exact) -{ - if (params.no_convert) { - _print_num_unit(num, buf, buf_size, orig_type); - } else - convert_num_unit2(num, buf, buf_size, orig_type, divisor, exact); -} - static void _print_small_double( char *outbuf, int buf_size, double dub, int units) { @@ -142,7 +112,8 @@ static void _print_small_double( return; if (dub > 1) - _local_convert_num_unit((double)dub, outbuf, buf_size, units); + convert_num_unit((double)dub, outbuf, buf_size, units, + params.convert_flags); else if (dub > 0) snprintf(outbuf, buf_size, "%.2fM", dub); else @@ -376,10 +347,11 @@ void print_fields(type_t type, void *object) } } if (!fuzzy_equal(tmp_dub, NO_VAL)) - _local_convert_num_unit2((double)tmp_dub, - outbuf, sizeof(outbuf), - UNIT_KILO, 1000, - false); + convert_num_unit2((double)tmp_dub, + outbuf, sizeof(outbuf), + UNIT_KILO, 1000, + params.convert_flags & + (~CONVERT_NUM_UNIT_EXACT)); field->print_routine(field, outbuf, @@ -488,9 +460,10 @@ void print_fields(type_t type, void *object) } } if (!fuzzy_equal(tmp_dub, NO_VAL)) - _local_convert_num_unit((double)tmp_dub, outbuf, - sizeof(outbuf), - UNIT_KILO); + convert_num_unit((double)tmp_dub, outbuf, + sizeof(outbuf), + UNIT_KILO, + params.convert_flags); field->print_routine(field, outbuf, @@ -512,9 +485,10 @@ void print_fields(type_t type, void *object) } } if (!fuzzy_equal(tmp_dub, NO_VAL)) - _local_convert_num_unit((double)tmp_dub, outbuf, - sizeof(outbuf), - UNIT_KILO); + convert_num_unit((double)tmp_dub, outbuf, + sizeof(outbuf), + UNIT_KILO, + params.convert_flags); field->print_routine(field, outbuf, @@ -537,9 +511,10 @@ void print_fields(type_t type, void *object) } if (!fuzzy_equal(tmp_dub, NO_VAL)) - _local_convert_num_unit((double)tmp_dub, outbuf, - sizeof(outbuf), - UNIT_KILO); + convert_num_unit((double)tmp_dub, outbuf, + sizeof(outbuf), + UNIT_KILO, + params.convert_flags); field->print_routine(field, outbuf, @@ -609,10 +584,11 @@ void print_fields(type_t type, void *object) } } if (!fuzzy_equal(tmp_dub, NO_VAL)) - _local_convert_num_unit2((double)tmp_dub, - outbuf, sizeof(outbuf), - UNIT_NONE, 1000, - false); + convert_num_unit2((double)tmp_dub, + outbuf, sizeof(outbuf), + UNIT_NONE, 1000, + params.convert_flags & + (~CONVERT_NUM_UNIT_EXACT)); field->print_routine(field, outbuf, @@ -1117,10 +1093,11 @@ void print_fields(type_t type, void *object) break; } if (tmp_uint64 != (uint64_t)NO_VAL) - _local_convert_num_unit( - (double)tmp_uint64, - outbuf, sizeof(outbuf), - UNIT_KILO); + convert_num_unit( + (double)tmp_uint64, + outbuf, sizeof(outbuf), + UNIT_KILO, + params.convert_flags); } field->print_routine(field, @@ -1194,10 +1171,11 @@ void print_fields(type_t type, void *object) break; } if (tmp_uint64 != (uint64_t)NO_VAL) - _local_convert_num_unit( - (double)tmp_uint64, - outbuf, sizeof(outbuf), - UNIT_KILO); + convert_num_unit( + (double)tmp_uint64, + outbuf, sizeof(outbuf), + UNIT_KILO, + params.convert_flags); } field->print_routine(field, @@ -1273,10 +1251,11 @@ void print_fields(type_t type, void *object) } if (tmp_uint64 != (uint64_t)NO_VAL) - _local_convert_num_unit( - (double)tmp_uint64, - outbuf, sizeof(outbuf), - UNIT_KILO); + convert_num_unit( + (double)tmp_uint64, + outbuf, sizeof(outbuf), + UNIT_KILO, + params.convert_flags); } field->print_routine(field, @@ -1452,8 +1431,9 @@ void print_fields(type_t type, void *object) tmp_int = hostlist_count(hl); hostlist_destroy(hl); } - _local_convert_num_unit((double)tmp_int, outbuf, - sizeof(outbuf), UNIT_NONE); + convert_num_unit((double)tmp_int, outbuf, + sizeof(outbuf), UNIT_NONE, + params.convert_flags); field->print_routine(field, outbuf, (curr_inx == field_count)); @@ -1678,9 +1658,10 @@ void print_fields(type_t type, void *object) tmp_uint32 &= (~MEM_PER_CPU); per_cpu = true; } - _local_convert_num_unit((double)tmp_uint32, - outbuf, sizeof(outbuf), - UNIT_MEGA); + convert_num_unit((double)tmp_uint32, + outbuf, sizeof(outbuf), + UNIT_MEGA, + params.convert_flags); if (per_cpu) sprintf(outbuf+strlen(outbuf), "c"); else @@ -1710,8 +1691,8 @@ void print_fields(type_t type, void *object) break; } field->print_routine(field, - tmp_char, - (curr_inx == field_count)); + tmp_char, + (curr_inx == field_count)); break; case PRINT_RESERVATION_ID: switch(type) { @@ -1734,8 +1715,8 @@ void print_fields(type_t type, void *object) if (tmp_uint32 == (uint32_t)NO_VAL) tmp_uint32 = NO_VAL; field->print_routine(field, - tmp_uint32, - (curr_inx == field_count)); + tmp_uint32, + (curr_inx == field_count)); break; case PRINT_RESV: switch(type) { diff --git a/src/sacct/sacct.h b/src/sacct/sacct.h index 282f06acf861504e8b6d2ff023346a004b48670f..5bc804d5a18a6fd4274214b66dbdeb33fef7926a 100644 --- a/src/sacct/sacct.h +++ b/src/sacct/sacct.h @@ -174,6 +174,7 @@ typedef enum { } sacct_print_types_t; typedef struct { + uint32_t convert_flags; slurmdb_job_cond_t *job_cond; int opt_completion; /* --completion */ int opt_dup; /* --duplicates; +1 = explicitly set */ @@ -184,7 +185,6 @@ typedef struct { int opt_noheader; /* can only be cleared */ int opt_allocs; /* --total */ int opt_uid; /* running persons uid */ - bool no_convert; /* don't convert units from original types */ } sacct_parameters_t; extern print_field_t fields[]; diff --git a/src/sinfo/opts.c b/src/sinfo/opts.c index 983be3793efda3778f5bba83520a1d03f6ec1bbb..1af0adc14e297ba64d286ee50b3ed5a8c805e721 100644 --- a/src/sinfo/opts.c +++ b/src/sinfo/opts.c @@ -65,6 +65,7 @@ #define OPT_LONG_HELP 0x100 #define OPT_LONG_USAGE 0x101 #define OPT_LONG_HIDE 0x102 +#define OPT_LONG_NOCONVERT 0x104 /* FUNCTIONS */ static List _build_state_list( char* str ); @@ -107,6 +108,7 @@ extern void parse_command_line(int argc, char *argv[]) {"cluster", required_argument, 0, 'M'}, {"clusters", required_argument, 0, 'M'}, {"nodes", required_argument, 0, 'n'}, + {"noconvert", no_argument, 0, OPT_LONG_NOCONVERT}, {"Node", no_argument, 0, 'N'}, {"format", required_argument, 0, 'o'}, {"Format", required_argument, 0, 'O'}, @@ -125,6 +127,8 @@ extern void parse_command_line(int argc, char *argv[]) {NULL, 0, 0, 0} }; + params.convert_flags = CONVERT_NUM_UNIT_EXACT; + if (getenv("SINFO_ALL")) { env_a_set = true; params.all_flag = true; @@ -206,6 +210,9 @@ extern void parse_command_line(int argc, char *argv[]) } working_cluster_rec = list_peek(params.clusters); break; + case OPT_LONG_NOCONVERT: + params.convert_flags |= CONVERT_NUM_UNIT_NO; + break; case (int) 'n': xfree(params.nodes); params.nodes = xstrdup(optarg); @@ -1278,6 +1285,8 @@ Usage: sinfo [OPTIONS]\n\ -b, --bg show bgblocks (on Blue Gene systems)\n\ -d, --dead show only non-responding nodes\n\ -e, --exact group nodes only on exact match of configuration\n\ + --noconvert Fields such as MaxRSS, ReqMem and others will\n\ + not be converted from their orignal unit types.\n\ -h, --noheader no headers on output\n\ --hide do not show hidden or non-accessible partitions\n\ -i, --iterate=seconds specify an iteration period\n\ diff --git a/src/sinfo/print.c b/src/sinfo/print.c index fa04c40a7788048930cca41d3f9800f41725cd38..da3c8c86bd060ea264ca220e697e7f5edc965fef 100644 --- a/src/sinfo/print.c +++ b/src/sinfo/print.c @@ -242,8 +242,10 @@ _build_min_max_16_string(char *buffer, int buf_size, uint16_t min, uint16_t max, { char tmp_min[8]; char tmp_max[8]; - convert_num_unit((float)min, tmp_min, sizeof(tmp_min), UNIT_NONE); - convert_num_unit((float)max, tmp_max, sizeof(tmp_max), UNIT_NONE); + convert_num_unit((float)min, tmp_min, sizeof(tmp_min), UNIT_NONE, + params.convert_flags); + convert_num_unit((float)max, tmp_max, sizeof(tmp_max), UNIT_NONE, + params.convert_flags); if (max == min) return snprintf(buffer, buf_size, "%s", tmp_max); @@ -268,9 +270,9 @@ _build_min_max_32_string(char *buffer, int buf_size, if (use_suffix) { convert_num_unit((float)min, tmp_min, sizeof(tmp_min), - UNIT_NONE); + UNIT_NONE, params.convert_flags); convert_num_unit((float)max, tmp_max, sizeof(tmp_max), - UNIT_NONE); + UNIT_NONE, params.convert_flags); } else { snprintf(tmp_min, sizeof(tmp_min), "%u", min); snprintf(tmp_max, sizeof(tmp_max), "%u", max); @@ -476,13 +478,17 @@ int _print_cpus_aiot(sinfo_data_t * sinfo_data, int width, if (sinfo_data) { if (params.cluster_flags & CLUSTER_FLAG_BG) { convert_num_unit((float)sinfo_data->cpus_alloc, - tmpa, sizeof(tmpa), UNIT_NONE); + tmpa, sizeof(tmpa), UNIT_NONE, + params.convert_flags); convert_num_unit((float)sinfo_data->cpus_idle, - tmpi, sizeof(tmpi), UNIT_NONE); + tmpi, sizeof(tmpi), UNIT_NONE, + params.convert_flags); convert_num_unit((float)sinfo_data->cpus_other, - tmpo, sizeof(tmpo), UNIT_NONE); + tmpo, sizeof(tmpo), UNIT_NONE, + params.convert_flags); convert_num_unit((float)sinfo_data->cpus_total, - tmpt, sizeof(tmpt), UNIT_NONE); + tmpt, sizeof(tmpt), UNIT_NONE, + params.convert_flags); } else { snprintf(tmpa, sizeof(tmpa), "%u", sinfo_data->cpus_alloc); @@ -764,7 +770,8 @@ int _print_nodes_t(sinfo_data_t * sinfo_data, int width, if (sinfo_data) { if (params.cluster_flags & CLUSTER_FLAG_BG) convert_num_unit((float)sinfo_data->nodes_total, - tmp, sizeof(tmp), UNIT_NONE); + tmp, sizeof(tmp), UNIT_NONE, + params.convert_flags); else snprintf(tmp, sizeof(tmp), "%d", sinfo_data->nodes_total); @@ -787,9 +794,11 @@ int _print_nodes_ai(sinfo_data_t * sinfo_data, int width, if (sinfo_data) { if (params.cluster_flags & CLUSTER_FLAG_BG) { convert_num_unit((float)sinfo_data->nodes_alloc, - tmpa, sizeof(tmpa), UNIT_NONE); + tmpa, sizeof(tmpa), UNIT_NONE, + params.convert_flags); convert_num_unit((float)sinfo_data->nodes_idle, - tmpi, sizeof(tmpi), UNIT_NONE); + tmpi, sizeof(tmpi), UNIT_NONE, + params.convert_flags); } else { snprintf(tmpa, sizeof(tmpa), "%d", sinfo_data->nodes_alloc); @@ -818,13 +827,17 @@ int _print_nodes_aiot(sinfo_data_t * sinfo_data, int width, if (sinfo_data) { if (params.cluster_flags & CLUSTER_FLAG_BG) { convert_num_unit((float)sinfo_data->nodes_alloc, - tmpa, sizeof(tmpa), UNIT_NONE); + tmpa, sizeof(tmpa), UNIT_NONE, + params.convert_flags); convert_num_unit((float)sinfo_data->nodes_idle, - tmpi, sizeof(tmpi), UNIT_NONE); + tmpi, sizeof(tmpi), UNIT_NONE, + params.convert_flags); convert_num_unit((float)sinfo_data->nodes_other, - tmpo, sizeof(tmpo), UNIT_NONE); + tmpo, sizeof(tmpo), UNIT_NONE, + params.convert_flags); convert_num_unit((float)sinfo_data->nodes_total, - tmpt, sizeof(tmpt), UNIT_NONE); + tmpt, sizeof(tmpt), UNIT_NONE, + params.convert_flags); } else { snprintf(tmpa, sizeof(tmpa), "%u", sinfo_data->nodes_alloc); diff --git a/src/sinfo/sinfo.h b/src/sinfo/sinfo.h index c7af063a352ceb21654dc6b229071b30174cac61..5652fe1eaf913a9b55d4d11bf5c04f20b3d46067 100644 --- a/src/sinfo/sinfo.h +++ b/src/sinfo/sinfo.h @@ -165,6 +165,7 @@ struct sinfo_parameters { bool all_flag; List clusters; uint32_t cluster_flags; + uint32_t convert_flags; bool bg_flag; bool dead_nodes; bool exact_match; diff --git a/src/smap/job_functions.c b/src/smap/job_functions.c index ae9a2160ede38fcc455129176cb308d001bf6049..d78606c744c084915f3e91fe0a2618a7b13f9894 100644 --- a/src/smap/job_functions.c +++ b/src/smap/job_functions.c @@ -309,7 +309,8 @@ static int _print_text_job(job_info_t * job_ptr) if (params.cluster_flags & CLUSTER_FLAG_BG) convert_num_unit((float)node_cnt, tmp_cnt, - sizeof(tmp_cnt), UNIT_NONE); + sizeof(tmp_cnt), UNIT_NONE, + CONVERT_NUM_UNIT_EXACT); else snprintf(tmp_cnt, sizeof(tmp_cnt), "%d", node_cnt); diff --git a/src/smap/partition_functions.c b/src/smap/partition_functions.c index e1b557c9360d5c12c8b6667559dad69819d795bc..5cd16e04412bc4797deed66a9781d079a0e03522 100644 --- a/src/smap/partition_functions.c +++ b/src/smap/partition_functions.c @@ -557,7 +557,8 @@ static int _print_text_part(partition_info_t *part_ptr, if (params.cluster_flags & CLUSTER_FLAG_BG) convert_num_unit((float)part_ptr->total_nodes, tmp_cnt, - sizeof(tmp_cnt), UNIT_NONE); + sizeof(tmp_cnt), UNIT_NONE, + CONVERT_NUM_UNIT_EXACT); else snprintf(tmp_cnt, sizeof(tmp_cnt), "%u", part_ptr->total_nodes);