config.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. // config.h
  2. //
  3. // The Config class is used to set, store, and retrieve all the configurable
  4. // parameters of the simulator.
  5. //
  6. // Initial creation: Sep 18, 2008 by jasonm
  7. #ifndef CONFIG_H
  8. #define CONFIG_H
  9. // Enable to run core performance model in separate thread
  10. // When # simulated cores > # host cores, this is probably not very useful
  11. //#define ENABLE_PERF_MODEL_OWN_THREAD
  12. #include "fixed_types.h"
  13. #include "clock_skew_minimization_object.h"
  14. #include "cache_efficiency_tracker.h"
  15. #include <vector>
  16. #include <set>
  17. #include <unordered_map>
  18. #include <iostream>
  19. #include <cassert>
  20. struct NetworkModelAnalyticalParameters;
  21. class Config
  22. {
  23. public:
  24. enum SimulationMode
  25. {
  26. PINTOOL = 0,
  27. STANDALONE,
  28. NUM_SIMULATION_MODES
  29. };
  30. enum SimulationROI
  31. {
  32. ROI_FULL,
  33. ROI_MAGIC,
  34. ROI_SCRIPT
  35. };
  36. typedef std::unordered_map<UInt32,core_id_t> CommToCoreMap;
  37. Config(SimulationMode mode);
  38. ~Config();
  39. void loadFromFile(char* filename);
  40. void loadFromCmdLine();
  41. // Return the total number of modules in all processes
  42. UInt32 getTotalCores();
  43. UInt32 getApplicationCores();
  44. // For mapping between user-land communication id's to actual core id's
  45. void updateCommToCoreMap(UInt32 comm_id, core_id_t core_id);
  46. UInt32 getCoreFromCommId(UInt32 comm_id);
  47. // Fills in an array with the models for each static network
  48. void getNetworkModels(UInt32 *) const;
  49. // Get CoreId length
  50. UInt32 getCoreIDLength()
  51. { return m_core_id_length; }
  52. SimulationMode getSimulationMode()
  53. { return m_simulation_mode; }
  54. // Knobs
  55. UInt32 getNumHostCores() const { return m_knob_num_host_cores; }
  56. bool getEnableSMCSupport() const { return m_knob_enable_smc_support; }
  57. void forceEnableSMCSupport() { m_knob_enable_smc_support = true; }
  58. bool getIssueMemopsAtFunctional() const { return m_knob_issue_memops_at_functional; }
  59. bool getEnableICacheModeling() const { return m_knob_enable_icache_modeling; }
  60. SimulationROI getSimulationROI() const { return m_knob_roi; }
  61. bool getEnableProgressTrace() const { return m_knob_enable_progress_trace; }
  62. bool getEnableSync() const { return m_knob_enable_sync; }
  63. bool getEnableSyncReport() const { return m_knob_enable_sync_report; }
  64. bool getOSEmuPthreadReplace() const { return m_knob_osemu_pthread_replace; }
  65. UInt32 getOSEmuNprocs() const { return m_knob_osemu_nprocs; }
  66. bool getOSEmuClockReplace() const { return m_knob_osemu_clock_replace; }
  67. time_t getOSEmuTimeStart() const { return m_knob_osemu_time_start; }
  68. ClockSkewMinimizationObject::Scheme getClockSkewMinimizationScheme() const { return m_knob_clock_skew_minimization_scheme; }
  69. UInt64 getHPIInstructionsPerCore() const { return m_knob_hpi_percore; }
  70. UInt64 getHPIInstructionsGlobal() const { return m_knob_hpi_global; }
  71. bool getEnableSpinLoopDetection() const { return m_knob_enable_spinloopdetection; }
  72. bool suppressStdout() const { return m_suppress_stdout; }
  73. bool suppressStderr() const { return m_suppress_stderr; }
  74. bool getEnablePinPlay() const { return m_knob_enable_pinplay; }
  75. bool getEnableSyscallEmulation() const { return m_knob_enable_syscall_emulation; }
  76. bool getBBVsEnabled() const { return m_knob_bbvs; }
  77. void setBBVsEnabled(bool enable) { m_knob_bbvs = enable; }
  78. const CacheEfficiencyTracker::Callbacks& getCacheEfficiencyCallbacks() const { return m_cache_efficiency_callbacks; }
  79. bool hasCacheEfficiencyCallbacks() const { return m_cache_efficiency_callbacks.notify_evict_func != NULL; }
  80. void setCacheEfficiencyCallbacks(CacheEfficiencyTracker::CallbackGetOwner get_owner_func, CacheEfficiencyTracker::CallbackNotifyAccess notify_access_func, CacheEfficiencyTracker::CallbackNotifyEvict notify_evict_func, UInt64 user_arg);
  81. // Logging
  82. String getOutputDirectory() const;
  83. String formatOutputFileName(String filename) const;
  84. void logCoreMap();
  85. bool getCircularLogEnabled() const { return m_circular_log_enabled; }
  86. static Config *getSingleton();
  87. private:
  88. UInt32 m_total_cores; // Total number of cores in all processes
  89. UInt32 m_core_id_length; // Number of bytes needed to store a core_id
  90. CommToCoreMap m_comm_to_core_map;
  91. // Simulation Mode
  92. SimulationMode m_simulation_mode;
  93. static Config *m_singleton;
  94. static String m_knob_output_directory;
  95. static UInt32 m_knob_total_cores;
  96. static UInt32 m_knob_num_host_cores;
  97. static bool m_knob_enable_smc_support;
  98. static bool m_knob_issue_memops_at_functional;
  99. static bool m_knob_enable_icache_modeling;
  100. static SimulationROI m_knob_roi;
  101. static bool m_knob_enable_progress_trace;
  102. static bool m_knob_enable_sync;
  103. static bool m_knob_enable_sync_report;
  104. static bool m_knob_osemu_pthread_replace;
  105. static UInt32 m_knob_osemu_nprocs;
  106. static bool m_knob_osemu_clock_replace;
  107. static time_t m_knob_osemu_time_start;
  108. static bool m_knob_bbvs;
  109. static ClockSkewMinimizationObject::Scheme m_knob_clock_skew_minimization_scheme;
  110. static UInt64 m_knob_hpi_percore;
  111. static UInt64 m_knob_hpi_global;
  112. static bool m_knob_enable_spinloopdetection;
  113. static bool m_suppress_stdout;
  114. static bool m_suppress_stderr;
  115. static bool m_circular_log_enabled;
  116. static bool m_knob_enable_pinplay;
  117. static bool m_knob_enable_syscall_emulation;
  118. static CacheEfficiencyTracker::Callbacks m_cache_efficiency_callbacks;
  119. static SimulationMode parseSimulationMode(String mode);
  120. static UInt32 computeCoreIDLength(UInt32 core_count);
  121. static UInt32 getNearestAcceptableCoreCount(UInt32 core_count);
  122. };
  123. #endif