google / google/xls

codegen verification should not reject mutually exclusive send ops to the same channel

Open
#1,899 0 comments 0 reactions 0 assignees View on GitHub
codegen ir 🧦 sox
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

**Describe the bug**
It seems that the codegen verification pass rejects IR packages that contain multiple send to the same channel, even if those are mutually exclusive or serialized.

**To Reproduce**

The following DSLX code
```
proc Foo {
some_chan: chan out;

init {
token()
}

config(some_chan: chan out) {
(some_chan,)
}

next(state: token) {
let tok = send(state, some_chan, true);
let tok = send(tok, some_chan, false);
tok
}
}
```
Get converted and optimize to the following IR:
```
package a

file_number 0 "/tmp/a.x"

chan a__some_chan(bits[1], id=0, kind=streaming, ops=send_only, flow_control=ready_valid, strictness=proven_mutually_exclusive, metadata="""""")

top proc __a__Foo_0_next(__state: token, init={token}) {
__state: token = state_read(state_element=__state, id=2)
literal.4: bits[1] = literal(value=1, id=4, pos=[(0,12,37)])
tok: token = send(__state, literal.4, channel=a__some_chan, id=11)
literal.6: bits[1] = literal(value=0, id=6, pos=[(0,13,35)])
tok__1: token = send(tok, literal.6, channel=a__some_chan, id=12)
next_value.8: () = next_value(param=__state, value=tok__1, id=8)
}
```
which fails to codegen with the following error:
```
Error: INTERNAL: Multiple sends associated with the same channel 'a__some_chan':

Send node with no known provenance: tok: token = send(__state, literal.4, channel=a__some_chan, id=11)

Send node with no known provenance: tok__1: token = send(tok, literal.6, channel=a__some_chan, id=12)
```

**Expected behavior**
The codegen verification pass should accept an IR package w/ mutually exclusive/serialized sends (or if WAI produce an actionable error message instead of an internal error).

**Additional context**

Switching the channel strictness to `proven_mutually_exclusive` or `total_order` doesn't seems to affect the codegen verification pass behavior.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.