stack_dist_calc.hh (10614:da37aec3ed1a) | stack_dist_calc.hh (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 --- 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 | 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 <limits> |
|
44#include <map> 45#include <vector> 46 47#include "base/types.hh" | 45#include <map> 46#include <vector> 47 48#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 */ | 49 50/** 51 * The stack distance calculator is a passive object that merely 52 * observes the addresses pass to it. It calculates stack distances 53 * of incoming addresses based on the partial sum hierarchy tree 54 * algorithm described by Alamasi et al. 55 * http://doi.acm.org/10.1145/773039.773043. 56 * --- 109 unchanged lines hidden (view full) --- 166 * on the top of an STL vector stack, and SD is returned as 167 * Infinity. If a non unique address is encountered then the previous 168 * entry in the STL vector is removed, all the entities above it are 169 * pushed down, and the address is pushed at the top of the stack). 170 * 171 * A printStack(int numOfEntitiesToPrint) is provided to print top n entities 172 * in both (tree and STL based dummy stack). 173 */ |
177class StackDistCalc : public SimObject | 174class StackDistCalc |
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 /** | 175{ 176 177 private: 178 179 struct Node; 180 181 typedef std::map<uint64_t, Node*> IndexNodeMap; 182 typedef std::map<Addr, uint64_t> AddressIndexMap; --- 76 unchanged lines hidden (view full) --- 259 * 260 * @param node pointer to the node whose sanity is being checked 261 * @param level the level at which this node is located in the tree 262 * 263 */ 264 void sanityCheckTree(const Node* node, uint64_t level = 0) const; 265 266 /** |
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: | 267 * Return the counter for address accesses (unique and 268 * non-unique). This is further used to dump stats at 269 * regular intervals. 270 * 271 * @return The stack distance of the current address. 272 */ 273 uint64_t getIndex() const { return index; } 274 --- 25 unchanged lines hidden (view full) --- 300 * @return Stack distance which is calculated by this alternative 301 * implementation 302 * 303 */ 304 uint64_t verifyStackDist(const Addr r_address, 305 bool update_stack = false); 306 307 public: |
308 StackDistCalc(bool verify_stack = false); |
|
344 | 309 |
310 ~StackDistCalc(); 311 |
|
345 /** | 312 /** |
346 * Convenience method to get the params when registering stats. | 313 * A convenient way of refering to infinity. |
347 */ | 314 */ |
348 const StackDistCalcParams* params() const 349 { return reinterpret_cast<const StackDistCalcParams*>(_params); } | 315 static constexpr uint64_t Infinity = std::numeric_limits<uint64_t>::max(); |
350 | 316 |
351 StackDistCalc(const StackDistCalcParams* p); | |
352 | 317 |
353 ~StackDistCalc(); | 318 /** 319 * Process the given address. If Mark is true then set the 320 * mark flag of the leaf node. 321 * This function returns the stack distance of the incoming 322 * address and the previous status of the mark flag. 323 * 324 * @param r_address The current address to process 325 * @param mark set the mark flag for the address. 326 * @return The stack distance of the current address and the mark flag. 327 */ 328 std::pair<uint64_t, bool> calcStackDist(const Addr r_address, 329 bool mark = false); |
354 | 330 |
355 void regStats(); 356 | |
357 /** | 331 /** |
358 * Update the tree and the statistics. | 332 * Process the given address: 333 * - Lookup the tree for the given address 334 * - delete old node if found in tree 335 * - add a new node (if addNewNode flag is set) 336 * This function returns the stack distance of the incoming 337 * address and the status of the mark flag. |
359 * | 338 * |
360 * @param cmd Command from the packet 361 * @param addr Address to put on the stack | 339 * @param r_address The current address to process 340 * @param addNewNode If true, a new node is added to the tree 341 * @return The stack distance of the current address and the mark flag. |
362 */ | 342 */ |
363 void update(const MemCmd& cmd, Addr addr); | 343 std::pair<uint64_t, bool> calcStackDistAndUpdate(const Addr r_address, 344 bool addNewNode = true); |
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; | 345 346 private: 347 348 /** 349 * Node which takes form of Leaf, INode or Root 350 */ 351 struct Node{ 352 // Sum of the left children --- 53 unchanged lines hidden (view full) --- 406 // level in the tree 407 std::vector<uint64_t> nextIndex; 408 409 // Dummy Stack for verification 410 std::vector<uint64_t> stack; 411 412 // Flag to enable verification of stack. (Slows down the simulation) 413 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 | 414}; 415 |
416 |
|
454#endif //__STACK_DIST_CALC_HH__ | 417#endif //__STACK_DIST_CALC_HH__ |