|
|
@ -76,6 +76,7 @@ Status Edge::InitEdgeCost() {
|
|
|
|
<< ", communication_with_partial_para_: " << cost->communication_with_partial_para_ << ".";
|
|
|
|
<< ", communication_with_partial_para_: " << cost->communication_with_partial_para_ << ".";
|
|
|
|
// refine communication cost calculation for practice
|
|
|
|
// refine communication cost calculation for practice
|
|
|
|
RefineForPracticalCost(cost, true);
|
|
|
|
RefineForPracticalCost(cost, true);
|
|
|
|
|
|
|
|
cost->communication_forward_ = cost->communication_redis_forward_;
|
|
|
|
CostPtrKey ck = {target_output_str, target_input_str};
|
|
|
|
CostPtrKey ck = {target_output_str, target_input_str};
|
|
|
|
CostPtrList cl;
|
|
|
|
CostPtrList cl;
|
|
|
|
cl.push_back(cost);
|
|
|
|
cl.push_back(cost);
|
|
|
@ -160,8 +161,9 @@ CostPtrList Edge::CreateEdgeEliminationCostList(const StrategyPtr &output_st_ptr
|
|
|
|
(void)std::transform(edges.begin(), edges.end(), all_cost_list.begin(), LocalGetCostList);
|
|
|
|
(void)std::transform(edges.begin(), edges.end(), all_cost_list.begin(), LocalGetCostList);
|
|
|
|
|
|
|
|
|
|
|
|
CostPtrList selected_cost_list(all_cost_list.size(), nullptr);
|
|
|
|
CostPtrList selected_cost_list(all_cost_list.size(), nullptr);
|
|
|
|
std::function<void(size_t, double, double, double, double)> recursive =
|
|
|
|
std::function<void(size_t, double, double, double, double, double)> recursive =
|
|
|
|
[&](size_t k, double computation, double memory, double communication, double communication_without_para) {
|
|
|
|
[&](size_t k, double computation, double memory, double communication, double communication_without_para,
|
|
|
|
|
|
|
|
double communication_forward) {
|
|
|
|
if (k == edges.size()) {
|
|
|
|
if (k == edges.size()) {
|
|
|
|
auto decision = std::make_shared<EdgeEliminationDecision>(selected_cost_list);
|
|
|
|
auto decision = std::make_shared<EdgeEliminationDecision>(selected_cost_list);
|
|
|
|
CostPtr new_cost = std::make_shared<Cost>(computation, communication);
|
|
|
|
CostPtr new_cost = std::make_shared<Cost>(computation, communication);
|
|
|
@ -170,6 +172,7 @@ CostPtrList Edge::CreateEdgeEliminationCostList(const StrategyPtr &output_st_ptr
|
|
|
|
new_cost->communication_with_partial_para_ =
|
|
|
|
new_cost->communication_with_partial_para_ =
|
|
|
|
communication_without_para + COST_MODEL_GAMMA * (communication - communication_without_para);
|
|
|
|
communication_without_para + COST_MODEL_GAMMA * (communication - communication_without_para);
|
|
|
|
new_cost->memory_with_reuse_ = memory;
|
|
|
|
new_cost->memory_with_reuse_ = memory;
|
|
|
|
|
|
|
|
new_cost->communication_forward_ = communication_forward;
|
|
|
|
new_cost->decision_ptr_ = decision;
|
|
|
|
new_cost->decision_ptr_ = decision;
|
|
|
|
result.push_back(new_cost);
|
|
|
|
result.push_back(new_cost);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -179,11 +182,12 @@ CostPtrList Edge::CreateEdgeEliminationCostList(const StrategyPtr &output_st_ptr
|
|
|
|
selected_cost_list[k] = c;
|
|
|
|
selected_cost_list[k] = c;
|
|
|
|
recursive(k + 1, computation + c->computation_cost_, memory + c->memory_with_reuse_,
|
|
|
|
recursive(k + 1, computation + c->computation_cost_, memory + c->memory_with_reuse_,
|
|
|
|
communication + c->communication_cost_,
|
|
|
|
communication + c->communication_cost_,
|
|
|
|
communication_without_para + c->communication_without_parameter_);
|
|
|
|
communication_without_para + c->communication_without_parameter_,
|
|
|
|
|
|
|
|
communication_forward + c->communication_forward_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
recursive(0, 0.0, 0.0, 0.0, 0.0);
|
|
|
|
recursive(0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
|
|
|
SimplifyForDreasingCommunicationWithPartialPara(&result);
|
|
|
|
Simplify(&result);
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -219,6 +223,8 @@ void Edge::CreateOpEliminationSubCostList(StrategyPtr op_strategy, const CostPtr
|
|
|
|
left_cost->computation_cost_ + middle_cost->computation_cost_ + right_cost->computation_cost_;
|
|
|
|
left_cost->computation_cost_ + middle_cost->computation_cost_ + right_cost->computation_cost_;
|
|
|
|
double communication =
|
|
|
|
double communication =
|
|
|
|
left_cost->communication_cost_ + middle_cost->communication_cost_ + right_cost->communication_cost_;
|
|
|
|
left_cost->communication_cost_ + middle_cost->communication_cost_ + right_cost->communication_cost_;
|
|
|
|
|
|
|
|
double communication_forward =
|
|
|
|
|
|
|
|
left_cost->communication_forward_ + middle_cost->communication_forward_ + right_cost->communication_forward_;
|
|
|
|
double communication_without_para = left_cost->communication_without_parameter_ +
|
|
|
|
double communication_without_para = left_cost->communication_without_parameter_ +
|
|
|
|
middle_cost->communication_without_parameter_ +
|
|
|
|
middle_cost->communication_without_parameter_ +
|
|
|
|
right_cost->communication_without_parameter_;
|
|
|
|
right_cost->communication_without_parameter_;
|
|
|
@ -232,6 +238,7 @@ void Edge::CreateOpEliminationSubCostList(StrategyPtr op_strategy, const CostPtr
|
|
|
|
cost->communication_with_partial_para_ =
|
|
|
|
cost->communication_with_partial_para_ =
|
|
|
|
communication_without_para + COST_MODEL_GAMMA * (communication - communication_without_para);
|
|
|
|
communication_without_para + COST_MODEL_GAMMA * (communication - communication_without_para);
|
|
|
|
cost->memory_with_reuse_ = memory_cost;
|
|
|
|
cost->memory_with_reuse_ = memory_cost;
|
|
|
|
|
|
|
|
cost->communication_forward_ = communication_forward;
|
|
|
|
ret_cost_list->emplace_back(std::move(cost));
|
|
|
|
ret_cost_list->emplace_back(std::move(cost));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -251,7 +258,7 @@ CostPtrList Edge::CreateOpEliminationCostList(const EdgePtr &e1, const StrategyP
|
|
|
|
CreateOpEliminationSubCostList(middle_strategy, e1->GetCostList(output_st_ptr, middle_strategy),
|
|
|
|
CreateOpEliminationSubCostList(middle_strategy, e1->GetCostList(output_st_ptr, middle_strategy),
|
|
|
|
op_strategy->cost_list, e2->GetCostList(middle_strategy, input_st_ptr), &result);
|
|
|
|
op_strategy->cost_list, e2->GetCostList(middle_strategy, input_st_ptr), &result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SimplifyForDreasingCommunicationWithPartialPara(&result);
|
|
|
|
Simplify(&result);
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|