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

Float32 array load/store primitives #2697

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Float32 array load/store primitives #2697

wants to merge 10 commits into from

Conversation

TheNumbat
Copy link
Contributor

@TheNumbat TheNumbat commented Jun 14, 2024

Adds %primitives for loading/storing float32s to/from strings, bytes, bigstrings, and float32_elt bigarrays. Also covers loading/storing unboxed float32s to/from bigstrings.

The string, bytes, and bigstring primitives have the same semantics as those for int32s; the only difference is that they operate on a float32 register directly. This did not require any compiler backend changes.

The bigarray functions are specialized copies of caml_ba_ref / caml_ba_set for float32. They require bigarrays with the float32_elt element kind, but purposefully ignore the bigarray's 'view' type. This allows the API functions to operate on e.g. (float, float32_elt, 'c) t bigarrays.

  • This required adding a new bigarray kind in the compiler, Pbigarray_float32_t / Float32_t. This kind not exposed by the standard library, and is only used by the new primitives.
  • When generating calls to generic caml_ba_get_$N / caml_ba_set_$N, we now need to check whether the kind is Pbigarray_float32_t. This was necessary because the default runtime functions will convert float32_elts to doubles.
  • Only 1, 2, and 3 dimensional float32_elt bigarrays are supported. Generic arrays must still convert through float.

Tests for all new primitives have been added to float32_lib.ml and float32_u_lib.ml.

p.s. fixes an assembly emission problem with CVTSI2SS, @xclerc to review the last commit

@mshinwell
Copy link
Collaborator

@TheNumbat please add a full PR description

@TheNumbat
Copy link
Contributor Author

Yeah, added, but this still isn't ready for review. Something bad is going on with the cfg backends

@TheNumbat TheNumbat added flambda2 Prerequisite for, or part of, flambda2 lambda Lambda language changes labels Jun 21, 2024
@TheNumbat TheNumbat marked this pull request as ready for review June 25, 2024 01:04
@TheNumbat TheNumbat requested a review from ccasin June 25, 2024 01:05
backend/x86_gas.ml Show resolved Hide resolved
backend/cfg/cfg_equivalence.ml Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flambda2 Prerequisite for, or part of, flambda2 lambda Lambda language changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants