libpredict_integration: add iteration by processes_per_processor
This commit is contained in:
@@ -319,7 +319,6 @@ double runLibpredictCalc(const vector<size_t>& topology,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void runPredictScheme(SgProject& project,
|
void runPredictScheme(SgProject& project,
|
||||||
vector<vector<size_t>>& topologies,
|
|
||||||
const vector<ParallelRegion*>& parallelRegions,
|
const vector<ParallelRegion*>& parallelRegions,
|
||||||
map<string, vector<LoopGraph*>>& loopGraph,
|
map<string, vector<LoopGraph*>>& loopGraph,
|
||||||
map<string, vector<Messages>>& SPF_messages)
|
map<string, vector<Messages>>& SPF_messages)
|
||||||
@@ -363,16 +362,14 @@ void runPredictScheme(SgProject& project,
|
|||||||
PrecomputedLibpredictParams precomputedParams = precomputeLibpredictParams(
|
PrecomputedLibpredictParams precomputedParams = precomputeLibpredictParams(
|
||||||
project, parallelRegions, loopGraph, templateIdMapping);
|
project, parallelRegions, loopGraph, templateIdMapping);
|
||||||
|
|
||||||
// iterating through topologies to find most optimal one
|
// iterating through topologies and processes_per_processor to find most optimal one
|
||||||
topologies = vector<vector<size_t>>();
|
|
||||||
if (maxSizeDist) {
|
if (maxSizeDist) {
|
||||||
if (maxSizeDist > 4) {
|
if (maxSizeDist > 4) {
|
||||||
maxSizeDist = 4;
|
maxSizeDist = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize cluster
|
// Initialize cluster
|
||||||
int procCount = 0;
|
libpredict::RetInitCluster retInitCluster = libpredict::InitCluster(clusterConfStr);
|
||||||
libpredict::RetInitCluster retInitCluster = libpredict::InitCluster(clusterConfStr, procCount);
|
|
||||||
|
|
||||||
if (retInitCluster != libpredict::INIT_CLUSTER_SUCCESS) {
|
if (retInitCluster != libpredict::INIT_CLUSTER_SUCCESS) {
|
||||||
__spf_print(1, "ERROR: Failed to initialize libpredict cluster with config: %s, return code: %d\n", clusterConfStr.c_str(), (int)retInitCluster);
|
__spf_print(1, "ERROR: Failed to initialize libpredict cluster with config: %s, return code: %d\n", clusterConfStr.c_str(), (int)retInitCluster);
|
||||||
@@ -385,54 +382,78 @@ void runPredictScheme(SgProject& project,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t n1 = 2; n1 <= procCount; ++n1) {
|
vector<size_t> best;
|
||||||
for (size_t n2 = 1; n2 <= n1 && n1 * n2 <= procCount; ++n2) {
|
double bestTime = std::numeric_limits<double>::max();
|
||||||
if (n2 != 1 && maxSizeDist < 2 || n2 == 1 && maxSizeDist == 2) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t n3 = 1; n3 <= n2 && n1 * n2 * n3 <= procCount; ++n3) {
|
for (size_t processes_per_processor = 1; processes_per_processor <= 16; ++processes_per_processor) {
|
||||||
if (n3 != 1 && maxSizeDist < 3 || n3 == 1 && maxSizeDist == 3) {
|
int procCount = 0;
|
||||||
|
libpredict::RetInitMapping retInitMapping = libpredict::InitMapping(processes_per_processor, procCount);
|
||||||
|
|
||||||
|
if (retInitMapping != libpredict::INIT_MAPPING_SUCCESS) {
|
||||||
|
__spf_print(1, "ERROR: Failed to initialize libpredict mapping with processes_per_processor: %zu, return code: %d\n",
|
||||||
|
processes_per_processor, (int)retInitMapping);
|
||||||
|
|
||||||
|
std::wstring messageR, messageE;
|
||||||
|
__spf_printToLongBuf(messageE, L"Failed to initialize libpredict mapping with processes_per_processor: %zu, return code: %d",
|
||||||
|
processes_per_processor, (int)retInitMapping);
|
||||||
|
__spf_printToLongBuf(messageR, R211);
|
||||||
|
getObjectForFileFromMap(clusterConfStr.c_str(), SPF_messages).push_back(Messages(ERROR, 1, messageR, messageE, 1068));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (procCount == 0) {
|
||||||
|
break; // No more processors available
|
||||||
|
}
|
||||||
|
|
||||||
|
__spf_print(1, "Calculate with processes_per_processor=%zu, procCount=%d\n", processes_per_processor, procCount);
|
||||||
|
|
||||||
|
for (size_t n1 = 2; n1 <= procCount; ++n1) {
|
||||||
|
for (size_t n2 = 1; n2 <= n1 && n1 * n2 <= procCount; ++n2) {
|
||||||
|
if (n2 != 1 && maxSizeDist < 2 || n2 == 1 && maxSizeDist == 2) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t n4 = 1; n4 <= n3 && n1 * n2 * n3 * n4 <= procCount; ++n4) {
|
for (size_t n3 = 1; n3 <= n2 && n1 * n2 * n3 <= procCount; ++n3) {
|
||||||
if (n4 != 1 && maxSizeDist < 4 || n4 == 1 && maxSizeDist == 4) {
|
if (n3 != 1 && maxSizeDist < 3 || n3 == 1 && maxSizeDist == 3) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
topologies.push_back(vector<size_t>{n1, n2, n3, n4});
|
for (size_t n4 = 1; n4 <= n3 && n1 * n2 * n3 * n4 <= procCount; ++n4) {
|
||||||
|
if (n4 != 1 && maxSizeDist < 4 || n4 == 1 && maxSizeDist == 4) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<size_t> topology = {n1, n2, n3, n4};
|
||||||
|
double currTime = runLibpredictCalc(topology, clusterConfStr, precomputedParams, SPF_messages);
|
||||||
|
|
||||||
|
string outStr = "";
|
||||||
|
for (const auto& elem : topology) {
|
||||||
|
outStr += std::to_string(elem) + " ";
|
||||||
|
}
|
||||||
|
__spf_print(1, "topology %s has time %f\n", outStr.c_str(), currTime);
|
||||||
|
|
||||||
|
if (currTime == -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currTime < bestTime) {
|
||||||
|
bestTime = currTime;
|
||||||
|
best = topology;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<size_t> best;
|
if (!best.empty()) {
|
||||||
double bestTime = std::numeric_limits<double>::max();
|
string outStr;
|
||||||
for (auto& topology : topologies) {
|
for (const auto& elem : best) {
|
||||||
double currTime = runLibpredictCalc(topology, clusterConfStr, precomputedParams, SPF_messages);
|
|
||||||
|
|
||||||
string outStr = "";
|
|
||||||
for (const auto& elem : topology) {
|
|
||||||
outStr += std::to_string(elem) + " ";
|
outStr += std::to_string(elem) + " ";
|
||||||
}
|
}
|
||||||
__spf_print(1, "topology %s has time %f\n", outStr.c_str(), currTime);
|
|
||||||
|
|
||||||
if (currTime == -1) {
|
__spf_print(1, "best topology %s with time %f\n", outStr.c_str(), bestTime);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currTime < bestTime) {
|
|
||||||
bestTime = currTime;
|
|
||||||
best = topology;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
string outStr;
|
|
||||||
for (const auto& elem : best) {
|
|
||||||
outStr += std::to_string(elem) + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
__spf_print(1, "best topology %s with time %f\n", outStr.c_str(), bestTime);
|
|
||||||
} else {
|
} else {
|
||||||
__spf_print(1, "impossible to calculate best topology: project does not contain distribution directives\n");
|
__spf_print(1, "impossible to calculate best topology: project does not contain distribution directives\n");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ PrecomputedLibpredictParams precomputeLibpredictParams(
|
|||||||
const std::map<size_t, size_t>& templateIdMapping);
|
const std::map<size_t, size_t>& templateIdMapping);
|
||||||
|
|
||||||
void runPredictScheme(SgProject& project,
|
void runPredictScheme(SgProject& project,
|
||||||
std::vector<std::vector<size_t>>& topologies,
|
|
||||||
const std::vector<ParallelRegion*>& parallelRegions,
|
const std::vector<ParallelRegion*>& parallelRegions,
|
||||||
std::map<std::string, std::vector<LoopGraph*>>& loopGraph,
|
std::map<std::string, std::vector<LoopGraph*>>& loopGraph,
|
||||||
std::map<std::string, std::vector<Messages>>& SPF_messages);
|
std::map<std::string, std::vector<Messages>>& SPF_messages);
|
||||||
|
|||||||
@@ -1733,7 +1733,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (curr_regime == PREDICT_SCHEME)
|
else if (curr_regime == PREDICT_SCHEME)
|
||||||
runPredictScheme(project, topologies, parallelRegions, loopGraph, SPF_messages);
|
runPredictScheme(project, parallelRegions, loopGraph, SPF_messages);
|
||||||
else if (curr_regime == CREATE_INTER_TREE)
|
else if (curr_regime == CREATE_INTER_TREE)
|
||||||
{
|
{
|
||||||
if (keepFiles)
|
if (keepFiles)
|
||||||
|
|||||||
@@ -519,6 +519,8 @@ static const wchar_t* R208 = L"R208:";
|
|||||||
static const wchar_t* R209 = L"R209:";
|
static const wchar_t* R209 = L"R209:";
|
||||||
//1067
|
//1067
|
||||||
static const wchar_t* R210 = L"R210:";
|
static const wchar_t* R210 = L"R210:";
|
||||||
|
//1068
|
||||||
|
static const wchar_t* R211 = L"R211:";
|
||||||
|
|
||||||
//2001
|
//2001
|
||||||
static const wchar_t *R94 = L"R94:";
|
static const wchar_t *R94 = L"R94:";
|
||||||
|
|||||||
@@ -196,6 +196,8 @@ R208 = "Ошибка распределения массива '%s' с помо
|
|||||||
R209 = "Ошибка выравнивания массива '%s' с массивом '%s' с помощью libpredict, код возврата: %d"
|
R209 = "Ошибка выравнивания массива '%s' с массивом '%s' с помощью libpredict, код возврата: %d"
|
||||||
//1067
|
//1067
|
||||||
R210 = "Ошибка обработки shadow_renew для массива '%s' с помощью libpredict, код возврата: %d"
|
R210 = "Ошибка обработки shadow_renew для массива '%s' с помощью libpredict, код возврата: %d"
|
||||||
|
//1068
|
||||||
|
R211 = "Ошибка инициализации отображения libpredict с processes_per_processor: %zu, код возврата: %d"
|
||||||
|
|
||||||
//2001
|
//2001
|
||||||
R94 = "Невозможно автоматически преобразовать данное присваивание к циклу"
|
R94 = "Невозможно автоматически преобразовать данное присваивание к циклу"
|
||||||
|
|||||||
Reference in New Issue
Block a user