Skip to content

[enhancement] add proto for opt args #2532

@proppy

Description

@proppy

What's hard to do? (limit 100 words)

Currently we can specify args as proto file for the following step in the toolchain:

But we don't have any equivalent to specify opt flags:

xls/xls/tools/opt_main.cc

Lines 71 to 151 in f571bc4

ABSL_FLAG(std::string, output_path, "-",
"Output path for the optimized IR file; '-' denotes stdout.");
ABSL_FLAG(std::optional<std::string>, alsologto, std::nullopt,
"Path to write logs to, in addition to stderr.");
// LINT.IfChange
ABSL_FLAG(std::string, top, "", "Top entity to optimize.");
ABSL_FLAG(std::string, ir_dump_path, "",
"Dump all intermediate IR files to the given directory");
ABSL_FLAG(std::vector<std::string>, skip_passes, {},
"If specified, passes in this comma-separated list of (short) "
"pass names are skipped.");
ABSL_FLAG(std::optional<int64_t>, convert_array_index_to_select, std::nullopt,
"If specified, convert array indexes with fewer than or "
"equal to the given number of possible indices (by range analysis) "
"into chains of selects. Otherwise, this optimization is skipped, "
"since it can sometimes reduce output quality.");
ABSL_FLAG(
std::optional<int64_t>, split_next_value_selects, 4,
"If positive, split `next_value`s that assign `sel`s to state params if "
"they have fewer than the given number of cases. This optimization is "
"skipped for selects with more cases, since it can sometimes reduce output "
"quality by replacing MUX trees with separate equality checks.");
ABSL_FLAG(int64_t, opt_level, xls::kMaxOptLevel, []() -> const std::string& {
static const std::string kDescription = absl::StrFormat(
"Optimization level. Ranges from 1 to %d.", xls::kMaxOptLevel);
return kDescription;
}());
ABSL_FLAG(std::string, ram_rewrites_pb, "",
"Path to protobuf describing ram rewrites.");
ABSL_FLAG(bool, use_context_narrowing_analysis, false,
"Use context sensitive narrowing analysis. This is somewhat slower "
"but might produce better results in some circumstances by using "
"usage context to narrow values more aggressively.");
ABSL_FLAG(
bool, optimize_for_best_case_throughput, false,
"Optimize for best case throughput, even at the cost of area. This will "
"aggressively optimize to create opportunities for improved throughput, "
"but at the cost of constraining the schedule and thus increasing area.");
// LINT.ThenChange(//xls/build_rules/xls_ir_rules.bzl)
ABSL_FLAG(bool, enable_resource_sharing, false,
"Enable the resource sharing optimization to save area.");
ABSL_FLAG(bool, force_resource_sharing, false,
"Force the resource sharing pass to apply the transformation where "
"it is legal to do so, overriding therefore the profitability "
"heuristic of such pass. This option is only used when the resource "
"sharing pass is enabled.");
ABSL_FLAG(std::string, area_model, "asap7",
"Area model to use for optimizations.");
ABSL_FLAG(
std::optional<std::string>, passes, std::nullopt,
"Explicit list of passes to run in a specific order. Passes are named "
"by 'short_name' and if they have non-opt-level arguments these are "
"placed in (). Fixed point sets of passes can be put within []. Pass "
"names are separated based on spaces. For example a simple pipeline "
"might be \"dfe dce [ ident_remove const_fold dce canon dce arith dce "
"comparison_simp ] loop_unroll map_inline\". This should not be used "
"with --skip_passes. If this is given the standard optimization "
"pipeline is ignored entirely, care should be taken to ensure the "
"given pipeline will run in reasonable amount of time. See the map in "
"passes/optimization_pass_pipeline.cc for pass mappings. Available "
"passes shown by running with --list_passes");
ABSL_FLAG(std::optional<std::string>, passes_proto, std::nullopt,
"A file containing binary PipelinePassList proto defining a pipeline "
"of passes to run");
ABSL_FLAG(std::optional<std::string>, passes_textproto, std::nullopt,
"A file containing textproto PipelinePassList proto defining a "
"pipeline of passes to run");
ABSL_FLAG(std::optional<int64_t>, passes_bisect_limit, std::nullopt,
"Number of passes to allow to execute. This can be used as compiler "
"fuel to ensure the compiler finishes at a particular point.");
ABSL_FLAG(bool, passes_bisect_limit_is_error, false,
"If set then reaching passes bisect limit is considered an error.");
ABSL_FLAG(bool, list_passes, false,
"If passed list the names of all passes and exit.");
ABSL_FLAG(
std::optional<std::string>, pass_metrics_path, std::nullopt,
"Output path for the pass pipeline metrics as a PassPipelineMetricsProto.");
ABSL_FLAG(bool, debug_optimizations, false,
"If passed, run additional strict correctness-checking passes; this "
"slows down the optimization significantly, and is mostly intended "
"for internal XLS debugging.");

Current best alternative workaround (limit 100 words)

None

Your view of the "best case XLS enhancement" (limit 100 words)

  • add a new opt_options_flags.proto definition
  • add --opt_options_proto and --opt_options_used_proto to opt_main

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestoptimizerRelated to IR optimization or analysisuxUser experience (end-user invoking XLS and its related tools)🧦 sox

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions