Skip to content

Commit ab8971d

Browse files
committed
task resolver, improve the case with unhandled path details level string. now the task is marked as failed.
1 parent b582978 commit ab8971d

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

vpr/src/server/taskresolver.cpp

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,18 @@ void TaskResolver::takeFinished(std::vector<TaskPtr>& result)
4848
}
4949
}
5050

51-
e_timing_report_detail TaskResolver::getDetailsLevelEnum(const std::string& pathDetailsLevelStr) const {
52-
e_timing_report_detail detailesLevel = e_timing_report_detail::INVALID;
51+
std::optional<e_timing_report_detail> TaskResolver::tryGetDetailsLevelEnum(const std::string& pathDetailsLevelStr) const {
5352
if (pathDetailsLevelStr == "netlist") {
54-
detailesLevel = e_timing_report_detail::NETLIST;
53+
return e_timing_report_detail::NETLIST;
5554
} else if (pathDetailsLevelStr == "aggregated") {
56-
detailesLevel = e_timing_report_detail::AGGREGATED;
55+
return e_timing_report_detail::AGGREGATED;
5756
} else if (pathDetailsLevelStr == "detailed") {
58-
detailesLevel = e_timing_report_detail::DETAILED_ROUTING;
57+
return e_timing_report_detail::DETAILED_ROUTING;
5958
} else if (pathDetailsLevelStr == "debug") {
60-
detailesLevel = e_timing_report_detail::DEBUG;
61-
} else {
62-
VTR_LOG_ERROR("unhandled option", pathDetailsLevelStr);
59+
return e_timing_report_detail::DEBUG;
6360
}
64-
return detailesLevel;
61+
62+
return std::nullopt;
6563
}
6664

6765
bool TaskResolver::update(ezgl::application* app)
@@ -99,22 +97,29 @@ void TaskResolver::processGetPathListTask(ezgl::application*, const TaskPtr& tas
9997
// read options
10098
const int nCriticalPathNum = options.getInt(comm::OPTION_PATH_NUM, 1);
10199
const std::string pathType = options.getString(comm::OPTION_PATH_TYPE);
102-
const std::string detailsLevel = options.getString(comm::OPTION_DETAILS_LEVEL);
100+
const std::string details_level_str = options.getString(comm::OPTION_DETAILS_LEVEL);
103101
const bool isFlat = options.getBool(comm::OPTION_IS_FLAT_ROUTING, false);
104102

105103
// calculate critical path depending on options and store result in server context
106-
CritPathsResult crit_paths_result = calcCriticalPath(pathType, nCriticalPathNum, getDetailsLevelEnum(detailsLevel), isFlat);
107-
108-
// setup context
109-
server_ctx.set_path_type(pathType);
110-
server_ctx.set_critical_path_num(nCriticalPathNum);
111-
server_ctx.set_crit_paths(crit_paths_result.paths);
112-
113-
if (crit_paths_result.isValid()) {
114-
std::string msg{crit_paths_result.report};
115-
task->success(msg);
104+
std::optional<e_timing_report_detail> details_level_opt = tryGetDetailsLevelEnum(details_level_str);
105+
if (details_level_opt) {
106+
CritPathsResult crit_paths_result = calcCriticalPath(pathType, nCriticalPathNum, details_level_opt.value(), isFlat);
107+
108+
// setup context
109+
server_ctx.set_path_type(pathType);
110+
server_ctx.set_critical_path_num(nCriticalPathNum);
111+
server_ctx.set_crit_paths(crit_paths_result.paths);
112+
113+
if (crit_paths_result.isValid()) {
114+
std::string msg{crit_paths_result.report};
115+
task->success(msg);
116+
} else {
117+
std::string msg{"Critical paths report is empty"};
118+
VTR_LOG_ERROR(msg.c_str());
119+
task->fail(msg);
120+
}
116121
} else {
117-
std::string msg{"Critical paths report is empty"};
122+
std::string msg{"unsupported report details level " + details_level_str};
118123
VTR_LOG_ERROR(msg.c_str());
119124
task->fail(msg);
120125
}

vpr/src/server/taskresolver.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "vpr_types.h"
88

99
#include <vector>
10+
#include <optional>
1011

1112
namespace ezgl {
1213
class application;
@@ -44,7 +45,7 @@ class TaskResolver {
4445
void processGetPathListTask(ezgl::application*, const TaskPtr&);
4546
void processDrawCriticalPathTask(ezgl::application*, const TaskPtr&);
4647

47-
e_timing_report_detail getDetailsLevelEnum(const std::string& pathDetailsLevelStr) const;
48+
std::optional<e_timing_report_detail> tryGetDetailsLevelEnum(const std::string& pathDetailsLevelStr) const;
4849
};
4950

5051
} // namespace server

0 commit comments

Comments
 (0)