8000 examples: add a proc version of gcd by MaxonT · Pull Request #5570 · google/xls · GitHub
[go: up one dir, main page]

Skip to content

examples: add a proc version of gcd - #5570

Open
MaxonT wants to merge 1 commit into
google:mainfrom
MaxonT:contrib/1444-auto
Open

MaxonT wants to merge 1 commit into
google:mainfrom
MaxonT:contrib/1444-auto

Conversation

@MaxonT
@MaxonT MaxonT commented Nov 29, 2026
Copy link
Copy Markdown

Hi there, here is a proposed fix for this issue.

Fixes #1444

Following the suggestion in #935, this adds a proc next to the existing function versions in xls/examples/gcd.x. It takes (a, b) on a request channel, does one Euclidean step per tick ((a, b) becomes (b, a % b)), and sends a on the result channel once b is zero. It only accepts a new request while idle. That gives a data dependent number of ticks, which is the tradeoff against the fixed latency of gcd_euclidean that the issue wanted to show.

Changes are all in gcd.x, so the existing gcd_test rule picks them up and no BUILD edit is needed:

  • gcd_euclidean_proc<N>
  • an in-file #[test] proc covering 48/18, 18/48, b == 0 and a == 0
  • the two #![feature(...)] lines the other proc examples use (explicit_state_access, generics)

What I ran, on my fork's GitHub Actions (Ubuntu) with the interpreter_main and dslx_fmt binaries from the release built at 753a8f1, which is the commit this branch is based on: https://github.com/MaxonT/xls/actions/runs/46273197446

  • interpreter_main --compare=jit gcd.x, the same flags as gcd_test: 3 tests ran, 0 failed, and the 50000 case quickcheck passed.
  • Changing a % b to a / b in the proc makes gcd_euclidean_proc_test fail (u8:9 vs u8:6), so the test does exercise the proc.
  • dslx_fmt on the file gives no diff.

Not run: the Bazel build and bazel test //xls/examples:gcd_test itself, upstream CI, and IR conversion or codegen of the new proc (no BUILD rule is added for it).

Signed-off-by: Ym <173550318+MaxonT@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

add gcd proc example

1 participant

0