xls icon indicating copy to clipboard operation
xls copied to clipboard

Add IEEE-754-Compatible Integer Rounding Primitives And Exhaustive DSLX Tests

Open dank-openai opened this issue 3 months ago • 5 comments

  • Create xls/dslx/stdlib/round.x implementing the generic round core plus unsigned, signed, and sign/magnitude wrappers for both runtime and compile-time truncation paths, covering all five IEEE-754 modes and flagging overflow when the rounded integer exceeds the available width.
  • Create xls/dslx/stdlib/tests/round_tests.x with sanity checks for the wrapper surface area, boundary cases such as zero-width values and rounding away all bits, and a generator-produced matrix of 372 tests spanning bit widths 1–5, every input value, all possible num_bits_rounded, and all rounding modes.
  • Create xls/dslx/stdlib/tests/gen_round_tests.py to regenerate the exhaustive test section, including utilities that model IEEE-754 rounding on rationals and compute expected overflow behaviour.
  • Document the rounding functions in dslx_std.md

dank-openai avatar Sep 19 '25 19:09 dank-openai

I don't understand why CI is failing:

Check C++ absolute includes..............................................Failed
- hook id: check-cpp-absolute-includes
- exit code: 1

xls/dslx/cpp_transpiler/cpp_transpiler_test.cc: Found non-absolute includes:
  path/to/some_types.h
  path/to/other_types.h
  /tmp/fake_path.h
  path/to/some_types.h
  path/to/other_types.h

this check has nothing to do with the changes made in this PR (which add a DSLX file and add to documentation).

dank-openai avatar Sep 29 '25 16:09 dank-openai

I don't understand why CI is failing:

Looks like this was fixed w/ rebasing? (underlying issues w/ check-cpp-absolute-includes has been fixed in https://github.com/google/xls/commit/62022c1fe8095e7d31c38f899949639dcf3e7013)

proppy avatar Sep 30 '25 00:09 proppy

I don't understand why CI is failing:

Looks like this was fixed w/ rebasing? (underlying issues w/ check-cpp-absolute-includes has been fixed in 62022c1)

Yes, it was.

dank-openai avatar Sep 30 '25 13:09 dank-openai

That's awesome!

My pleasure!

factoring out the rounding logic will definitly help making apfloat more maintainable.

I have also found this more broadly useful; I have made use of it with the fixed point module too. I'm sure others will find uses for rounding functions outside of just apfloat.

dank-openai avatar Sep 30 '25 13:09 dank-openai

Hi, just checking if the team wanted me to rip out the generated tests, or not? I see both of the following, so I'm not sure what the consensus is:

richmckeever added the Reviewing Internally label last week

what do think of continuing the discussion about jit wrapper vs generated tests in a separate PR and merging this w/o exhaustive testing

dank-openai avatar Nov 14 '25 15:11 dank-openai

I see both of the following, so I'm not sure what the consensus is

I'd personnally be up for us to split the generated tests in a separate PR and discuss options there (I'd be also happy to help!), I think @richmckeever wanted to kick-off the internal review process nonetheless.

proppy avatar Dec 24 '25 02:12 proppy