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

[DC] Add merge lowering #6943

Merged
merged 6 commits into from
May 7, 2024
Merged

[DC] Add merge lowering #6943

merged 6 commits into from
May 7, 2024

Conversation

mortbopet
Copy link
Contributor

Modelled after the Handshake lowering, however, becomes trivial with a 2-input merge.

Modelled after the Handshake lowering, however, becomes trivial with a 2-input merge.
Copy link
Contributor

@Dinistro Dinistro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % nit comments. Again, maybe ensure that @teqdruid has time to take a look at well.

lib/Conversion/DCToHW/DCToHW.cpp Outdated Show resolved Hide resolved
lib/Conversion/HandshakeToDC/HandshakeToDC.cpp Outdated Show resolved Hide resolved
mortbopet and others added 3 commits April 23, 2024 10:17
Co-authored-by: Christian Ulmann <christianulmann@gmail.com>
Co-authored-by: Christian Ulmann <christianulmann@gmail.com>
Copy link
Contributor

@teqdruid teqdruid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks about right to me.

lib/Conversion/HandshakeToDC/HandshakeToDC.cpp Outdated Show resolved Hide resolved

if (!data.empty()) {
// Data-merge; mux the selected input.
auto dataMux = rewriter.create<arith::SelectOp>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does something lower arith.select to an hw.mux?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map-arith-to-comb will lower this to a comb.mux.

// Pack the data mux with the control token.
mergeOutput = pack(rewriter, selectedIndexUnpacked.token, dataMux);
} else {
// Control-only merge; throw away the index value of the dc.merge
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Unlike dc.merge, handshake.merge doesn't output the idx of the value which got selected. This is why you had alarm bells going off.
  • When would a handshake.merge have no data? Since handshake is all about dynamic data flow, I don't think it ever would. In the context of a lowering, even none would be considered data, yes?
  • If none is implicitly converted to dc.token, then this makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If none is implicitly converted to dc.token, then this makes sense.
it is - see

if (type.isa<NoneType>())

When would a handshake.merge have no data? Since handshake is all about dynamic data flow, I don't think it ever would. In the context of a lowering, even none would be considered data, yes?

True, in practice, i've never seen this used. The DHLS lowerings used data merge ops but these could always be boiled down to single-input merges (i.e. a no-op). So your observation is correct, and there is a good argument for removing handshake.merge from the dialect.

@mortbopet mortbopet merged commit 836e745 into main May 7, 2024
4 checks passed
@mortbopet mortbopet deleted the dev/mpetersen/dctohw_merge branch May 7, 2024 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants