----------------------------------------------------------------------
| 107 | |
| 108 | // ---------------------------------------------------------------------- |
| 109 | void RegionsProfStats::SyncFNamesAndNumbers() { |
| 110 | if(mFNameNumbersPerProc.size() == 0) { |
| 111 | return; |
| 112 | } |
| 113 | std::set<std::string> localNames; |
| 114 | for(int p(0); p < dataNProcs; ++p) { |
| 115 | std::map<std::string, int>::iterator mfnnit; |
| 116 | for(mfnnit = mFNameNumbersPerProc[p].begin(); |
| 117 | mfnnit != mFNameNumbersPerProc[p].end(); ++mfnnit) |
| 118 | { |
| 119 | localNames.insert(mfnnit->first); |
| 120 | } |
| 121 | } |
| 122 | Vector<std::string> localStrings, syncedStrings; |
| 123 | bool alreadySynced; |
| 124 | for(std::set<std::string>::iterator lsit = localNames.begin(); |
| 125 | lsit != localNames.end(); ++lsit) |
| 126 | { |
| 127 | localStrings.push_back(*lsit); |
| 128 | } |
| 129 | |
| 130 | amrex::SyncStrings(localStrings, syncedStrings, alreadySynced); |
| 131 | fnameRemap.resize(dataNProcs); |
| 132 | |
| 133 | for(int p(0); p < dataNProcs; ++p) { |
| 134 | fnameRemap[p].resize(syncedStrings.size(), -1); // -1 are names not on proc p |
| 135 | Vector<int> foundStrings(syncedStrings.size(), -1); |
| 136 | std::map<std::string, int>::iterator mfnnit; |
| 137 | for(mfnnit = mFNameNumbersPerProc[p].begin(); |
| 138 | mfnnit != mFNameNumbersPerProc[p].end(); ++mfnnit) |
| 139 | { |
| 140 | const std::string &findName = mfnnit->first; |
| 141 | int localIndex(mfnnit->second); |
| 142 | for(int n(0); n < syncedStrings.size(); ++n) { |
| 143 | if(findName == syncedStrings[n]) { |
| 144 | fnameRemap[p][localIndex] = n; |
| 145 | foundStrings[n] = n; |
| 146 | //cout << " p fname localIndex n = " << p << " " << findName << " " |
| 147 | //<< localIndex << " " << n << endl; |
| 148 | } |
| 149 | } |
| 150 | } |
| 151 | for(int n(0); n < foundStrings.size(); ++n) { // fill in unfound strings |
| 152 | if(foundStrings[n] < 0) { |
| 153 | for(int ii(0); ii < fnameRemap[p].size(); ++ii) { |
| 154 | if(fnameRemap[p][ii] < 0) { |
| 155 | fnameRemap[p][ii] = n; |
| 156 | break; |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | // ---- the index here is the remapped one, must access numbersToFName with |
| 164 | // ---- the data processors local index in fnameRemap |
| 165 | numbersToFName = syncedStrings; |
| 166 |