Skip to content

Commit 94bbfa6

Browse files
allightcopybara-github
authored andcommitted
Create BddQueryEngine per-function in benchmark schedule printing.
The BddQueryEngine is associated with a single function. When printing schedule information for a PackageSchedule containing multiple functions, a new BddQueryEngine must be created and populated for each function in the package. Fixes: #3637 PiperOrigin-RevId: 886998620
1 parent ce5dd34 commit 94bbfa6

4 files changed

Lines changed: 51 additions & 8 deletions

File tree

xls/dev_tools/BUILD

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ cc_binary(
7070
],
7171
)
7272

73+
sh_test(
74+
name = "benchmark_main_test",
75+
srcs = ["benchmark_main_test.sh"],
76+
data = [
77+
"//xls/examples:proc_network_opt_ir_benchmark",
78+
],
79+
)
80+
7381
pytype_strict_contrib_test(
7482
name = "tool_timeout_test",
7583
srcs = ["tool_timeout_test.py"],

xls/dev_tools/benchmark_main.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,7 @@ absl::Status PrintScheduleInfo(FunctionBase* f,
416416
return absl::OkStatus();
417417
}
418418

419-
absl::Status PrintScheduleInfo(FunctionBase* f,
420-
const PackageSchedule& package_schedule,
421-
const BddQueryEngine& bdd_query_engine,
419+
absl::Status PrintScheduleInfo(const PackageSchedule& package_schedule,
422420
const DelayEstimator& delay_estimator,
423421
std::optional<int64_t> clock_period_ps) {
424422
if (package_schedule.GetSchedules().size() == 1) {
@@ -436,9 +434,12 @@ absl::Status PrintScheduleInfo(FunctionBase* f,
436434
}
437435
for (auto& [function_base, schedule] : package_schedule.GetSchedules()) {
438436
std::cout << "\n\nFunction: " << function_base->name() << "\n";
439-
XLS_RETURN_IF_ERROR(PrintScheduleInfo(function_base, schedule,
440-
bdd_query_engine, delay_estimator,
441-
clock_period_ps));
437+
// NB query engines are associated with a specific function, so we need to
438+
// create a new one for each function.
439+
BddQueryEngine query_engine(BddQueryEngine::kDefaultPathLimit);
440+
XLS_RETURN_IF_ERROR(query_engine.Populate(function_base).status());
441+
XLS_RETURN_IF_ERROR(PrintScheduleInfo(function_base, schedule, query_engine,
442+
delay_estimator, clock_period_ps));
442443
}
443444
return absl::OkStatus();
444445
}
@@ -858,7 +859,7 @@ absl::Status RealMain(std::string_view path) {
858859
synthesizer.get()));
859860

860861
XLS_RETURN_IF_ERROR(PrintScheduleInfo(
861-
f, package_schedule, query_engine, defaulted_delay_estimator,
862+
package_schedule, defaulted_delay_estimator,
862863
scheduling_options_flags_proto.has_clock_period_ps()
863864
? std::make_optional(
864865
scheduling_options_flags_proto.clock_period_ps())
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
MY_BENCHMARK_FILE="./xls/examples/proc_network_opt_ir_benchmark.sh"
4+
5+
die () {
6+
echo "ERROR: $1"
7+
exit 1
8+
}
9+
10+
# Run the benchmark
11+
${MY_BENCHMARK_FILE} || die "Failed in ${MY_BENCHMARK_FILE}"
12+
13+
echo "PASS"

xls/examples/BUILD

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,11 +1382,32 @@ xls_dslx_test(
13821382
xls_dslx_ir(
13831383
name = "proc_network_ir",
13841384
dslx_top = "Initiator",
1385-
ir_conv_args = {"lower_to_proc_scoped_channels": "true"},
1385+
ir_conv_args = {
1386+
"lower_to_proc_scoped_channels": "true",
1387+
"default_fifo_config": "depth: 2, bypass: true, " +
1388+
"register_push_outputs: false, register_pop_outputs: false",
1389+
},
13861390
ir_file = "proc_network.ir",
13871391
library = ":proc_network_dslx",
13881392
)
13891393

1394+
xls_ir_opt_ir(
1395+
name = "proc_network_opt_ir",
1396+
src = "proc_network.ir",
1397+
)
1398+
1399+
xls_benchmark_ir(
1400+
name = "proc_network_opt_ir_benchmark",
1401+
src = ":proc_network_opt_ir",
1402+
codegen_args = {
1403+
"module_name": "ProcName",
1404+
"delay_model": "unit",
1405+
"pipeline_stages": "2",
1406+
"reset": "rst",
1407+
},
1408+
synthesize = True,
1409+
)
1410+
13901411
xls_dslx_ir(
13911412
name = "proc_network_proc_scoped_ir",
13921413
dslx_top = "Initiator",

0 commit comments

Comments
 (0)