From: Alex Schmidt Date: Fri, 22 Mar 2013 13:46:19 +0000 (+0100) Subject: implemented partial virtual equilibration. X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/commitdiff_plain/b3e5f37ca561e20879f984d53db68adae89ef413 implemented partial virtual equilibration. --- diff --git a/configcache.cpp b/configcache.cpp index 1095775..a3490ad 100644 --- a/configcache.cpp +++ b/configcache.cpp @@ -172,9 +172,12 @@ void * configcache::getHeader(const string& headerid) { return NULL; } -bool configcache::readConfig(vector *excludeFileHashes) -{ - if(DATADIR == "" || MODE == CACHE_MODE_DISABLED) return false; +/* returns number of equilibration-steps left */ +int configcache::readConfig(vector *excludeFileHashes) +{ + int nequileft = NEQUI; + + if(DATADIR == "" || MODE == CACHE_MODE_DISABLED) return nequileft; if(refetchDataFiles){ refetchDataFiles = false; @@ -183,7 +186,7 @@ bool configcache::readConfig(vector *excludeFileHashes) while(true) { - if( (!inFile.is_open()) && inFiles.size() == 0 ) return false; + if( (!inFile.is_open()) && inFiles.size() == 0 ) return nequileft; while( (!inFile.is_open()) && inFiles.size() > 0 ) { bool excludethisfile=false; @@ -221,13 +224,17 @@ bool configcache::readConfig(vector *excludeFileHashes) for (int iskip=0; iskip < (NEQUI-openFileDesc.nequi)/openFileDesc.nskip; iskip++) { if( readFullBlock(tmpConfig, configSize) != configSize || ! inFile.is_open() ) break; + else if ( (NEQUI-openFileDesc.nequi) - (iskip+1)*openFileDesc.nskip < nequileft ) { + memcpy(configMem, tmpConfig, configSize); + nequileft = (NEQUI-openFileDesc.nequi) - (iskip+1)*openFileDesc.nskip; + } } } if( readFullBlock(tmpConfig, configSize) == configSize && inFile.is_open() ) { memcpy(configMem, tmpConfig, configSize); - return true; + return -1; } else { if(out) *out->log << "CCACHE: Could not read configuration. Closing dat-file: " << openFileDesc.filename << endl << flush; diff --git a/configcache.h b/configcache.h index 17c8606..f07ccf5 100644 --- a/configcache.h +++ b/configcache.h @@ -38,7 +38,7 @@ class configcache{ ~configcache(); configcache(const string& cacheid, const int& nequi, const int& nskip, const string& datadir, char **configmem, const int& configMemSize, const int& cachemode=CACHE_MODE_FULL, writeout *out_a=NULL); - bool readConfig(vector *excludeFileHashes=NULL); + int readConfig(vector *excludeFileHashes=NULL); void writeConfig(); void addPara(const string& parid, const double& val=0); void setPara(const string& parid, const double& value); diff --git a/hypercache.cpp b/hypercache.cpp index b025ba6..2d38b21 100644 --- a/hypercache.cpp +++ b/hypercache.cpp @@ -71,10 +71,12 @@ string hypercache::fileOfPath(const string& dressedfile) { return dressedfile.substr(dressedfile.find_last_of("\\/")+1); } -bool hypercache::readC() { - bool readret; +int hypercache::readC() { + int readret; - if ( readret = C->readConfig(&parentConfigs) ) + readret = C->readConfig(&parentConfigs); + + if ( readret == -1 ) activeCFile = fileOfPath(C->getInFileName()); else activeCFile = ""; @@ -96,15 +98,17 @@ void hypercache::writeO() { O->writeConfig(); } -bool hypercache::readO() { - bool readret; +int hypercache::readO() { + int readret; + + readret = O->readConfig(); - if ( readret = O->readConfig() ) { + if ( readret == -1 ) { unsigned long *parentconfig = (unsigned long*)O->getHeader("concurrent_cfile"); if ( parentconfig != NULL ) addParentConfig(parentconfig); } - + return readret; } diff --git a/hypercache.h b/hypercache.h index 11e1565..f7c039c 100644 --- a/hypercache.h +++ b/hypercache.h @@ -20,8 +20,8 @@ class hypercache { static void addPara(const string& parid, const double& val=0); static void setPara(const string& parid, const double& value); - static bool readO(); - static bool readC(); + static int readO(); + static int readC(); static void writeO(); static void writeC(); static void writeHeaderO(const string& headerid, char *header, long unsigned int size) { O->writeHeader(headerid, header, size); }