Commit 22954c52 authored by Ondrej Vysocky's avatar Ondrej Vysocky
Browse files

ENH removed mericMeasurementCounters #61

parent 93668e42
......@@ -175,23 +175,12 @@ public:
MPI_Abort(MPI_COMM_WORLD, -1);
}
}
/*
if (!_MPInodeRank) {
if (Meric::AGGREGATE) {
for(int i=0; i<_storeList.size(); i++)
_storeList[i]->save(Meric::OUTPUT_DIR, Meric::OUTPUT_FILENAME, _name, _nodeName);
} else {
for(int i=0; i<_storeList.size(); i++)
_storeList[i]->save(Meric::OUTPUT_DIR, Meric::OUTPUT_FILENAME, _name, _nodeName);
}
}
*/
int initCounter = -1;
for(int i=0; i<_storeList.size(); i++)
{
if (!_MPInodeRank)
{
initCounter = _storeList[i]->initStore(initCounter, Meric::OUTPUT_DIR, Meric::OUTPUT_FILENAME, Meric::outputFilenameInfo, _nodeName);
_storeList[i]->initStore(Meric::ITERATION, Meric::OUTPUT_DIR, Meric::OUTPUT_FILENAME, Meric::outputFilenameInfo, _nodeName);
}
if (_storeList[i]->getMPIWrite())
{
......@@ -202,7 +191,6 @@ public:
catch (int &e)
{
//exception for timeenergystore(HDEEM), timestore<HDEEM>, timestore<DAVIDE> store when there are no power samples
_storeList[i]->restoreCounter(initCounter, Meric::OUTPUT_DIR, Meric::OUTPUT_FILENAME);
MPI_Abort(MPI_COMM_WORLD, 1);
}
}
......
......@@ -3,6 +3,7 @@
using namespace meric;
int Meric::ITERATION = mutils::getenv("MERIC_ITERATION", 0);
int Meric::MODE = mutils::getenv<int>("MERIC_MODE" , MODE_RUN);
bool Meric::CONTINUAL = mutils::getenv("MERIC_CONTINUAL" , false);
bool Meric::DETAILED = mutils::getenv("MERIC_DETAILED" , false);
......
......@@ -31,20 +31,6 @@ class Meric {
public:
static void readRegionParameters();
static bool CONTINUAL;
static bool DETAILED;
static bool AGGREGATE;
static bool DEBUG;
static bool SAMPLES;
static bool IGNORE;
static bool HDF5;
static int MODE;
static std::string COUNTERS;
static std::string OUTPUT_DIR;
static std::string OUTPUT_FILENAME;
static std::string REGION_OPTIONS;
static std::string BARRIERS;
virtual void start(const std::string &region)
{
for (int i=0; i<_storeList.size(); i++)
......@@ -352,6 +338,21 @@ protected:
static bool MPIbarriers;
static bool OMPbarriers;
static std::string outputFilenameInfo;
static int ITERATION;
static bool CONTINUAL;
static bool DETAILED;
static bool AGGREGATE;
static bool DEBUG;
static bool SAMPLES;
static bool IGNORE;
static bool HDF5;
static int MODE;
static std::string COUNTERS;
static std::string OUTPUT_DIR;
static std::string OUTPUT_FILENAME;
static std::string REGION_OPTIONS;
static std::string BARRIERS;
};
}
......
......@@ -155,20 +155,10 @@ public:
exit(-1);
}
int initCounter = -1;
for(int i=0; i<_storeList.size(); i++)
{
initCounter = _storeList[i]->initStore(initCounter, Meric::OUTPUT_DIR, Meric::OUTPUT_FILENAME, Meric::outputFilenameInfo);
try
{
_storeList[i]->save(Meric::OUTPUT_DIR, Meric::OUTPUT_FILENAME, _name);
}
catch (int &e)
{
//exception for timeenergystore(HDEEM), timestore<HDEEM>, timestore<DAVIDE> store when there are no power samples
_storeList[i]->restoreCounter(initCounter, Meric::OUTPUT_DIR, Meric::OUTPUT_FILENAME);
break;
}
_storeList[i]->initStore(Meric::ITERATION, Meric::OUTPUT_DIR, Meric::OUTPUT_FILENAME, Meric::outputFilenameInfo);
_storeList[i]->save(Meric::OUTPUT_DIR, Meric::OUTPUT_FILENAME, _name);
}
}
......
......@@ -41,7 +41,6 @@ public:
void save(const std::string outputDir, const std::string outputFilename, std::vector<std::string> regionNames, const std::string prefix = "")
{
_store->setRegionsNames(regionNames);
_store->initStore(_initCounter);
if (_rank) {
_store->save([&] (std::vector<size_t> &iStarts, size_t iEnd) {
saveInterval(iStarts, iEnd);
......@@ -52,52 +51,14 @@ public:
});
}
}
int storeCounter(std::string counterFileName)
{
if (!_rank)
{
std::ifstream iFile(counterFileName);
if(iFile.is_open())
{
std::string numOfStartsStr;
std::getline(iFile, numOfStartsStr);
_initCounter = std::stoi(numOfStartsStr) + 1;
iFile.close();
}else
{
_initCounter = 0;
}
std::ofstream oFile(counterFileName);
oFile << _initCounter;
oFile.close();
return _initCounter;
}
else
return -1;
}
void restoreCounter(int counter,
void initStore( int counter,
const std::string outputDir,
const std::string outputFilename,
const std::string prefix = "")
const std::string outputFilenameInfo, //node_CF_UnCF_config
const std::string prefix = "") override
{
if (!_rank)
{
std::string startCounterFile = outputDir + "Counters/" + "startCounter_" + (prefix.size() ? prefix + "_" : "" ) + outputFilename + ".tmp";
if(counter == 0)
{
remove(startCounterFile.c_str());
}
else
{
std::ofstream oFile(startCounterFile);
oFile << _initCounter-1;
oFile.close();
}
}
this->_store->initStore(counter, outputDir, outputFilename, outputFilenameInfo, prefix);
}
void loadSchedulerEnvironment()
......
......@@ -73,6 +73,49 @@ public:
MERIC_INFO << "Create InfoStore\n";
}
void initStore( int counter) override
{
loadSchedulerEnvironment();
_initCounter = counter;
};
void initStore( int counter,
const std::string outputDir,
const std::string outputFilename,
const std::string outputFilenameInfo, //node_CF_UnCF_config
const std::string prefix = "") override
{
loadSchedulerEnvironment();
_initCounter = counter;
if(counter == 0)
{
mutils::createDir(outputDir);
std::string dataInfoFileName = outputDir + "/measurementInfo.json";
struct stat info;
if(stat(dataInfoFileName.c_str(), &info ) != 0)
{
std::ofstream oFile(dataInfoFileName);
char hostname[50];
gethostname(hostname, 50);
time_t now_t = time(0);
std::string now_s = std::string(ctime(&now_t));
now_s.pop_back();
oFile << "{\n"
<< "\t\"Timestamp\" : \"" << now_s << "\",\n"
<< "\t\"System\" : \"" << std::string(hostname) << "\",\n"
<< "\t\"DataFormat\": \"" << (prefix.size() ? "node_" : "") << outputFilenameInfo << "\",\n"
<< "\t\"Note\" : \"\"\n"
<< "}";
oFile.close();
}
}
//CALLTREE init counter
return;
};
protected:
void saveInterval(std::ofstream &ss, std::vector<size_t> &iStarts, size_t iEnd);
......
......@@ -49,8 +49,6 @@ public:
virtual void addEnd(int region) = 0;
virtual double getRegionDuration() = 0;
virtual void loadSchedulerEnvironment() = 0;
virtual int storeCounter(std::string counterFileName) = 0;
virtual void restoreCounter(int counter, const std::string outputDir, const std::string outputFilename, const std::string prefix = "") = 0;
virtual void save(const std::string outputDir, const std::string outputFilename, std::vector<std::string> regionNames, const std::string prefix = "") = 0;
StoreBase(bool samples = false) : printSamples(samples) {};
......@@ -61,51 +59,21 @@ public:
bool getMPIWrite() {return MPIProcessWrite;};
void setMPIWrite(bool write) {MPIProcessWrite = write;};
int initStore( int counter)
virtual void initStore( int counter)
{
loadSchedulerEnvironment();
_initCounter = counter;
};
int initStore( int counter,
virtual void initStore( int counter,
const std::string outputDir,
const std::string outputFilename,
const std::string outputFilenameInfo, //node_CF_UnCF_config
const std::string prefix = "")
{
loadSchedulerEnvironment();
if(counter >= 0)
{
_initCounter = counter;
return counter;
}
mutils::createDir(outputDir);
std::string dataInfoFileName = outputDir + "/measurementInfo.json";
struct stat info;
if(stat(dataInfoFileName.c_str(), &info ) != 0)
{
std::ofstream oFile(dataInfoFileName);
char hostname[50];
gethostname(hostname, 50);
time_t now_t = time(0);
std::string now_s = std::string(ctime(&now_t));
now_s.pop_back();
oFile << "{\n"
<< "\t\"Timestamp\" : \"" << now_s << "\",\n"
<< "\t\"System\" : \"" << std::string(hostname) << "\",\n"
<< "\t\"DataFormat\": \"" << (prefix.size() ? "node_" : "") << outputFilenameInfo << "\",\n"
<< "\t\"Note\" : \"\"\n"
<< "}";
oFile.close();
}
//CALLTREE init counter
mutils::createDir(outputDir + "Counters");
return storeCounter(outputDir + "Counters/" + "startCounter_" + (prefix.size() ? prefix + "_" : "" ) + outputFilename + ".tmp");
_initCounter = counter;
return;
};
......@@ -221,44 +189,6 @@ protected:
class Store: public StoreBase {
public:
int storeCounter(std::string counterFileName)
{
std::ifstream iFile(counterFileName);
if(iFile.is_open())
{
std::string numOfStartsStr;
std::getline(iFile, numOfStartsStr);
_initCounter = std::stoi(numOfStartsStr) + 1;
iFile.close();
}else
{
_initCounter = 0;
}
std::ofstream oFile(counterFileName);
oFile << _initCounter;
oFile.close();
return _initCounter;
}
void restoreCounter(int counter,
const std::string outputDir,
const std::string outputFilename,
const std::string prefix = "")
{
std::string startCounterFile = outputDir + "Counters/" + "startCounter_" + (prefix.size() ? prefix + "_" : "" ) + outputFilename + ".tmp";
if(counter == 0)
{
remove(startCounterFile.c_str());
}
else
{
std::ofstream oFile(startCounterFile);
oFile << _initCounter-1;
oFile.close();
}
}
void loadSchedulerEnvironment()
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment