From 02ae21d8fc3bc1375848f40702cd4bb7f6700595 Mon Sep 17 00:00:00 2001 From: David Shah Date: Sun, 24 Mar 2019 11:10:20 +0000 Subject: Add --placer option and refactor placer selection Signed-off-by: David Shah --- common/command.cc | 19 +++++++++++++++++++ common/settings.h | 27 +++++++++++++++++++-------- 2 files changed, 38 insertions(+), 8 deletions(-) (limited to 'common') diff --git a/common/command.cc b/common/command.cc index b7fc13e6..6f4137fe 100644 --- a/common/command.cc +++ b/common/command.cc @@ -27,6 +27,7 @@ #include "pybindings.h" #endif +#include #include #include #include @@ -120,6 +121,13 @@ po::options_description CommandHandler::getGeneralOptions() general.add_options()("json", po::value(), "JSON design file to ingest"); general.add_options()("seed", po::value(), "seed value for random number generator"); general.add_options()("randomize-seed,r", "randomize seed value for random number generator"); + + general.add_options()( + "placer", po::value(), + std::string("placer algorithm to use; available: " + boost::algorithm::join(Arch::availablePlacers, ", ") + + "; default: " + Arch::defaultPlacer) + .c_str()); + general.add_options()("slack_redist_iter", po::value(), "number of iterations between slack redistribution"); general.add_options()("cstrweight", po::value(), "placer weighting for relative constraint satisfaction"); general.add_options()("starttemp", po::value(), "placer SA start temperature"); @@ -186,6 +194,17 @@ void CommandHandler::setupContext(Context *ctx) settings->set("timing/allowFail", true); } + if (vm.count("placer")) { + std::string placer = vm["placer"].as(); + if (std::find(Arch::availablePlacers.begin(), Arch::availablePlacers.end(), placer) == + Arch::availablePlacers.end()) + log_error("Placer algorithm '%s' is not supported (available options: %s)\n", placer.c_str(), + boost::algorithm::join(Arch::availablePlacers, ", ").c_str()); + settings->set("placer", placer); + } else { + settings->set("placer", Arch::defaultPlacer); + } + if (vm.count("cstrweight")) { settings->set("placer1/constraintWeight", vm["cstrweight"].as()); } diff --git a/common/settings.h b/common/settings.h index 0c4a67db..b57947c9 100644 --- a/common/settings.h +++ b/common/settings.h @@ -45,19 +45,30 @@ class Settings return defaultValue; } - template void set(const char *name, T value) - { - IdString id = ctx->id(name); - auto pair = ctx->settings.emplace(id, std::to_string(value)); - if (!pair.second) { - ctx->settings[pair.first->first] = value; - } - } + template void set(const char *name, T value); private: Context *ctx; }; +template inline void Settings::set(const char *name, T value) +{ + IdString id = ctx->id(name); + auto pair = ctx->settings.emplace(id, std::to_string(value)); + if (!pair.second) { + ctx->settings[pair.first->first] = value; + } +} + +template <> inline void Settings::set(const char *name, std::string value) +{ + IdString id = ctx->id(name); + auto pair = ctx->settings.emplace(id, value); + if (!pair.second) { + ctx->settings[pair.first->first] = value; + } +} + NEXTPNR_NAMESPACE_END #endif // SETTINGS_H -- cgit v1.2.3