diff options
author | mfederico <mfederico@1f5c12ca-751b-0410-a591-d2e778427230> | 2006-08-14 06:49:35 +0400 |
---|---|---|
committer | mfederico <mfederico@1f5c12ca-751b-0410-a591-d2e778427230> | 2006-08-14 06:49:35 +0400 |
commit | d0a573bc517d11deebea1bafbb91bacc5dfa8ab5 (patch) | |
tree | 373d199a3731e58a3ba34eaec8963a1b1d2e5334 /irstlm | |
parent | 7cc3d890b197e51fd1c44f7443349158e5854133 (diff) |
added tracing of cache usage
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@705 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'irstlm')
-rw-r--r-- | irstlm/src/lmtable.cpp | 16 | ||||
-rw-r--r-- | irstlm/src/lmtable.h | 26 |
2 files changed, 32 insertions, 10 deletions
diff --git a/irstlm/src/lmtable.cpp b/irstlm/src/lmtable.cpp index 05593a976..8a462f0d5 100644 --- a/irstlm/src/lmtable.cpp +++ b/irstlm/src/lmtable.cpp @@ -50,7 +50,7 @@ lmtable::lmtable(){ memset(NumCenters, 0, sizeof(NumCenters)); max_cache_lev=0; - for (int i=0;i<=maxlev;i++) lmtcache[i]=NULL; + for (int i=0;i<=LMTMAXLEV+1;i++) lmtcache[i]=NULL; probcache=NULL; statecache=NULL; @@ -825,17 +825,23 @@ double lmtable::lprob(ngram ong){ //return log10 probsL use cache memory -double lmtable::clprob(ngram ong){ - +double lmtable::clprob(ngram ong){ if (ong.size==0) return 0.0; if (ong.size>maxlev) ong.size=maxlev; double logpr; - if (probcache && ong.size==maxlev && probcache->get(ong.wordp(maxlev),(char *)&logpr)) - return logpr; +#ifdef TRACE_CACHE + if (probcache && ong.size==maxlev && sentence_id>0lo){ + *cacheout << sentence_id << " " << ong << "\n"; + } +#endif + + if (probcache && ong.size==maxlev && probcache->get(ong.wordp(maxlev),(char *)&logpr)){ + return logpr; + } logpr=lprob(ong); diff --git a/irstlm/src/lmtable.h b/irstlm/src/lmtable.h index 32a291d45..e2b6bb4e2 100644 --- a/irstlm/src/lmtable.h +++ b/irstlm/src/lmtable.h @@ -26,6 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "dictionary.h" #include "n_gram.h" +#undef TRACE_CACHE + #define LMTMAXLEV 11 #ifndef LMTCODESIZE @@ -140,15 +142,20 @@ class lmtable{ ngramcache* probcache; ngramcache* statecache; int max_cache_lev; - + public: +#ifdef TRACE_CACHE + std::fstream* cacheout; + int sentence_id; +#endif + dictionary *dict; // dictionary lmtable(); ~lmtable(){ - for (int i=2;i<=max_cache_lev;i++) + for (int i=2;i<=LMTMAXLEV;i++) if (lmtcache[i]){ std::cerr << i <<"-gram cache: "; lmtcache[i]->stat(); delete lmtcache[i]; @@ -157,6 +164,11 @@ public: if (probcache){ std::cerr << "Prob Cache: "; probcache->stat(); delete probcache; +#if TRACE_CACHE + cacheout->close(); + delete cacheout; +#endif + } if (statecache){ std::cerr << "State Cache: "; statecache->stat(); @@ -176,19 +188,23 @@ public: void init_probcache(){ assert(probcache==NULL); - probcache=new ngramcache(maxlev,sizeof(double),1000000); + probcache=new ngramcache(maxlev,sizeof(double),200000); +#ifdef TRACE_CACHE + cacheout=new std::fstream("/tmp/tracecache",std::ios::out); + sentence_id=0; +#endif } void init_statecache(){ assert(statecache==NULL); - statecache=new ngramcache(maxlev-1,sizeof(char *),200000); + statecache=new ngramcache(maxlev-1,sizeof(char *),100000); } void init_lmtcaches(int uptolev){ max_cache_lev=uptolev; for (int i=2;i<=max_cache_lev;i++){ assert(lmtcache[i]==NULL); - lmtcache[i]=new ngramcache(i,sizeof(char *),2000000); + lmtcache[i]=new ngramcache(i,sizeof(char *),200000); } } |