13 #ifndef _H_SST_CORE_COMP_REG_STAT__
14 #define _H_SST_CORE_COMP_REG_STAT__
23 std::string fullStatName;
25 bool nameFound =
false;
26 StatisticBase::StatMode_t statCollectionMode = StatisticBase::STAT_MODE_COUNT;
27 Output & out = getSimulation()->getSimulationOutput();
28 StatisticProcessingEngine *engine = StatisticProcessingEngine::getInstance();
29 UnitAlgebra collectionRate;
31 std::string statRateParam;
32 std::string statTypeParam;
33 Statistic<T>* statistic = NULL;
37 fullStatName = StatisticBase::buildStatisticFullName(getName().c_str(), statName, statSubId);
40 if (
true == getSimulation()->isWireUpFinished()) {
42 out.fatal(CALL_INFO, 1,
"ERROR: Statistic %s - Cannot be registered after the Components have been wired up. Statistics must be registered on Component creation.; exiting...\n", fullStatName.c_str());
49 BaseComponent *owner = this->getStatisticOwner();
61 for (
auto & si : *my_info->getStatEnableList() ) {
65 if ((std::string(STATALLFLAG) == si.name) || (statName == si.name)) {
67 Params::KeySet_t allowedKeySet;
68 allowedKeySet.insert(
"type");
69 allowedKeySet.insert(
"rate");
70 allowedKeySet.insert(
"startat");
71 allowedKeySet.insert(
"stopat");
72 allowedKeySet.insert(
"resetOnRead");
73 si.params.pushAllowedKeys(allowedKeySet);
77 statTypeParam = si.params.find<std::string>(
"type",
"sst.AccumulatorStatistic");
78 statRateParam = si.params.find<std::string>(
"rate",
"0ns");
80 collectionRate = UnitAlgebra(statRateParam);
81 statParams = si.params;
88 if (
false == nameFound) {
90 out.verbose(CALL_INFO, 1, 0,
" Warning: Statistic %s is not enabled in python script, statistic will not be enabled...\n", fullStatName.c_str());
93 if (
true == statGood) {
95 if ((
true == collectionRate.hasUnits(
"s")) ||
96 (
true == collectionRate.hasUnits(
"hz")) ) {
98 statCollectionMode = StatisticBase::STAT_MODE_PERIODIC;
99 }
else if (
true == collectionRate.hasUnits(
"event")) {
101 statCollectionMode = StatisticBase::STAT_MODE_COUNT;
102 }
else if (0 == collectionRate.getValue()) {
104 collectionRate = UnitAlgebra(
"0ns");
105 statCollectionMode = StatisticBase::STAT_MODE_PERIODIC;
108 out.fatal(CALL_INFO, 1,
"ERROR: Statistic %s - Collection Rate = %s not valid; exiting...\n", fullStatName.c_str(), collectionRate.toString().c_str());
112 if (
true == statGood) {
114 statistic = engine->createStatistic<T>(owner, statTypeParam, statName, statSubId, statParams);
115 if (NULL == statistic) {
116 out.fatal(CALL_INFO, 1,
"ERROR: Unable to instantiate Statistic %s; exiting...\n", fullStatName.c_str());
120 if (
false == statistic->isStatModeSupported(statCollectionMode)) {
121 if (StatisticBase::STAT_MODE_PERIODIC == statCollectionMode) {
122 out.verbose(CALL_INFO, 1, 0,
" Warning: Statistic %s Does not support Periodic Based Collections; Collection Rate = %s\n", fullStatName.c_str(), collectionRate.toString().c_str());
124 out.verbose(CALL_INFO, 1, 0,
" Warning: Statistic %s Does not support Event Based Collections; Collection Rate = %s\n", fullStatName.c_str(), collectionRate.toString().c_str());
130 statistic->setRegisteredCollectionMode(statCollectionMode);
134 if (
true == statGood) {
135 statGood = engine->registerStatisticWithEngine<T>(statistic);
138 if (
false == statGood ) {
140 if (NULL != statistic) {
145 statTypeParam =
"sst.NullStatistic";
146 statistic = engine->createStatistic<T>(owner, statTypeParam, statName, statSubId, statParams);
147 if (NULL == statistic) {
149 out.fatal(CALL_INFO, 1,
"ERROR: Unable to instantiate Null Statistic %s; exiting...\n", fullStatName.c_str());
151 engine->registerStatisticWithEngine<T>(statistic);
158 #endif //_H_SST_CORE_COMP_REG_STAT__