Deleted Added
sdiff udiff text old ( 10614:da37aec3ed1a ) new ( 10995:a114e2712642 )
full compact
1/*
2 * Copyright (c) 2014 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

--- 25 unchanged lines hidden (view full) ---

36 *
37 * Authors: Kanishk Sugand
38 * Andreas Hansson
39 */
40
41#ifndef __MEM_STACK_DIST_CALC_HH__
42#define __MEM_STACK_DIST_CALC_HH__
43
44#include <map>
45#include <vector>
46
47#include "base/types.hh"
48#include "mem/packet.hh"
49#include "params/StackDistCalc.hh"
50#include "sim/sim_object.hh"
51#include "sim/stats.hh"
52
53/**
54 * The stack distance calculator is a passive object that merely
55 * observes the addresses pass to it. It calculates stack distances
56 * of incoming addresses based on the partial sum hierarchy tree
57 * algorithm described by Alamasi et al.
58 * http://doi.acm.org/10.1145/773039.773043.
59 *

--- 109 unchanged lines hidden (view full) ---

169 * on the top of an STL vector stack, and SD is returned as
170 * Infinity. If a non unique address is encountered then the previous
171 * entry in the STL vector is removed, all the entities above it are
172 * pushed down, and the address is pushed at the top of the stack).
173 *
174 * A printStack(int numOfEntitiesToPrint) is provided to print top n entities
175 * in both (tree and STL based dummy stack).
176 */
177class StackDistCalc : public SimObject
178{
179
180 private:
181
182 struct Node;
183
184 typedef std::map<uint64_t, Node*> IndexNodeMap;
185 typedef std::map<Addr, uint64_t> AddressIndexMap;

--- 76 unchanged lines hidden (view full) ---

262 *
263 * @param node pointer to the node whose sanity is being checked
264 * @param level the level at which this node is located in the tree
265 *
266 */
267 void sanityCheckTree(const Node* node, uint64_t level = 0) const;
268
269 /**
270 * A convenient way of refering to infinity.
271 */
272 static constexpr uint64_t Infinity = std::numeric_limits<uint64_t>::max();
273
274 /**
275 * Process the given address. If Mark is true then set the
276 * mark flag of the leaf node.
277 * This function returns the stack distance of the incoming
278 * address and the previous status of the mark flag.
279 *
280 * @param r_address The current address to process
281 * @param mark set the mark flag for the address.
282 * @return The stack distance of the current address and the mark flag.
283 */
284 std::pair<uint64_t , bool> calcStackDist(const Addr r_address,
285 bool mark = false);
286
287 /**
288 * Process the given address:
289 * - Lookup the tree for the given address
290 * - delete old node if found in tree
291 * - add a new node (if addNewNode flag is set)
292 * This function returns the stack distance of the incoming
293 * address and the status of the mark flag.
294 *
295 * @param r_address The current address to process
296 * @param addNewNode If true, a new node is added to the tree
297 * @return The stack distance of the current address and the mark flag.
298 */
299 std::pair<uint64_t, bool> calcStackDistAndUpdate(const Addr r_address,
300 bool addNewNode = true);
301
302 /**
303 * Return the counter for address accesses (unique and
304 * non-unique). This is further used to dump stats at
305 * regular intervals.
306 *
307 * @return The stack distance of the current address.
308 */
309 uint64_t getIndex() const { return index; }
310

--- 25 unchanged lines hidden (view full) ---

336 * @return Stack distance which is calculated by this alternative
337 * implementation
338 *
339 */
340 uint64_t verifyStackDist(const Addr r_address,
341 bool update_stack = false);
342
343 public:
344
345 /**
346 * Convenience method to get the params when registering stats.
347 */
348 const StackDistCalcParams* params() const
349 { return reinterpret_cast<const StackDistCalcParams*>(_params); }
350
351 StackDistCalc(const StackDistCalcParams* p);
352
353 ~StackDistCalc();
354
355 void regStats();
356
357 /**
358 * Update the tree and the statistics.
359 *
360 * @param cmd Command from the packet
361 * @param addr Address to put on the stack
362 */
363 void update(const MemCmd& cmd, Addr addr);
364
365 private:
366
367 /**
368 * Node which takes form of Leaf, INode or Root
369 */
370 struct Node{
371 // Sum of the left children

--- 53 unchanged lines hidden (view full) ---

425 // level in the tree
426 std::vector<uint64_t> nextIndex;
427
428 // Dummy Stack for verification
429 std::vector<uint64_t> stack;
430
431 // Flag to enable verification of stack. (Slows down the simulation)
432 const bool verifyStack;
433
434 // Disable the linear histograms
435 const bool disableLinearHists;
436
437 // Disable the logarithmic histograms
438 const bool disableLogHists;
439
440 // Reads linear histogram
441 Stats::Histogram readLinearHist;
442
443 // Reads logarithmic histogram
444 Stats::SparseHistogram readLogHist;
445
446 // Writes linear histogram
447 Stats::Histogram writeLinearHist;
448
449 // Writes logarithmic histogram
450 Stats::SparseHistogram writeLogHist;
451
452};
453
454#endif //__STACK_DIST_CALC_HH__