MCPcopy Create free account
hub / github.com/SeisSol/SeisSol / checkEnvVariables

Method checkEnvVariables

src/Parallel/Pin.cpp:148–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148void Pinning::checkEnvVariables() {
149#ifndef __APPLE__
150 const auto rank = MPI::mpi.rank();
151 if (const char* envVariable = std::getenv("SEISSOL_FREE_CPUS_MASK")) {
152 auto parsedResult = seissol::IntegerMaskParser::parse(std::string(envVariable));
153 if (parsedResult) {
154 parsedFreeCPUsMask = parsedResult.value();
155
156 bool isMaskGood{true};
157 const auto numLocalProcesses = MPI::mpi.sharedMemMpiSize();
158 if (numLocalProcesses > static_cast<int>(parsedFreeCPUsMask.size())) {
159 logInfo(rank) << "There are more communication (and/or output-writing) threads"
160 << "to pin than locations defined in `SEISSOL_FREE_CPUS_MASK`";
161
162 isMaskGood = false;
163 } else {
164 const auto maxCpuId = get_nprocs();
165 for (auto localProcessId = 0; localProcessId < static_cast<int>(parsedFreeCPUsMask.size());
166 ++localProcessId) {
167 for (auto cpu : parsedFreeCPUsMask[localProcessId]) {
168 if (cpu > maxCpuId) {
169 logInfo(rank) << "Free cpu mask of the local process" << localProcessId
170 << "is out of bounds. CPU/core id" << cpu << "exceeds max. value"
171 << maxCpuId;
172 isMaskGood = false;
173 break;
174 }
175 }
176 }
177 }
178
179 if (isMaskGood) {
180 logInfo(rank) << "Binding free cpus according to `SEISSOL_FREE_CPUS_MASK` env. variable.";
181 } else {
182 logWarning(rank) << "Ignoring `SEISSOL_FREE_CPUS_MASK` env. variable.";
183 logWarning(rank) << "`SEISSOL_FREE_CPUS_MASK` Format:"
184 << "(<int>|<range: int-int>|<list: {int,+}>),+";
185 parsedFreeCPUsMask = IntegerMaskParser::MaskType{};
186 }
187 } else {
188 logWarning(rank) << "Failed to parse `SEISSOL_FREE_CPUS_MASK` env. variable";
189 }
190 }
191#endif // __APPLE__
192}
193
194CpuMask Pinning::getWorkerUnionMask() {
195#ifndef __APPLE__

Callers 1

initMethod · 0.80

Calls 4

rankMethod · 0.80
valueMethod · 0.80
sharedMemMpiSizeMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected