stack_dist_calc.cc (10614:da37aec3ed1a) | stack_dist_calc.cc (10995:a114e2712642) |
---|---|
1/* | 1/* |
2 * Copyright (c) 2014 ARM Limited | 2 * Copyright (c) 2014-2015 ARM Limited |
3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated --- 21 unchanged lines hidden (view full) --- 32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 * 37 * Authors: Kanishk Sugand 38 */ 39 | 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated --- 21 unchanged lines hidden (view full) --- 32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 * 37 * Authors: Kanishk Sugand 38 */ 39 |
40#include "mem/stack_dist_calc.hh" 41 42#include "base/chunk_generator.hh" |
|
40#include "base/intmath.hh" 41#include "base/trace.hh" 42#include "debug/StackDist.hh" | 43#include "base/intmath.hh" 44#include "base/trace.hh" 45#include "debug/StackDist.hh" |
43#include "mem/stack_dist_calc.hh" | |
44 | 46 |
45StackDistCalc::StackDistCalc(const StackDistCalcParams* p) : 46 SimObject(p), index(0), verifyStack(p->verify), 47 disableLinearHists(p->disable_linear_hists), 48 disableLogHists(p->disable_log_hists) | 47StackDistCalc::StackDistCalc(bool verify_stack) 48 : index(0), 49 verifyStack(verify_stack) |
49{ 50 // Instantiate a new root and leaf layer 51 // Map type variable, representing a layer in the tree 52 IndexNodeMap tree_level; 53 54 // Initialize tree count for leaves 55 nextIndex.push_back(0); 56 --- 29 unchanged lines hidden (view full) --- 86 tree.clear(); 87 aiMap.clear(); 88 nextIndex.clear(); 89 90 // For verification 91 stack.clear(); 92} 93 | 50{ 51 // Instantiate a new root and leaf layer 52 // Map type variable, representing a layer in the tree 53 IndexNodeMap tree_level; 54 55 // Initialize tree count for leaves 56 nextIndex.push_back(0); 57 --- 29 unchanged lines hidden (view full) --- 87 tree.clear(); 88 aiMap.clear(); 89 nextIndex.clear(); 90 91 // For verification 92 stack.clear(); 93} 94 |
94void 95StackDistCalc::update(const MemCmd& cmd, Addr addr) 96{ 97 // only capturing read and write requests (which allocate in the 98 // cache) 99 if (cmd.isRead() || cmd.isWrite()) { 100 auto returnType = calcStackDistAndUpdate(addr); 101 102 uint64_t stackDist = returnType.first; 103 104 if (stackDist != Infinity) { 105 // Sample the stack distance of the address in linear bins 106 if (!disableLinearHists) { 107 if (cmd.isRead()) 108 readLinearHist.sample(stackDist); 109 else 110 writeLinearHist.sample(stackDist); 111 } 112 113 if (!disableLogHists) { 114 int stackDistLog2 = stackDist == 0 ? 1 : floorLog2(stackDist); 115 116 // Sample the stack distance of the address in log bins 117 if (cmd.isRead()) 118 readLogHist.sample(stackDistLog2); 119 else 120 writeLogHist.sample(stackDistLog2); 121 } 122 } 123 } 124} 125 | |
126// The updateSum method is a recursive function which updates 127// the node sums till the root. It also deletes the nodes that 128// are not used anymore. 129uint64_t 130StackDistCalc::updateSum(Node* node, bool from_left, 131 uint64_t sum_from_below, uint64_t level, 132 uint64_t stack_dist, bool discard_node) 133{ --- 493 unchanged lines hidden (view full) --- 627 DPRINTF(StackDist,"Printing Last %d entries in VerifStack \n", n); 628 count = 0; 629 for (auto a = stack.rbegin(); (count < n) && (a != stack.rend()); 630 ++a, ++count) { 631 DPRINTF(StackDist, "Verif Stack, Top-[%d] = %#lx\n", count, *a); 632 } 633 } 634} | 95// The updateSum method is a recursive function which updates 96// the node sums till the root. It also deletes the nodes that 97// are not used anymore. 98uint64_t 99StackDistCalc::updateSum(Node* node, bool from_left, 100 uint64_t sum_from_below, uint64_t level, 101 uint64_t stack_dist, bool discard_node) 102{ --- 493 unchanged lines hidden (view full) --- 596 DPRINTF(StackDist,"Printing Last %d entries in VerifStack \n", n); 597 count = 0; 598 for (auto a = stack.rbegin(); (count < n) && (a != stack.rend()); 599 ++a, ++count) { 600 DPRINTF(StackDist, "Verif Stack, Top-[%d] = %#lx\n", count, *a); 601 } 602 } 603} |
635 636void 637StackDistCalc::regStats() 638{ 639 using namespace Stats; 640 641 readLinearHist 642 .init(params()->linear_hist_bins) 643 .name(name() + ".readLinearHist") 644 .desc("Reads linear distribution") 645 .flags(disableLinearHists ? nozero : pdf); 646 647 readLogHist 648 .init(params()->log_hist_bins) 649 .name(name() + ".readLogHist") 650 .desc("Reads logarithmic distribution") 651 .flags(disableLogHists ? nozero : pdf); 652 653 writeLinearHist 654 .init(params()->linear_hist_bins) 655 .name(name() + ".writeLinearHist") 656 .desc("Writes linear distribution") 657 .flags(disableLinearHists ? nozero : pdf); 658 659 writeLogHist 660 .init(params()->log_hist_bins) 661 .name(name() + ".writeLogHist") 662 .desc("Writes logarithmic distribution") 663 .flags(disableLogHists ? nozero : pdf); 664} 665 666StackDistCalc* 667StackDistCalcParams::create() 668{ 669 return new StackDistCalc(this); 670} | |