google / xls

XLS: Accelerated HW Synthesis
http://google.github.io/xls/
Apache License 2.0
1.2k stars 177 forks source link

Two non-parametric procs in a single file cause errors when running DSLX tests #1415

Open rw1nkler opened 5 months ago

rw1nkler commented 5 months ago

Describe the bug

Having two non-parametric procs in one DSLX file triggers errors when running DSLX tests using the xls_dslx_test rule. The test itself is not even necessary, as it seems that the problem occurs before running the actual test. The error is not triggered when the other proc is parametric.

To Reproduce

One can use the following DSLX code to trigger the error:

import std;

proc Passthrough {
  data_r: chan<u32> in;
  data_s: chan<u32> out;

  init {()}

  config(data_r: chan<u32> in, data_s: chan<u32> out) {
    (data_r, data_s)
  }

  next(tok: token, state: ()) {
    let (tok, data) = recv(tok, data_r);
    let tok = send(tok, data_s, data);
  }
}

// proc MyOtherProc<FAKE_PARAMETER: u32> { // adding a fake parameter removes the error
proc MyOtherProc { 
  data_r: chan<u32> in;
  data_s: chan<u32> out;

  init {()}

  config(data_r: chan<u32> in, data_s: chan<u32> out) {
    (data_r, data_s)
  }

  next(tok: token, state: ()) {
    let (tok, data) = recv(tok, data_r);
    let tok = send(tok, data_s, data);
  }
}

The problem may be related to IR translation, as adding the compare = none flag to dslx_test_args removes the error. Here are the build rules needed to trigger the problem:

xls_dslx_library(
    name = "passthrough_dslx",
    srcs = [
        "passthrough.x",
    ],
)

xls_dslx_test(
    name = "passthrough_dslx_test",
    dslx_test_args = {
        #"compare": "none", # uncommenting this line removes errors
    },
    library = ":passthrough_dslx"
)

The error message is as follows:

$ bazel run //xls/examples:passthrough_dslx_test
Executing tests from //xls/examples:passthrough_dslx_test
-----------------------------------------------------------------------------
E0517 09:02:38.735197 2067348 command_line_utils.cc:45] Could not extract a textual position from error message: INTERNAL: Proc ID "MyOtherProc:0" was not found in arg mapping.: INVALID_ARGUMENT: Provided status is not in recognized error form: INTERNAL: Proc ID "MyOtherProc:0" was not found in arg mapping.

I pushed the code of this example to here. To trigger the error, use:

bazel run //xls/examples:passthrough_dslx_test

Expected behavior

The error should not be triggered. Also, an INTERNAL error is triggered when handling the original error, which should not happen.

erinzmoore commented 1 month ago

Now that compare defaults to none, we expect this issue to be less frequent. I think the desired behavior for multiple procs in a test file with compare: jit is not totally clear at this point. For now, de-prioritizing and removing from the DSLX Next milestone.