libpredict_integration: add smart search by processes_per_processor

This commit is contained in:
2026-02-22 14:00:16 +03:00
parent d51a5e0301
commit 9c3fa362ec

View File

@@ -383,8 +383,10 @@ void runPredictScheme(SgProject& project,
return;
}
vector<size_t> best;
vector<size_t> bestTopology;
double bestTime = std::numeric_limits<double>::max();
size_t bestProcessesPerProcessor = 0;
int prevProcCount = -1;
for (size_t processes_per_processor = 1; processes_per_processor <= maxCoresCount; ++processes_per_processor) {
int procCount = 0;
@@ -406,6 +408,11 @@ void runPredictScheme(SgProject& project,
break; // No more processors available
}
if (procCount == prevProcCount) {
continue; // Skip with procCount value unchanged for different processes_per_processor
}
prevProcCount = procCount;
__spf_print(1, "Calculate with processes_per_processor=%zu, procCount=%d\n", processes_per_processor, procCount);
for (size_t n1 = 2; n1 <= procCount; ++n1) {
@@ -439,7 +446,8 @@ void runPredictScheme(SgProject& project,
if (currTime < bestTime) {
bestTime = currTime;
best = topology;
bestTopology = topology;
bestProcessesPerProcessor = processes_per_processor;
}
}
}
@@ -447,13 +455,14 @@ void runPredictScheme(SgProject& project,
}
}
if (!best.empty()) {
if (!bestTopology.empty()) {
string outStr;
for (const auto& elem : best) {
for (const auto& elem : bestTopology) {
outStr += std::to_string(elem) + " ";
}
__spf_print(1, "best topology %s with time %f\n", outStr.c_str(), bestTime);
__spf_print(1, "best topology %s with time %f (processes_per_processor=%zu)\n",
outStr.c_str(), bestTime, bestProcessesPerProcessor);
}
} else {
__spf_print(1, "impossible to calculate best topology: project does not contain distribution directives\n");