int iDidVirtualSkips;
if( (!inFile.is_open()) && inFileIt == inFiles.end() ) {
- cout << "RETURNING..." << endl;
nequileft = nequileft_internal;
return;
}
if( inFile.is_open() )
{
if (doVirtualEquilibration) {
- cout << nequileft_internal << endl;
-
if(log) *log << "CCACHE: Trying virtual equilibration." << endl << flush;
doVirtualEquilibration = false;
for (iDidVirtualSkips=0; iDidVirtualSkips < (NEQUI-openFileDesc.nequi)/openFileDesc.nskip; iDidVirtualSkips++) {
else if ( (NEQUI-openFileDesc.nequi) - (iDidVirtualSkips+1)*openFileDesc.nskip < nequileft_internal ) {
memcpy(configMem, tmpConfig, configSize);
nequileft_internal = NEQUI - openFileDesc.nequi - (iDidVirtualSkips+1)*openFileDesc.nskip;
- cout << "blabla:" << nequileft_internal << endl;
readnewconfig = true;
firstUsedConfig = false;
}
nequileft_internal = NEQUI - openFileDesc.nequi;
}
nequileft_internal -= openFileDesc.nskip;
- cout << "sadasd:" << nequileft_internal << endl;
nequileft = nequileft_internal;
return;
}
int hypercache::NEQUI;
int hypercache::NSKIP;
int hypercache::nequileft;
+pair<int, char*> hypercache::mostEquilibratedConfig;
void hypercache::initCache(configcache **cache,
const string& cacheid, const int& nequi, const int& nskip, const string& datadir,
(*osit)->setPara(parid, val);
nequileft = NEQUI;
+ mostEquilibratedConfig.first = NEQUI;
}
void hypercache::finalize() {
C->readConfig(readnewconfig_nonex, nequileftReadConfig_nonex, &parentConfigs);
if (readnewconfig_nonex) {
- cout << ":" << nequileftReadConfig_nonex << endl;
nequileft = nequileftReadConfig_nonex;
readAtLeastOneConfig = true;
}
free(tmpconfig);
}
+ /* storing most equilibrated config */
+ if ( nequileft < mostEquilibratedConfig.first && readAtLeastOneConfig ) {
+ *log << "HYPERCACHE: Storing a copy of so far most equilibrated config with nequileft = " << nequileft << endl << flush;
+ mostEquilibratedConfig.first = nequileft;
+ memcpy(mostEquilibratedConfig.second, C->getConfigMem(), C->getConfigSize());
+ }
+
+
+ /* injecting back most equilibrated config if nothing could be used anymore */
+ if ( nequileft > 0 && mostEquilibratedConfig.first < nequileft ) {
+ *log << "HYPERCACHE: Injecting back most equilibrated stored config with nequileft = " << mostEquilibratedConfig.first << endl << flush;
+ nequileft = mostEquilibratedConfig.first;
+ memcpy(C->getConfigMem(), mostEquilibratedConfig.second, C->getConfigSize());
+ readAtLeastOneConfig = false;
+ }
+
return readAtLeastOneConfig;
}
static void initC(const string& cacheid, const int& nequi, const int& nskip, const string& datadir,
char **configmem, const int& configMemSize, const int& cachemode=CACHE_MODE_FULL, ostream *_log=NULL) {
initCache(&C, cacheid, nequi, nskip, datadir, configmem, configMemSize, cachemode, _log);
+ mostEquilibratedConfig.second = new char[configMemSize];
}
static int getNEquiLeft() { return nequileft; }
static int NEQUI;
static int NSKIP;
static int nequileft;
+
+ static pair<int, char*> mostEquilibratedConfig;
};
#endif