Repository: systemml Updated Branches: refs/heads/master ac1cf093a -> b70608328
[SYSTEMML-1796] Improved formatting of fine-grained statistics for SystemML - The user can update systemml.stats.maxWrapLength configuration to change the maximum wrap length of instruction and misc timers - Here are some examples: ``` Heavy hitter instructions: # Instruction Time(s) Count Misc Timers 1 write [PCA.dml 110:8-110:14] 7.740 1 2 eigen [PCA.dml 85:1-85:1] 7.191 1 rlswr[0.000s,2], rlsev[0.000s,0], a qmd[0.001s,2] 3 write [92:12-92:25] 0.686 1 4 ba+* [PCA.dml 110:8-110:14] 0.511 1 rlswr[0.000s,1], rlsev[0.000s,0], a qmd[0.000s,1], aqrd[0.000s,2], rlsi [0.000s,2] 5 tsmm [PCA.dml 81:5-81:16] 0.372 1 rlswr[0.000s,1], rlsev[0.000s,0], r lsi[0.000s,1], aqrd[0.000s,1], aqmd [0.000s,1] 6 uacmean [PCA.dml 66:5-66:5] 0.361 1 rlswr[0.000s,1], rlsev[0.000s,0], a qmd[0.000s,1], rlsi[0.000s,1], aqrd [0.204s,1] 7 ba+* [92:12-92:25] 0.155 1 rlswr[0.000s,1], aqmd[0.000s,1], aq rs[0.000s,1], aqrd[0.000s,1], rlsev [0.000s,0], rlsi[0.000s,2] Heavy hitter instructions: # Instruction Time(s) Count Misc Timers 1 write [PCA 7.751 1 .dml 110:8 -110:14] 2 eigen [PCA 7.031 1 rlswr[0.00 .dml 85:1- 0s,2], rls 85:1] ev[0.000s, 0], aqmd[0 .000s,2] 3 write [92: 0.687 1 12-92:25] 4 ba+* [PCA. 0.527 1 rlswr[0.00 dml 110:8- 0s,1], aqm 110:14] d[0.000s,1 ], aqrd[0. 000s,2], r lsev[0.000 s,0], rlsi [0.001s,2] 5 tsmm [PCA. 0.401 1 rlswr[0.00 dml 81:5-8 0s,1], rls 1:16] ev[0.000s, 0], rlsi[0 .000s,1], aqrd[0.000 s,1], aqmd [0.000s,1] Heavy hitter instructions: # Instruction Time(s) Count 1 write 8.371 4 2 eigen 7.239 1 3 ba+* 0.663 3 4 tsmm 0.340 2 5 uacmean 0.309 2 6 uacsqk+ 0.146 1 7 / 0.107 5 8 - 0.067 3 9 uack+ 0.043 1 10 -* 0.025 2 11 ctableexpa 0.007 1 nd ``` Closes #593. Project: http://git-wip-us.apache.org/repos/asf/systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/b7060832 Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/b7060832 Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/b7060832 Branch: refs/heads/master Commit: b706083282e75203d57c72ef138a284078fd33b2 Parents: ac1cf09 Author: Niketan Pansare <npan...@us.ibm.com> Authored: Thu Aug 3 09:10:37 2017 -0800 Committer: Niketan Pansare <npan...@us.ibm.com> Committed: Thu Aug 3 10:10:37 2017 -0700 ---------------------------------------------------------------------- conf/SystemML-config.xml.template | 3 ++ .../java/org/apache/sysml/api/DMLScript.java | 3 +- .../apache/sysml/api/ScriptExecutorUtils.java | 1 + .../java/org/apache/sysml/conf/DMLConfig.java | 4 +- .../java/org/apache/sysml/utils/Statistics.java | 46 ++++++++++++++++---- 5 files changed, 46 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/systemml/blob/b7060832/conf/SystemML-config.xml.template ---------------------------------------------------------------------- diff --git a/conf/SystemML-config.xml.template b/conf/SystemML-config.xml.template index 8608a9c..86bacda 100644 --- a/conf/SystemML-config.xml.template +++ b/conf/SystemML-config.xml.template @@ -80,4 +80,7 @@ <!-- sets the GPUs to use per process, -1 for all GPUs, a specific GPU number (5), a range (eg: 0-2) or a comma separated list (eg: 0,2,4)--> <systemml.gpu.availableGPUs>-1</systemml.gpu.availableGPUs> + + <!-- maximum wrap length for instruction and miscellaneous timer column of statistics --> + <systemml.stats.maxWrapLength>30</systemml.stats.maxWrapLength> </root> http://git-wip-us.apache.org/repos/asf/systemml/blob/b7060832/src/main/java/org/apache/sysml/api/DMLScript.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/api/DMLScript.java b/src/main/java/org/apache/sysml/api/DMLScript.java index 9cb5ebe..eef6990 100644 --- a/src/main/java/org/apache/sysml/api/DMLScript.java +++ b/src/main/java/org/apache/sysml/api/DMLScript.java @@ -158,8 +158,9 @@ public class DMLScript public static RUNTIME_PLATFORM rtplatform = DMLOptions.defaultOptions.execMode; // the execution mode public static boolean STATISTICS = DMLOptions.defaultOptions.stats; // whether to print statistics - public static boolean FINEGRAINED_STATISTICS = DMLOptions.defaultOptions.stats; // whether to print statistics + public static boolean FINEGRAINED_STATISTICS = false; // whether to print fine-grained statistics public static int STATISTICS_COUNT = DMLOptions.defaultOptions.statsCount; // statistics maximum heavy hitter count + public static int STATISTICS_MAX_WRAP_LEN = 30; // statistics maximum wrap length public static boolean ENABLE_DEBUG_MODE = DMLOptions.defaultOptions.debug; // debug mode public static ExplainType EXPLAIN = DMLOptions.defaultOptions.explainType; // explain type public static String DML_FILE_PATH_ANTLR_PARSER = DMLOptions.defaultOptions.filePath; // filename of dml/pydml script http://git-wip-us.apache.org/repos/asf/systemml/blob/b7060832/src/main/java/org/apache/sysml/api/ScriptExecutorUtils.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/api/ScriptExecutorUtils.java b/src/main/java/org/apache/sysml/api/ScriptExecutorUtils.java index 389f661..5f9c0a2 100644 --- a/src/main/java/org/apache/sysml/api/ScriptExecutorUtils.java +++ b/src/main/java/org/apache/sysml/api/ScriptExecutorUtils.java @@ -78,6 +78,7 @@ public class ScriptExecutorUtils { GPUStatistics.DISPLAY_STATISTICS = dmlconf.getBooleanValue(DMLConfig.EXTRA_GPU_STATS); LibMatrixDNN.DISPLAY_STATISTICS = dmlconf.getBooleanValue(DMLConfig.EXTRA_DNN_STATS); DMLScript.FINEGRAINED_STATISTICS = dmlconf.getBooleanValue(DMLConfig.EXTRA_FINEGRAINED_STATS); + DMLScript.STATISTICS_MAX_WRAP_LEN = dmlconf.getIntValue(DMLConfig.STATS_MAX_WRAP_LEN); Statistics.startRunTimer(); try { http://git-wip-us.apache.org/repos/asf/systemml/blob/b7060832/src/main/java/org/apache/sysml/conf/DMLConfig.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/conf/DMLConfig.java b/src/main/java/org/apache/sysml/conf/DMLConfig.java index 563573c..84beea8 100644 --- a/src/main/java/org/apache/sysml/conf/DMLConfig.java +++ b/src/main/java/org/apache/sysml/conf/DMLConfig.java @@ -77,6 +77,7 @@ public class DMLConfig public static final String CODEGEN_PLANCACHE = "codegen.plancache"; //boolean public static final String CODEGEN_LITERALS = "codegen.literals"; //1..heuristic, 2..always public static final String EXTRA_FINEGRAINED_STATS = "systemml.stats.finegrained"; //boolean + public static final String STATS_MAX_WRAP_LEN = "systemml.stats.maxWrapLength"; //int public static final String EXTRA_GPU_STATS = "systemml.stats.extraGPU"; //boolean public static final String EXTRA_DNN_STATS = "systemml.stats.extraDNN"; //boolean public static final String AVAILABLE_GPUS = "systemml.gpu.availableGPUs"; // String to specify which GPUs to use (a range, all GPUs, comma separated list or a specific GPU) @@ -122,6 +123,7 @@ public class DMLConfig _defaultVals.put(CODEGEN_LITERALS, "1" ); _defaultVals.put(NATIVE_BLAS, "none" ); _defaultVals.put(EXTRA_FINEGRAINED_STATS,"false" ); + _defaultVals.put(STATS_MAX_WRAP_LEN,"30" ); _defaultVals.put(EXTRA_GPU_STATS, "false" ); _defaultVals.put(EXTRA_DNN_STATS, "false" ); @@ -407,7 +409,7 @@ public class DMLConfig YARN_APPMASTER, YARN_APPMASTERMEM, YARN_MAPREDUCEMEM, CP_PARALLEL_OPS, CP_PARALLEL_IO, NATIVE_BLAS, COMPRESSED_LINALG, CODEGEN, CODEGEN_LITERALS, CODEGEN_PLANCACHE, - EXTRA_GPU_STATS, EXTRA_DNN_STATS, EXTRA_FINEGRAINED_STATS, + EXTRA_GPU_STATS, EXTRA_DNN_STATS, EXTRA_FINEGRAINED_STATS, STATS_MAX_WRAP_LEN, AVAILABLE_GPUS }; http://git-wip-us.apache.org/repos/asf/systemml/blob/b7060832/src/main/java/org/apache/sysml/utils/Statistics.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/utils/Statistics.java b/src/main/java/org/apache/sysml/utils/Statistics.java index 847682c..e7e8ecc 100644 --- a/src/main/java/org/apache/sysml/utils/Statistics.java +++ b/src/main/java/org/apache/sysml/utils/Statistics.java @@ -47,7 +47,7 @@ import org.apache.sysml.runtime.matrix.data.LibMatrixDNN; * This class captures all statistics. */ public class Statistics -{ +{ private static long compileStartTime = 0; private static long compileEndTime = 0; @@ -553,6 +553,7 @@ public class Statistics maxCountLen = Math.max(maxCountLen, String.valueOf(_cpInstCounts.get(instruction)).length()); } + maxInstLen = Math.min(maxInstLen, DMLScript.STATISTICS_MAX_WRAP_LEN); sb.append(String.format( " %" + maxNumLen + "s %-" + maxInstLen + "s %" + maxTimeSLen + "s %" + maxCountLen + "s", numCol, instCol, timeSCol, countCol)); @@ -563,22 +564,38 @@ public class Statistics sb.append("\n"); for (int i = 0; i < numHittersToDisplay; i++) { String instruction = tmp[len - 1 - i].getKey(); + String [] wrappedInstruction = wrap(instruction, maxInstLen); Long timeNs = tmp[len - 1 - i].getValue(); double timeS = (double) timeNs / 1000000000.0; String timeSString = sFormat.format(timeS); Long count = _cpInstCounts.get(instruction); - sb.append(String.format( - " %" + maxNumLen + "d %-" + maxInstLen + "s %" + maxTimeSLen + "s %" + maxCountLen + "d", - (i + 1), instruction, timeSString, count)); - - // Add the miscellaneous timer info + int numLines = wrappedInstruction.length; + String [] miscTimers = null; + if (GPUStatistics.DISPLAY_STATISTICS || DMLScript.FINEGRAINED_STATISTICS) { - sb.append(" "); - sb.append(GPUStatistics.getStringForCPMiscTimesPerInstruction(instruction)); + miscTimers = wrap(GPUStatistics.getStringForCPMiscTimesPerInstruction(instruction), DMLScript.STATISTICS_MAX_WRAP_LEN); + numLines = Math.max(numLines, miscTimers.length); + } + + String miscFormatString = (GPUStatistics.DISPLAY_STATISTICS || DMLScript.FINEGRAINED_STATISTICS) ? " %" + DMLScript.STATISTICS_MAX_WRAP_LEN + "s" : "%s"; + for(int wrapIter = 0; wrapIter < numLines; wrapIter++) { + String instStr = (wrapIter < wrappedInstruction.length) ? wrappedInstruction[wrapIter] : ""; + String miscTimerStr = ( (GPUStatistics.DISPLAY_STATISTICS || DMLScript.FINEGRAINED_STATISTICS) && wrapIter < miscTimers.length) ? miscTimers[wrapIter] : ""; + if(wrapIter == 0) { + // Display instruction count + sb.append(String.format( + " %" + maxNumLen + "d %-" + maxInstLen + "s %" + maxTimeSLen + "s %" + maxCountLen + "d" + miscFormatString, + (i + 1), instStr, timeSString, count, miscTimerStr)); + } + else { + sb.append(String.format( + " %" + maxNumLen + "s %-" + maxInstLen + "s %" + maxTimeSLen + "s %" + maxCountLen + "s" + miscFormatString, + "", instStr, "", "", miscTimerStr)); + } + sb.append("\n"); } - sb.append("\n"); } return sb.toString(); @@ -669,6 +686,17 @@ public class Statistics public static String display() { return display(DMLScript.STATISTICS_COUNT); } + + + private static String [] wrap(String str, int wrapLength) { + int numLines = (int) Math.ceil( ((double)str.length()) / wrapLength); + int len = str.length(); + String [] ret = new String[numLines]; + for(int i = 0; i < numLines; i++) { + ret[i] = str.substring(i*wrapLength, Math.min((i+1)*wrapLength, len)); + } + return ret; + } /** * Returns statistics as a string