Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enhancement] developer should be able to choose how to simulate their DSLX code #1573

Open
proppy opened this issue Aug 29, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request ux User experience (end-user invoking XLS and its related tools)

Comments

@proppy
Copy link
Member

proppy commented Aug 29, 2024

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

Currently when choosing between the DSLX interpreter, the IR interpreter, the JIT or a Verilog simulator to run a set of DSLX tests: developers have to go thru very disjoint experiences (both on the command line and thru bazel rules).

Current best alternative workaround (limit 100 words)

DSLX interpreter

Just use interpreter_main w/ input and assertion from tests; for bazel: xls_dslx_test.

IR interpreter

ir_converter_main | opt_main | eval_ir --use_llvm_jit=false w/ inputs from the command line and --input_validator_expr or --input_validator_path to validate the result; for bazel: xls_dslx_ir ← xls_opt_ir ← xls_eval_ir_test.

JIT

ir_converter_main | opt_main | eval_ir --use_llvm_jit=true w/ inputs from the command line and --input_validator_expr or --input_validator_path to validate the result; for bazel: xls_dslx_irxls_opt_ircc_xls_ir_jit_wrappercc_test.

Verilog

codegen_main and write a verilog test bench.

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

Ideally we would have only one command line/bazel rule w/ a flag to choose the simulation environment.

DSLX interpreter

dslx test path/to/example.x
xls_dslx_test(
    name = "e_dslx_test",
    srcs = [ "example.x" ],
)

IR interpreter

dslx test --simulator=dslx path/to/example.x
xls_dslx_test(
    name = "e_dslx_test",
    srcs = [ "example.x" ],
    simulator = "dslx",
)

JIT

dslx test --simulator=jit path/to/example.x
xls_dslx_test(
    name = "e_dslx_test",
    srcs = [ "example.x" ],
    simulator = "jit",
)

Verilog

dslx test --simulator=iverilog path/to/example.x
xls_dslx_test(
    name = "e_dslx_test",
    srcs = [ "example.x" ],
    simulator = "verilog",
)
@proppy proppy added enhancement New feature or request ux User experience (end-user invoking XLS and its related tools) labels Aug 29, 2024
@proppy proppy changed the title [enhancement] developer should be able to choose how to simulate their DSLX code from a single entrypoint [enhancement] developer should be able to choose how to simulate their DSLX code Aug 31, 2024
@allight allight self-assigned this Aug 31, 2024
@allight
Copy link
Collaborator

allight commented Aug 31, 2024

Just for another motivating example an engineer was recently trying to understand how performance of XLS simulator tools compared to verilog. They created a #[test_proc] which ran a proc codegen'd through verilog and compared how long the verilog simulation took vs the one performed by 'testing' the test_proc. They were confused about why the xls one was so slow when the reason was that it was doing the DSLX interpreter and so took ~5 minutes to complete. If one runs the same benchmark using the proc-jit it finishes in 0.5 seconds.

We take pride in our fast simulation support but the path to try them out is not always the most well lit.

copybara-service bot pushed a commit that referenced this issue Sep 5, 2024
Running dslx_tests though the ir jit allows much longer running tests to be run at the cost of somewhat significant (~1sec/test) startup time.

Currently all tests in a file must be run with a single evaluator.

The 'compare' dslx_test_args functionality is not available when using evaluators other than 'dslx-interpreter' since it directly relies on DSLX interpreter behaviors for its implementation.

The evaluator option has no effect on quick_checks at this time.

Bug: #1592
Bug: #1573
PiperOrigin-RevId: 671555663
@meheff
Copy link
Collaborator

meheff commented Sep 16, 2024

One complexity here is that we ideally want identical test behavior at each level which will take a lot of work. The biggest problem is likely that the DSLX type system is much richer than the IR (structs, signedness, etc) so you can have much nicer messages. Ideally we'd have a way of recovering that at the lower levels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ux User experience (end-user invoking XLS and its related tools)
Projects
None yet
Development

No branches or pull requests

3 participants