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

f32 support #121

Merged
merged 35 commits into from
Apr 16, 2024
Merged

f32 support #121

merged 35 commits into from
Apr 16, 2024

Conversation

enricozb
Copy link
Contributor

@enricozb enricozb commented Apr 7, 2024

Fixes #110

Some quirks/features:

  • float operators f32.+, f32.-, etc.
  • float literals #<int>.<int>, eg. #123.456
  • integral float literals are not yet supported
  • operations mixing ints and floats cause the integer bits to be reinterpreted as an f32. The integers are not converted to floats.

@enricozb enricozb requested a review from tjjfvi April 7, 2024 21:55
@HigherOrderBot

This comment has been minimized.

@HigherOrderBot

This comment has been minimized.

@HigherOrderBot

This comment has been minimized.

src/ast.rs Outdated Show resolved Hide resolved
src/ast.rs Outdated Show resolved Hide resolved
src/ast.rs Show resolved Hide resolved
src/run/instruction.rs Outdated Show resolved Hide resolved
src/ops.rs Outdated Show resolved Hide resolved
src/run/port.rs Outdated Show resolved Hide resolved
src/run/port.rs Outdated Show resolved Hide resolved
src/transform/eta_reduce.rs Show resolved Hide resolved
src/transform/eta_reduce.rs Show resolved Hide resolved
src/ops/num.rs Outdated Show resolved Hide resolved
fixes a float parsing bug where 1.001 was parsed as 1.1,
as the leading zeros after the decimal point were ignored.
@enricozb enricozb requested a review from tjjfvi April 11, 2024 19:50
Cargo.toml Outdated Show resolved Hide resolved
src/ops.rs Outdated Show resolved Hide resolved
src/ops/word.rs Outdated Show resolved Hide resolved
src/run/interact.rs Outdated Show resolved Hide resolved
@@ -135,10 +137,10 @@ impl<'a, M: Mode> Net<'a, M> {
pub(crate) fn do_op(&mut self, op: Op, trg: Trg) -> (Trg, Trg) {
trace!(self.tracer, op, trg);
let port = trg.target();
if !M::LAZY && port.tag() == Num {
if !M::LAZY && (port.tag() == Int || port.tag() == F32) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if !M::LAZY && (port.tag() == Int || port.tag() == F32) {
if !M::LAZY && port.is_num() {

src/run/interact.rs Outdated Show resolved Hide resolved
src/run/port.rs Outdated Show resolved Hide resolved
src/transform/eta_reduce.rs Outdated Show resolved Hide resolved
@enricozb
Copy link
Contributor Author

Comparison operators should return ints.

@HigherOrderBot

This comment has been minimized.

@HigherOrderBot

This comment has been minimized.

@HigherOrderBot

This comment has been minimized.

@HigherOrderBot

This comment has been minimized.

Copy link
Contributor

@tjjfvi tjjfvi left a comment

Choose a reason for hiding this comment

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

looks good, just a few remaining nits and then should be good to merge

src/ast.rs Show resolved Hide resolved
src/ops.rs Outdated Show resolved Hide resolved
src/ops/num.rs Outdated Show resolved Hide resolved
src/ops/num.rs Outdated Show resolved Hide resolved
src/ops/num.rs Outdated Show resolved Hide resolved
src/run/def.rs Outdated Show resolved Hide resolved
src/run/instruction.rs Outdated Show resolved Hide resolved
src/run/linker.rs Outdated Show resolved Hide resolved
src/run/port.rs Outdated Show resolved Hide resolved
src/run/port.rs Outdated Show resolved Hide resolved
@enricozb enricozb requested a review from tjjfvi April 16, 2024 17:51
@HigherOrderBot
Copy link
Collaborator

Perf run for cac6783:

file              mode        main          cac6783f13c1
========================================================
merge_sort        intr-singl       7.521 s       7.866 s
                  intr-multi       3.736 s       3.912 s
--------------------------------------------------------
boom              intr-singl       2.303 s       2.258 s
                  intr-multi       2.341 s       2.633 s
--------------------------------------------------------
bitonic_sort_lam  intr-singl      12.504 s      13.184 s
                  intr-multi       5.794 s       6.303 s
--------------------------------------------------------
radix_sort_lam    intr-singl       9.352 s      10.071 s
                  intr-multi       4.589 s       4.976 s
--------------------------------------------------------
sum_tree          intr-singl       9.871 s      10.290 s
                  intr-multi       4.715 s       4.854 s
--------------------------------------------------------
c2                intr-singl       0.000 s       0.000 s
                  intr-multi       0.001 s       0.001 s
--------------------------------------------------------
sum_tail          intr-singl       1.361 s       1.279 s
                  intr-multi       1.156 s       1.225 s
--------------------------------------------------------
sum_rec           intr-singl      14.969 s      14.828 s
                  intr-multi       7.245 s       7.430 s

@enricozb enricozb added this pull request to the merge queue Apr 16, 2024
Merged via the queue into main with commit f464b59 Apr 16, 2024
6 checks passed
@enricozb enricozb deleted the enricozb/f32 branch April 16, 2024 18:03
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 support for floats
3 participants