50 #ifdef HAVE_MUELU_EPETRAEXT
57 #include <arpa/inet.h>
77 const std::string& levelName = it->first;
80 if (inList.
isSublist(levelName) && ((levelName.find(
"level ") == 0 && levelName.size() > 6) || levelName.find(
"user data") == 0)) {
81 int levelID = strtol(levelName.substr(6).c_str(), 0, 0);
83 if(levelName.find(
"user data") == std::string::npos) {
85 levelID = strtol(levelName.substr(6).c_str(), 0, 0);
86 if (maxLevel < levelID)
93 const std::string& name = it2->first;
94 if (name ==
"A" || name ==
"P" || name ==
"R" || name==
"M" || name ==
"Mdiag" || name ==
"K" || name ==
"Nullspace" || name ==
"Coordinates"
95 || name ==
"Node Comm"
96 #ifdef HAVE_MUELU_INTREPID2
97 || name ==
"pcoarsen: element to node map"
103 #ifdef HAVE_MUELU_MATLAB
117 serialList.
setEntry(it->first, it->second);
128 char* buf = (
char*) malloc(stream.size() + 1);
129 strcpy(buf, stream.c_str());
130 char* token = strtok(buf, delimChars);
140 char* tokStart = token;
141 char* tokEnd = token + strlen(token) - 1;
142 while(*tokStart ==
' ' && tokStart < tokEnd)
144 while(*tokEnd ==
' ' && tokStart < tokEnd)
147 if(tokStart < tokEnd)
149 std::string finishedToken(tokStart, tokEnd - tokStart);
150 tokenList.push_back(finishedToken);
152 token = strtok(NULL, delimChars);
160 char* str = (
char*) malloc(name.length() + 1);
161 strcpy(str, name.c_str());
163 char* firstWord = strtok(str,
" ");
168 char* secondWord = strtok(NULL,
" ");
173 char* thirdWord = strtok(NULL,
" ");
179 char* tolowerIt = firstWord;
182 *tolowerIt = (char)
tolower(*tolowerIt);
186 if(strstr(firstWord,
"matrix") ||
187 strstr(firstWord,
"multivector") ||
188 strstr(firstWord,
"map") ||
189 strstr(firstWord,
"ordinalvector") ||
190 strstr(firstWord,
"int") ||
191 strstr(firstWord,
"scalar") ||
192 strstr(firstWord,
"double") ||
193 strstr(firstWord,
"complex") ||
194 strstr(firstWord,
"string"))
210 char* str = (
char*) malloc(name.length() + 1);
211 strcpy(str, name.c_str());
213 char* firstWord = strtok(str,
" ");
218 char* secondWord = strtok(NULL,
" ");
223 char* thirdWord = strtok(NULL,
" ");
229 char* tolowerIt = firstWord;
232 *tolowerIt = (char)
tolower(*tolowerIt);
236 if(strstr(firstWord,
"matrix") ||
237 strstr(firstWord,
"multivector") ||
238 strstr(firstWord,
"map") ||
239 strstr(firstWord,
"ordinalvector") ||
240 strstr(firstWord,
"int") ||
241 strstr(firstWord,
"scalar") ||
242 strstr(firstWord,
"double") ||
243 strstr(firstWord,
"complex") ||
244 strstr(firstWord,
"string") ||
245 strstr(firstWord,
"array<go>") ||
246 strstr(firstWord,
"array<lo>") ||
247 strstr(firstWord,
"arrayrcp<lo>") ||
248 strstr(firstWord,
"arrayrcp<go>"))
265 int numRanks = baseComm->getSize();
266 if(numRanks == 1) {NodeId = baseComm->getRank();
return baseComm;}
269 char hostname[MPI_MAX_PROCESSOR_NAME];
271 MPI_Get_processor_name(hostname,&len);
272 struct hostent * host = gethostbyname(hostname);
273 int myaddr = (int) htonl(inet_network(inet_ntoa(*(
struct in_addr *)host->h_addr)));
276 std::vector<int> addressList(numRanks);
277 Teuchos::gatherAll(*baseComm,1,&myaddr,numRanks,&addressList[0]);
280 std::sort(addressList.begin(),addressList.end());
284 for(
int i=0, prev=addressList[0]; i<numRanks && prev != myaddr; i++) {
285 if(prev != addressList[i]) {
286 prev = addressList[i];
296 if(reductionFactor != 1) {
299 int coresPerNode = 0;
300 for(
int i=0, prev=addressList[0]; i<numRanks; i++) {
301 if(prev != addressList[i]) {
302 prev = addressList[i];
303 coresPerNode = std::max(i - lastI, coresPerNode);
307 coresPerNode = std::max(numRanks - lastI, coresPerNode);
310 if(coresPerNode % reductionFactor != 0)
311 throw std::runtime_error(
"Reduction factor does not evently divide # cores per node");
312 int reducedCPN = coresPerNode / reductionFactor;
313 int nodeDivision = newComm->getRank() / reducedCPN;
315 NodeId = numNodes * reductionFactor + nodeDivision;
316 newComm = baseComm->split(NodeId,baseComm->getRank());
321 NodeId = baseComm->getRank();
ConstIterator end() const
Teuchos::RCP< const Teuchos::Comm< int > > GenerateNodeComm(RCP< const Teuchos::Comm< int > > &baseComm, int &NodeId, const int reductionFactor)
std::string tolower(const std::string &str)
bool IsParamMuemexVariable(const std::string &name)
ParameterList & setEntry(const std::string &name, const ParameterEntry &entry)
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)
long ExtractNonSerializableData(const Teuchos::ParameterList &inList, Teuchos::ParameterList &serialList, Teuchos::ParameterList &nonSerialList)