Skip to content

Commit

Permalink
Move benchmarking tools from xls/tools to xls/dev_tools.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 671537853
  • Loading branch information
meheffernan authored and copybara-github committed Sep 5, 2024
1 parent c0646ff commit ff75c43
Show file tree
Hide file tree
Showing 14 changed files with 137 additions and 137 deletions.
6 changes: 3 additions & 3 deletions docs_src/bazel_rules_macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,15 @@ Examples:
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="xls_dslx_opt_ir_test-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
| <a id="xls_dslx_opt_ir_test-benchmark_ir_args"></a>benchmark_ir_args | Arguments of the benchmark IR tool. For details on the arguments, refer to the benchmark_main application at //xls/tools/benchmark_main.cc. | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | `{}` |
| <a id="xls_dslx_opt_ir_test-benchmark_ir_args"></a>benchmark_ir_args | Arguments of the benchmark IR tool. For details on the arguments, refer to the benchmark_main application at //xls/dev_tools/benchmark_main.cc. | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | `{}` |
| <a id="xls_dslx_opt_ir_test-dep"></a>dep | The xls_dslx_opt_ir target to test. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
| <a id="xls_dslx_opt_ir_test-dslx_test_args"></a>dslx_test_args | Arguments of the DSLX interpreter executable. For details on the arguments, refer to the interpreter_main application at //xls/dslx/interpreter_main.cc. | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | `{}` |
| <a id="xls_dslx_opt_ir_test-expect_equivalent"></a>expect_equivalent | If true this test fails if IRs are not equivalent. If false the test only passes if the IRs are not equivalent. | Boolean | optional | `True` |
| <a id="xls_dslx_opt_ir_test-input_validator"></a>input_validator | The DSLX library defining the input validator for this test. Mutually exclusive with "input_validator_expr". | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
| <a id="xls_dslx_opt_ir_test-input_validator_expr"></a>input_validator_expr | The expression to validate an input for the test function. Mutually exclusive with "input_validator". | String | optional | `""` |
| <a id="xls_dslx_opt_ir_test-ir_equivalence_args"></a>ir_equivalence_args | Arguments of the IR equivalence tool. For details on the arguments, refer to the check_ir_equivalence_main application at //xls/dev_tools/check_ir_equivalence_main.cc. The 'function' argument is not assigned using this attribute. | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | `{}` |
| <a id="xls_dslx_opt_ir_test-ir_eval_args"></a>ir_eval_args | Arguments of the IR interpreter. For details on the arguments, refer to the eval_ir_main application at //xls/tools/eval_ir_main.cc.The 'top' argument is not assigned using this attribute. | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | `{"random_inputs": "100", "optimize_ir": "true"}` |
| <a id="xls_dslx_opt_ir_test-scheduling_options_proto"></a>scheduling_options_proto | Protobuf filename of scheduling arguments to the benchmark IR tool. For details on the arguments, refer to the benchmark_main application at //xls/tools/benchmark_main.cc. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
| <a id="xls_dslx_opt_ir_test-scheduling_options_proto"></a>scheduling_options_proto | Protobuf filename of scheduling arguments to the benchmark IR tool. For details on the arguments, refer to the benchmark_main application at //xls/dev_tools/benchmark_main.cc. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
| <a id="xls_dslx_opt_ir_test-top"></a>top | The (*mangled*) name of the entry point. See get_mangled_ir_symbol. Defines the 'top' argument of the IR tool/application. | String | optional | `""` |
Expand Down Expand Up @@ -706,7 +706,7 @@ Examples:
refer to the codegen_main application at
//xls/tools/codegen_main.cc.
benchmark_ir_args: Arguments of the benchmark IR tool. For details on the arguments, refer
to the benchmark_main application at //xls/tools/benchmark_main.cc.
to the benchmark_main application at //xls/dev_tools/benchmark_main.cc.
standard_cells: Label for the PDK (possibly specifying a
non-default corner), with the assumption that $location will
return the timing (Liberty) library for the PDK corner. Unused if synthesize == False.
Expand Down
2 changes: 1 addition & 1 deletion docs_src/delay_estimation.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ given IR should be in a form suitable for code generation; e.g. it has run
through the `opt_main` binary).

```
$ bazel run -c opt //xls/tools:benchmark_main -- $PWD/bazel-bin/xls/examples/crc32.opt.ir --clock_period_ps=500 --delay_model=sky130
$ bazel run -c opt //xls/dev_tools:benchmark_main -- $PWD/bazel-bin/xls/examples/crc32.opt.ir --clock_period_ps=500 --delay_model=sky130
<snip>
Critical path delay: 8351ps
Critical path entry count: 43
Expand Down
4 changes: 2 additions & 2 deletions docs_src/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ various statistics about the BDD. BDD construction can be very slow in
pathological cases and this utility is useful for identifying the underlying
causes. Accepts arbitrary IR as input or a benchmark specified by name.

## [`benchmark_main`](https://github.com/google/xls/tree/main/xls/tools/benchmark_main.cc)
## [`benchmark_main`](https://github.com/google/xls/tree/main/xls/dev_tools/benchmark_main.cc)

Prints numerous metrics and other information about an XLS IR file including:
total delay, critical path, codegen information, optimization time, etc. This
tool may be run against arbitrary IR not just the fixed set of XLS benchmarks.
The output of this tool is scraped by `run_benchmarks` to construct a table
comparing metrics against a mint CL across the benchmark suite.

## [`booleanify_main`](https://github.com/google/xls/tree/main/xls/tools/booleanify_main.cc)
## [`booleanify_main`](https://github.com/google/xls/tree/main/xls/dev_tools/booleanify_main.cc)

Rewrites an XLS IR function in terms of its ops' fundamental AND/OR/NOT
constituents, i.e., makes all operations boolean, thus it's "booleanifying" the
Expand Down
4 changes: 2 additions & 2 deletions xls/build_rules/xls_ir_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1075,14 +1075,14 @@ xls_benchmark_ir_attrs = {
"benchmark_ir_args": attr.string_dict(
doc = "Arguments of the benchmark IR tool. For details on the " +
"arguments, refer to the benchmark_main application at " +
"//xls/tools/benchmark_main.cc.",
"//xls/dev_tools/benchmark_main.cc.",
),
"scheduling_options_proto": attr.label(
allow_single_file = True,
default = None,
doc = "Protobuf filename of scheduling arguments to the benchmark IR tool. " +
"For details on the arguments, refer to the benchmark_main application at " +
"//xls/tools/benchmark_main.cc.",
"//xls/dev_tools/benchmark_main.cc.",
),
}

Expand Down
2 changes: 1 addition & 1 deletion xls/build_rules/xls_macros.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ Examples:
refer to the codegen_main application at
//xls/tools/codegen_main.cc.
benchmark_ir_args: Arguments of the benchmark IR tool. For details on the arguments, refer
to the benchmark_main application at //xls/tools/benchmark_main.cc.
to the benchmark_main application at //xls/dev_tools/benchmark_main.cc.
standard_cells: Label for the PDK (possibly specifying a
non-default corner), with the assumption that $location will
return the timing (Liberty) library for the PDK corner. Unused if synthesize == False.
Expand Down
4 changes: 2 additions & 2 deletions xls/build_rules/xls_toolchains.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ _DEFAULT_IR_EQUIVALENCE_TARGET = "//xls/dev_tools:check_ir_equivalence_main"

_DEFAULT_EVAL_IR_TARGET = "//xls/tools:eval_ir_main"

_DEFAULT_BENCHMARK_TARGET = "//xls/tools:benchmark_main"
_DEFAULT_BENCHMARK_TARGET = "//xls/dev_tools:benchmark_main"

_DEFAULT_BENCHMARK_CODEGEN_TARGET = "//xls/tools:benchmark_codegen_main"
_DEFAULT_BENCHMARK_CODEGEN_TARGET = "//xls/dev_tools:benchmark_codegen_main"

_DEFAULT_CODEGEN_TARGET = "//xls/tools:codegen_main"

Expand Down
122 changes: 122 additions & 0 deletions xls/dev_tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -606,3 +606,125 @@ py_test(
"//xls/common:runfiles",
],
)

filegroup(
name = "benchmark_test_sh",
srcs = ["benchmark_test.sh"],
visibility = ["//xls:xls_users"],
)

filegroup(
name = "benchmark_eval_test_sh",
srcs = ["benchmark_eval_test.sh"],
visibility = ["//xls:xls_users"],
)

cc_binary(
name = "benchmark_main",
srcs = ["benchmark_main.cc"],
visibility = ["//xls:xls_users"],
deps = [
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/time",
"@com_google_absl//absl/types:span",
"//xls/codegen:module_signature",
"//xls/common:exit_status",
"//xls/common:init_xls",
"//xls/common/file:filesystem",
"//xls/common/status:ret_check",
"//xls/common/status:status_macros",
"//xls/data_structures:binary_decision_diagram",
"//xls/estimators/delay_model:analyze_critical_path",
"//xls/estimators/delay_model:delay_estimator",
"//xls/estimators/delay_model:delay_estimators",
"//xls/fdo:grpc_synthesizer",
"//xls/fdo:synthesized_delay_diff_utils",
"//xls/fdo:synthesizer",
"//xls/interpreter:block_evaluator",
"//xls/interpreter:ir_interpreter",
"//xls/interpreter:random_value",
"//xls/ir",
"//xls/ir:events",
"//xls/ir:ir_parser",
"//xls/ir:op",
"//xls/ir:type",
"//xls/ir:value",
"//xls/jit:block_jit",
"//xls/jit:function_jit",
"//xls/jit:jit_channel_queue",
"//xls/jit:jit_runtime",
"//xls/jit:orc_jit",
"//xls/jit:proc_jit",
"//xls/passes:bdd_function",
"//xls/passes:bdd_query_engine",
"//xls/passes:optimization_pass",
"//xls/passes:optimization_pass_pipeline",
"//xls/passes:pass_base",
"//xls/passes:query_engine",
"//xls/scheduling:pipeline_schedule",
"//xls/tools:codegen",
"//xls/tools:codegen_flags",
"//xls/tools:codegen_flags_cc_proto",
"//xls/tools:scheduling_options_flags",
"//xls/tools:scheduling_options_flags_cc_proto",
],
)

cc_binary(
name = "benchmark_codegen_main",
srcs = ["benchmark_codegen_main.cc"],
deps = [
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/time",
"//xls/codegen:block_metrics",
"//xls/codegen:codegen_options",
"//xls/codegen:combinational_generator",
"//xls/codegen:module_signature",
"//xls/codegen:pipeline_generator",
"//xls/codegen:xls_metrics_cc_proto",
"//xls/common:exit_status",
"//xls/common:init_xls",
"//xls/common/file:filesystem",
"//xls/common/status:ret_check",
"//xls/common/status:status_macros",
"//xls/estimators/delay_model:delay_estimator",
"//xls/ir",
"//xls/ir:ir_parser",
"//xls/scheduling:pipeline_schedule",
"//xls/scheduling:run_pipeline_schedule",
"//xls/scheduling:scheduling_options",
"//xls/tools:codegen",
"//xls/tools:codegen_flags",
"//xls/tools:codegen_flags_cc_proto",
"//xls/tools:scheduling_options_flags",
"//xls/tools:scheduling_options_flags_cc_proto",
],
)

py_test(
name = "benchmark_codegen_main_test",
srcs = ["benchmark_codegen_main_test.py"],
data = [
":benchmark_codegen_main",
],
python_version = "PY3",
srcs_version = "PY3",
deps = [
"@com_google_absl_py//absl/testing:absltest",
"//xls/common:runfiles",
"//xls/common:test_base",
],
)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from xls.common import test_base

BENCHMARK_CODEGEN_MAIN_PATH = runfiles.get_path(
'xls/tools/benchmark_codegen_main'
'xls/dev_tools/benchmark_codegen_main'
)

OPT_IR = """package add
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
# limitations under the License.


./xls/tools/benchmark_main \
./xls/dev_tools/benchmark_main \
--vmodule=delay_estimator_main=1 --alsologtostderr "$@" || exit -1
echo "PASS!"
4 changes: 2 additions & 2 deletions xls/dev_tools/check_examples_have_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ def test_collect_x_files_for_library():
<rule-input name="//xls/examples:find_index.x"/>
<rule-input name="//xls/jit:aot_compiler"/>
<rule-input name="//xls/jit:jit_wrapper_generator_main"/>
<rule-input name="//xls/tools:benchmark_codegen_main"/>
<rule-input name="//xls/tools:benchmark_main"/>
<rule-input name="//xls/dev_tools:benchmark_codegen_main"/>
<rule-input name="//xls/dev_tools:benchmark_main"/>
<rule-input name="//xls/dev_tools:check_ir_equivalence_main"/>
<rule-input name="//xls/tools:codegen_main"/>
<rule-input name="//xls/tools:eval_ir_main"/>
Expand Down
122 changes: 0 additions & 122 deletions xls/tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -791,77 +791,6 @@ py_test(
],
)

filegroup(
name = "benchmark_test_sh",
srcs = ["benchmark_test.sh"],
visibility = ["//xls:xls_users"],
)

filegroup(
name = "benchmark_eval_test_sh",
srcs = ["benchmark_eval_test.sh"],
visibility = ["//xls:xls_users"],
)

cc_binary(
name = "benchmark_main",
srcs = ["benchmark_main.cc"],
visibility = ["//xls:xls_users"],
deps = [
":codegen",
":codegen_flags",
":codegen_flags_cc_proto",
":scheduling_options_flags",
":scheduling_options_flags_cc_proto",
"//xls/codegen:module_signature",
"//xls/common:exit_status",
"//xls/common:init_xls",
"//xls/common/file:filesystem",
"//xls/common/status:ret_check",
"//xls/common/status:status_macros",
"//xls/data_structures:binary_decision_diagram",
"//xls/estimators/delay_model:analyze_critical_path",
"//xls/estimators/delay_model:delay_estimator",
"//xls/estimators/delay_model:delay_estimators",
"//xls/fdo:grpc_synthesizer",
"//xls/fdo:synthesized_delay_diff_utils",
"//xls/fdo:synthesizer",
"//xls/interpreter:block_evaluator",
"//xls/interpreter:ir_interpreter",
"//xls/interpreter:random_value",
"//xls/ir",
"//xls/ir:events",
"//xls/ir:ir_parser",
"//xls/ir:op",
"//xls/ir:type",
"//xls/ir:value",
"//xls/jit:block_jit",
"//xls/jit:function_jit",
"//xls/jit:jit_channel_queue",
"//xls/jit:jit_runtime",
"//xls/jit:orc_jit",
"//xls/jit:proc_jit",
"//xls/passes:bdd_function",
"//xls/passes:bdd_query_engine",
"//xls/passes:optimization_pass",
"//xls/passes:optimization_pass_pipeline",
"//xls/passes:pass_base",
"//xls/passes:query_engine",
"//xls/scheduling:pipeline_schedule",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/time",
"@com_google_absl//absl/types:span",
],
)

# TODO(b/147004555): Add a JIT (or legacy) version of this test once
# the JIT supports enough functionality to pass.
py_test(
Expand Down Expand Up @@ -1117,57 +1046,6 @@ cc_binary(
],
)

cc_binary(
name = "benchmark_codegen_main",
srcs = ["benchmark_codegen_main.cc"],
deps = [
":codegen",
":codegen_flags",
":codegen_flags_cc_proto",
":scheduling_options_flags",
":scheduling_options_flags_cc_proto",
"//xls/codegen:block_metrics",
"//xls/codegen:codegen_options",
"//xls/codegen:combinational_generator",
"//xls/codegen:module_signature",
"//xls/codegen:pipeline_generator",
"//xls/codegen:xls_metrics_cc_proto",
"//xls/common:exit_status",
"//xls/common:init_xls",
"//xls/common/file:filesystem",
"//xls/common/status:ret_check",
"//xls/common/status:status_macros",
"//xls/estimators/delay_model:delay_estimator",
"//xls/ir",
"//xls/ir:ir_parser",
"//xls/scheduling:pipeline_schedule",
"//xls/scheduling:run_pipeline_schedule",
"//xls/scheduling:scheduling_options",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/time",
],
)

py_test(
name = "benchmark_codegen_main_test",
srcs = ["benchmark_codegen_main_test.py"],
data = [
":benchmark_codegen_main",
],
python_version = "PY3",
srcs_version = "PY3",
deps = [
"//xls/common:runfiles",
"//xls/common:test_base",
"@com_google_absl_py//absl/testing:absltest",
],
)

py_test(
name = "delay_info_main_test",
srcs = ["delay_info_main_test.py"],
Expand Down

0 comments on commit ff75c43

Please sign in to comment.