00001 #ifndef MST_HEAP_CACHE_CPP
00002 #define MST_HEAP_CACHE_CPP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "MSTHeapCache.h"
00038
00039 MSTHeapCache::MSTHeapCache(const int totalESTCount,
00040 const int startESTidx,
00041 const int numOwnESTs,
00042 const ESTAnalyzer *estAnalyzer,
00043 const bool repopulate,
00044 const int maxCachePerEST) :
00045 MSTCache(totalESTCount, startESTidx, numOwnESTs, estAnalyzer,
00046 repopulate, maxCachePerEST),
00047 prunedEntries(0), cache(GreaterCachedESTInfo(estAnalyzer)) {
00048
00049 }
00050
00051 void
00052 MSTHeapCache::pruneCaches(const int estIdxAdded,
00053 std::vector<int>& repopulateList,
00054 const bool prefixListSize) {
00055
00056
00057 repopulateList.clear();
00058 if (prefixListSize) {
00059
00060 repopulateList.push_back(0);
00061 }
00062
00063 nodesAdded[estIdxAdded] = true;
00064
00065
00066
00067 while (!cache.empty() && (isESTinMST(cache.top().estIdx))) {
00068 popCache();
00069 }
00070 }
00071
00072 void
00073 MSTHeapCache::mergeList(const int UNREFERENCED_PARAMETER(estIdx),
00074 const SMList& list) {
00075
00076 for(size_t i = 0; (i < list.size()); i++) {
00077 cache.push(list[i]);
00078 }
00079 }
00080
00081 void
00082 MSTHeapCache::getBestEntry(int& srcESTidx, int& destESTidx,
00083 float& metric, int & alignmentData,
00084 int& directionData) const {
00085
00086 srcESTidx= destESTidx = alignmentData = directionData = -1;
00087 metric = analyzer->getInvalidMetric();
00088
00089 if (!cache.empty()) {
00090
00091 const CachedESTInfo& entry = cache.top();
00092 srcESTidx = entry.refESTidx;
00093 destESTidx = entry.estIdx;
00094 metric = entry.metric;
00095 alignmentData = entry.alignmentData;
00096 directionData = entry.directionData;
00097 }
00098 }
00099
00100 void
00101 MSTHeapCache::displayStats(std::ostream &os, const int MyRank) const {
00102 const int totalEntries = cache.size() + prunedEntries;
00103
00104 os << "Statistics on process with Rank " << MyRank << "\n"
00105 << "-------------------------------------------\n"
00106 << " #ESTs entries managed : " << totalEntries << "\n"
00107 << " Total remaining entries : " << cache.size() << "\n"
00108 << " #Pruned entries : " << prunedEntries
00109 << std::endl;
00110 }
00111
00112 void
00113 MSTHeapCache::popCache() {
00114
00115 cache.pop();
00116
00117 prunedEntries++;
00118 }
00119
00120 #endif