15 #ifdef HAVE_MUELU_EPETRAEXT
25 #include <arpa/inet.h>
37 const std::string& levelName = inListEntry->first;
40 if (inList.
isSublist(levelName) && ((levelName.find(
"level ") == 0 && levelName.size() > 6) || levelName.find(
"user data") == 0)) {
41 int levelID = strtol(levelName.substr(6).c_str(), 0, 0);
43 if (levelName.find(
"user data") == std::string::npos) {
45 levelID = strtol(levelName.substr(6).c_str(), 0, 0);
46 if (maxLevel < levelID)
53 const std::string& name = levelListEntry->first;
54 if (name ==
"A" || name ==
"P" || name ==
"R" || name ==
"M" || name ==
"Mdiag" || name ==
"K" || name ==
"Nullspace" || name ==
"Coordinates" || name ==
"D0" || name ==
"Dk_1" || name ==
"Dk_2" || name ==
"Mk_one" || name ==
"Mk_1_one" || name ==
"M1_beta" || name ==
"M1_alpha" || name ==
"invMk_1_invBeta" || name ==
"invMk_2_invAlpha" || name ==
"M1" || name ==
"Ms" || name ==
"M0inv" || name ==
"Pnodal" || name ==
"NodeMatrix" || name ==
"NodeAggMatrix" || name ==
"Node Comm" || name ==
"DualNodeID2PrimalNodeID"
55 #ifdef HAVE_MUELU_INTREPID2
56 || name ==
"pcoarsen: element to node map"
58 || name ==
"output stream") {
59 nonSerialList.
sublist(levelName).
setEntry(name, levelListEntry->second);
61 #ifdef HAVE_MUELU_MATLAB
63 nonSerialList.
sublist(levelName).
setEntry(name, levelListEntry->second);
67 nonSerialList.
sublist(levelName).
setEntry(name, levelListEntry->second);
74 serialList.
setEntry(inListEntry->first, inListEntry->second);
84 char* buf = (
char*)malloc(stream.size() + 1);
85 strcpy(buf, stream.c_str());
86 char* token = strtok(buf, delimChars);
94 char* tokStart = token;
95 char* tokEnd = token + strlen(token) - 1;
96 while (*tokStart ==
' ' && tokStart < tokEnd)
98 while (*tokEnd ==
' ' && tokStart < tokEnd)
101 if (tokStart < tokEnd) {
102 std::string finishedToken(tokStart, tokEnd - tokStart);
103 tokenList.push_back(finishedToken);
105 token = strtok(NULL, delimChars);
112 char* str = (
char*)malloc(name.length() + 1);
113 strcpy(str, name.c_str());
115 char* firstWord = strtok(str,
" ");
120 char* secondWord = strtok(NULL,
" ");
125 char* thirdWord = strtok(NULL,
" ");
131 char* tolowerIt = firstWord;
133 *tolowerIt = (char)
tolower(*tolowerIt);
137 if (strstr(firstWord,
"matrix") ||
138 strstr(firstWord,
"multivector") ||
139 strstr(firstWord,
"map") ||
140 strstr(firstWord,
"ordinalvector") ||
141 strstr(firstWord,
"int") ||
142 strstr(firstWord,
"scalar") ||
143 strstr(firstWord,
"double") ||
144 strstr(firstWord,
"complex") ||
145 strstr(firstWord,
"string"))
158 char* str = (
char*)malloc(name.length() + 1);
159 strcpy(str, name.c_str());
161 char* firstWord = strtok(str,
" ");
166 char* secondWord = strtok(NULL,
" ");
171 char* thirdWord = strtok(NULL,
" ");
177 char* tolowerIt = firstWord;
179 *tolowerIt = (char)
tolower(*tolowerIt);
183 if (strstr(firstWord,
"matrix") ||
184 strstr(firstWord,
"multivector") ||
185 strstr(firstWord,
"map") ||
186 strstr(firstWord,
"ordinalvector") ||
187 strstr(firstWord,
"int") ||
188 strstr(firstWord,
"scalar") ||
189 strstr(firstWord,
"double") ||
190 strstr(firstWord,
"complex") ||
191 strstr(firstWord,
"string") ||
192 strstr(firstWord,
"array<go>") ||
193 strstr(firstWord,
"array<lo>") ||
194 strstr(firstWord,
"arrayrcp<lo>") ||
195 strstr(firstWord,
"arrayrcp<go>"))
209 int numRanks = baseComm->getSize();
211 NodeId = baseComm->getRank();
216 char hostname[MPI_MAX_PROCESSOR_NAME];
218 MPI_Get_processor_name(hostname, &len);
219 struct hostent* host = gethostbyname(hostname);
220 int myaddr = (int)inet_addr(inet_ntoa(*(
struct in_addr*)host->h_addr));
223 std::vector<int> addressList(numRanks);
224 Teuchos::gatherAll(*baseComm, 1, &myaddr, numRanks, &addressList[0]);
227 std::sort(addressList.begin(), addressList.end());
231 for (
int i = 0, prev = addressList[0]; i < numRanks && prev != myaddr; i++) {
232 if (prev != addressList[i]) {
233 prev = addressList[i];
243 if (reductionFactor != 1) {
246 int coresPerNode = 0;
247 for (
int i = 0, prev = addressList[0]; i < numRanks; i++) {
248 if (prev != addressList[i]) {
249 prev = addressList[i];
250 coresPerNode = std::max(i - lastI, coresPerNode);
254 coresPerNode = std::max(numRanks - lastI, coresPerNode);
257 if (coresPerNode % reductionFactor != 0)
258 throw std::runtime_error(
"Reduction factor does not evently divide # cores per node");
259 int reducedCPN = coresPerNode / reductionFactor;
260 int nodeDivision = newComm->getRank() / reducedCPN;
262 NodeId = numNodes * reductionFactor + nodeDivision;
263 newComm = baseComm->split(NodeId, baseComm->getRank());
268 NodeId = baseComm->getRank();
ParameterList & setEntry(const std::string &name, U &&entry)
ConstIterator end() const
std::string tolower(const std::string &str)
bool IsParamMuemexVariable(const std::string &name)
bool isSublist(const std::string &name) const
params_t::ConstIterator ConstIterator
ConstIterator begin() const
bool IsParamValidVariable(const std::string &name)
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
void TokenizeStringAndStripWhiteSpace(const std::string &stream, std::vector< std::string > &tokenList, const char *delimChars)
Teuchos::RCP< const Teuchos::Comm< int > > GenerateNodeComm(RCP< const Teuchos::Comm< int > > &baseComm, int &NodeId, const int reductionFactor)
long ExtractNonSerializableData(const Teuchos::ParameterList &inList, Teuchos::ParameterList &serialList, Teuchos::ParameterList &nonSerialList)
Extract non-serializable data from level-specific sublists and move it to a separate parameter list...