From 1f096643a800af2f70e4bc809f7b6d606abc3b8d Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Fri, 6 Jun 2008 21:26:46 +0000
Subject: [PATCH] fixed printing

---
 src/common/slurm_protocol_api.c |  4 ++--
 src/sacct/options.c             |  5 -----
 src/sacct/print.c               | 16 ++++++++--------
 src/sstat/print.c               | 16 ++++++++--------
 src/sstat/sstat.c               |  5 -----
 5 files changed, 18 insertions(+), 28 deletions(-)

diff --git a/src/common/slurm_protocol_api.c b/src/common/slurm_protocol_api.c
index e4dbf4996e2..42473f16649 100644
--- a/src/common/slurm_protocol_api.c
+++ b/src/common/slurm_protocol_api.c
@@ -2829,8 +2829,8 @@ extern void convert_num_unit(float num, char *buf, int buf_size, int orig_type)
 {
 	char *unit = "\0KMGP?";
 	int i = (int)num % 512;
-	
-	if(i > 0 || (int)num == 0) {
+
+	if((i > 0 && num < 1024) || (int)num == 0) {
 		snprintf(buf, buf_size, "%d%c", (int)num, unit[orig_type]);
 		return;
 	}
diff --git a/src/sacct/options.c b/src/sacct/options.c
index 76d8f8c60a3..c1f56487f46 100644
--- a/src/sacct/options.c
+++ b/src/sacct/options.c
@@ -307,11 +307,6 @@ int get_data(void)
 			/* now aggregate the aggregatable */
 			job->alloc_cpus = MAX(job->alloc_cpus, step->ncpus);
 
-			step->sacct.ave_rss *= 1024;
-			step->sacct.max_rss *= 1024;
-			step->sacct.ave_vsize *= 1024;
-			step->sacct.max_vsize *= 1024;
-
 			if(step->state < JOB_COMPLETE)
 				continue;
 			job->tot_cpu_sec += step->tot_cpu_sec;
diff --git a/src/sacct/print.c b/src/sacct/print.c
index 61a70f8e4f8..91c1231b18a 100644
--- a/src/sacct/print.c
+++ b/src/sacct/print.c
@@ -617,13 +617,13 @@ void print_rss(type_t type, void *object)
 		nodes = job->nodes;
 		pos = sacct.min_cpu_id.nodeid;				 
 		convert_num_unit((float)sacct.max_rss, buf1, sizeof(buf1),
-				 UNIT_NONE);
+				 UNIT_KILO);
 
 		if(job->track_steps)
 			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/- - -", buf1);
 		else {
 			convert_num_unit((float)sacct.ave_rss, 
-					 buf2, sizeof(buf2), UNIT_NONE);
+					 buf2, sizeof(buf2), UNIT_KILO);
 			find_hostname(pos, nodes, buf3);
 			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
 				 buf1,
@@ -638,9 +638,9 @@ void print_rss(type_t type, void *object)
 		nodes = step->nodes;
 		pos = sacct.min_cpu_id.nodeid;				 
 		convert_num_unit((float)sacct.max_rss, buf1, sizeof(buf1),
-				 UNIT_NONE);
+				 UNIT_KILO);
 		convert_num_unit((float)sacct.ave_rss, buf2, sizeof(buf2),
-				 UNIT_NONE);
+				 UNIT_KILO);
 		find_hostname(pos, nodes, buf3);
 		snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
 			 buf1,
@@ -970,12 +970,12 @@ void print_vsize(type_t type, void *object)
 		nodes = job->nodes;
 		pos = sacct.min_cpu_id.nodeid;				 
 		convert_num_unit((float)sacct.max_vsize, 
-				 buf1, sizeof(buf1),UNIT_NONE);
+				 buf1, sizeof(buf1), UNIT_KILO);
 		if(job->track_steps)
 			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/- - -", buf1);
 		else {
 			convert_num_unit((float)sacct.ave_vsize,
-					 buf2, sizeof(buf2), UNIT_NONE);
+					 buf2, sizeof(buf2), UNIT_KILO);
 			find_hostname(pos, nodes, buf3);
 			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
 				 buf1,
@@ -990,9 +990,9 @@ void print_vsize(type_t type, void *object)
 		nodes = step->nodes;
 		pos = sacct.min_cpu_id.nodeid;				 
 		convert_num_unit((float)sacct.max_vsize, buf1, sizeof(buf1), 
-				 UNIT_NONE);
+				 UNIT_KILO);
 		convert_num_unit((float)sacct.ave_vsize, buf2, sizeof(buf2),
-				 UNIT_NONE);
+				 UNIT_KILO);
 		find_hostname(pos, nodes, buf3);
 		snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
 			 buf1,
diff --git a/src/sstat/print.c b/src/sstat/print.c
index 0ff252c9d25..8057f4a12a2 100644
--- a/src/sstat/print.c
+++ b/src/sstat/print.c
@@ -298,13 +298,13 @@ extern void print_rss(type_t type, void *object)
 		nodes = job->nodes;
 		pos = sacct.min_cpu_id.nodeid;				 
 		convert_num_unit((float)sacct.max_rss, buf1, sizeof(buf1),
-				 UNIT_NONE);
+				 UNIT_KILO);
 
 		if(job->track_steps)
 			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/- - -", buf1);
 		else {
 			convert_num_unit((float)sacct.ave_rss, 
-					 buf2, sizeof(buf2), UNIT_NONE);
+					 buf2, sizeof(buf2), UNIT_KILO);
 			find_hostname(pos, nodes, buf3);
 			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
 				 buf1,
@@ -319,9 +319,9 @@ extern void print_rss(type_t type, void *object)
 		nodes = step->nodes;
 		pos = sacct.min_cpu_id.nodeid;				 
 		convert_num_unit((float)sacct.max_rss, buf1, sizeof(buf1),
-				 UNIT_NONE);
+				 UNIT_KILO);
 		convert_num_unit((float)sacct.ave_rss, buf2, sizeof(buf2),
-				 UNIT_NONE);
+				 UNIT_KILO);
 		find_hostname(pos, nodes, buf3);
 		snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
 			 buf1,
@@ -400,12 +400,12 @@ extern void print_vsize(type_t type, void *object)
 		nodes = job->nodes;
 		pos = sacct.min_cpu_id.nodeid;				 
 		convert_num_unit((float)sacct.max_vsize, 
-				 buf1, sizeof(buf1),UNIT_NONE);
+				 buf1, sizeof(buf1),UNIT_KILO);
 		if(job->track_steps)
 			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/- - -", buf1);
 		else {
 			convert_num_unit((float)sacct.ave_vsize,
-					 buf2, sizeof(buf2), UNIT_NONE);
+					 buf2, sizeof(buf2), UNIT_KILO);
 			find_hostname(pos, nodes, buf3);
 			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
 				 buf1,
@@ -420,9 +420,9 @@ extern void print_vsize(type_t type, void *object)
 		nodes = step->nodes;
 		pos = sacct.min_cpu_id.nodeid;				 
 		convert_num_unit((float)sacct.max_vsize, buf1, sizeof(buf1), 
-				 UNIT_NONE);
+				 UNIT_KILO);
 		convert_num_unit((float)sacct.ave_vsize, buf2, sizeof(buf2),
-				 UNIT_NONE);
+				 UNIT_KILO);
 		find_hostname(pos, nodes, buf3);
 		snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
 			 buf1,
diff --git a/src/sstat/sstat.c b/src/sstat/sstat.c
index 58f75d55df9..62f246aebd0 100644
--- a/src/sstat/sstat.c
+++ b/src/sstat/sstat.c
@@ -170,11 +170,6 @@ int _sstat_query(slurm_step_layout_t *step_layout, uint32_t job_id,
 cleanup:
 	
 	if(tot_tasks) {
-		step.sacct.ave_rss *= 1024;
-		step.sacct.max_rss *= 1024;
-		step.sacct.ave_vsize *= 1024;
-		step.sacct.max_vsize *= 1024;
-
 		step.sacct.ave_cpu /= tot_tasks;
 		step.sacct.ave_cpu /= 100;
 		step.sacct.min_cpu /= 100;
-- 
GitLab