From 97d8d3204968cf42da7b41e760a0f46c1e276080 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 17 Sep 2021 18:52:12 -0400 Subject: [PATCH] Commentary --- bin/verilator_gantt | 12 +++++------ src/V3EmitCModel.cpp | 48 ++++++++++++++++++++++---------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/bin/verilator_gantt b/bin/verilator_gantt index e48792425..5fae5f46f 100755 --- a/bin/verilator_gantt +++ b/bin/verilator_gantt @@ -58,7 +58,7 @@ def read_data(filename): if 'elapsed' not in Mtasks[mtask]: Mtasks[mtask] = {'end': 0, 'elapsed': 0} Mtasks[mtask]['elapsed'] += elapsed_time - Mtasks[mtask]['predict'] = predict_time + Mtasks[mtask]['predict_cost'] = predict_time Mtasks[mtask]['end'] = max(Mtasks[mtask]['end'], end) elif re.match(r'^VLPROFTHREAD', line): None # pylint: disable=pointless-statement @@ -166,9 +166,9 @@ def report(): for mtask in sorted(Mtasks.keys()): if Mtasks[mtask]['elapsed'] > 0: - if Mtasks[mtask]['predict'] == 0: - Mtasks[mtask]['predict'] = 1 # don't log(0) below - p2e_ratio = math.log(Mtasks[mtask]['predict'] / + if Mtasks[mtask]['predict_cost'] == 0: + Mtasks[mtask]['predict_cost'] = 1 # don't log(0) below + p2e_ratio = math.log(Mtasks[mtask]['predict_cost'] / Mtasks[mtask]['elapsed']) p2e_ratios.append(p2e_ratio) @@ -182,12 +182,12 @@ def report(): print("\nStatistics:") print(" min log(p2e) = %0.3f" % min_p2e, end="") print(" from mtask %d (predict %d," % - (min_mtask, Mtasks[min_mtask]['predict']), + (min_mtask, Mtasks[min_mtask]['predict_cost']), end="") print(" elapsed %d)" % Mtasks[min_mtask]['elapsed']) print(" max log(p2e) = %0.3f" % max_p2e, end="") print(" from mtask %d (predict %d," % - (max_mtask, Mtasks[max_mtask]['predict']), + (max_mtask, Mtasks[max_mtask]['predict_cost']), end="") print(" elapsed %d)" % Mtasks[max_mtask]['elapsed']) diff --git a/src/V3EmitCModel.cpp b/src/V3EmitCModel.cpp index 140f03140..334824df1 100644 --- a/src/V3EmitCModel.cpp +++ b/src/V3EmitCModel.cpp @@ -407,45 +407,45 @@ class EmitCModel final : public EmitCFunc { } if (v3Global.opt.mtasks() && v3Global.opt.profThreads()) { - puts("if (VL_UNLIKELY((vlSymsp->_vm_contextp__->profThreadsStart() != " - "vlSymsp->__Vm_profile_time_finished)\n"); + puts("if (VL_UNLIKELY((vlSymsp->_vm_contextp__->profThreadsStart()" + " != vlSymsp->__Vm_profile_time_finished)\n"); puts(" && (VL_TIME_Q() > vlSymsp->_vm_contextp__->profThreadsStart())\n"); puts(" && (vlSymsp->_vm_contextp__->profThreadsWindow() >= 1))) {\n"); // Within a profile (either starting, middle, or end) - puts("if (vlSymsp->__Vm_profile_window_ct == 0) {\n"); // Opening file? + puts(/**/ "if (vlSymsp->__Vm_profile_window_ct == 0) {\n"); // Opening file? // Start profile on this cycle. We'll capture a window worth, then // only analyze the next window worth. The idea is that the first window // capture will hit some cache-cold stuff (eg printf) but it'll be warm // by the time we hit the second window, we hope. - puts("vlSymsp->__Vm_profile_cycle_start = VL_RDTSC_Q();\n"); + puts(/****/ "vlSymsp->__Vm_profile_cycle_start = VL_RDTSC_Q();\n"); // "* 2" as first half is warmup, second half is collection - puts("vlSymsp->__Vm_profile_window_ct = vlSymsp->_vm_contextp__->profThreadsWindow() " - "* 2 " - "+ " - "1;\n"); - puts("}\n"); - puts("--(vlSymsp->__Vm_profile_window_ct);\n"); - puts("if (vlSymsp->__Vm_profile_window_ct == " - "vlSymsp->_vm_contextp__->profThreadsWindow()) {\n"); + puts(/****/ "vlSymsp->__Vm_profile_window_ct" + " = vlSymsp->_vm_contextp__->profThreadsWindow()" + " * 2 + 1;\n"); + puts(/**/ "}\n"); + puts(/**/ "--(vlSymsp->__Vm_profile_window_ct);\n"); + puts(/**/ "if (vlSymsp->__Vm_profile_window_ct" + " == vlSymsp->_vm_contextp__->profThreadsWindow()) {\n"); // This barrier record in every threads' profile demarcates the // cache-warm-up cycles before the barrier from the actual profile // cycles afterward. - puts("vlSymsp->__Vm_threadPoolp->profileAppendAll("); - puts("VlProfileRec(VlProfileRec::Barrier()));\n"); - puts("vlSymsp->__Vm_profile_cycle_start = VL_RDTSC_Q();\n"); - puts("}\n"); - puts("else if (vlSymsp->__Vm_profile_window_ct == 0) {\n"); + puts(/****/ "vlSymsp->__Vm_threadPoolp->profileAppendAll("); + puts(/****/ "VlProfileRec(VlProfileRec::Barrier()));\n"); + puts(/****/ "vlSymsp->__Vm_profile_cycle_start = VL_RDTSC_Q();\n"); + puts(/**/ "}\n"); + puts(/**/ "else if (vlSymsp->__Vm_profile_window_ct == 0) {\n"); // Ending file. - puts("vluint64_t elapsed = VL_RDTSC_Q() - vlSymsp->__Vm_profile_cycle_start;\n"); - puts("vlSymsp->__Vm_threadPoolp->profileDump(vlSymsp->_vm_contextp__->" - "profThreadsFilename().c_str(), elapsed);\n"); + puts(/****/ "vluint64_t elapsed" + " = VL_RDTSC_Q() - vlSymsp->__Vm_profile_cycle_start;\n"); + puts(/****/ "vlSymsp->__Vm_threadPoolp->profileDump(vlSymsp->_vm_contextp__->" + "profThreadsFilename().c_str(), elapsed);\n"); // This turns off the test to enter the profiling code, but still // allows the user to collect another profile by changing // profThreadsStart - puts("vlSymsp->__Vm_profile_time_finished = " - "vlSymsp->_vm_contextp__->profThreadsStart();\n"); - puts("vlSymsp->__Vm_profile_cycle_start = 0;\n"); - puts("}\n"); + puts(/****/ "vlSymsp->__Vm_profile_time_finished" + " = vlSymsp->_vm_contextp__->profThreadsStart();\n"); + puts(/****/ "vlSymsp->__Vm_profile_cycle_start = 0;\n"); + puts(/**/ "}\n"); puts("}\n"); }