Repository navigation
runtime/array.c: expose {uniform_,float}array_concat, use it in Float.Array - #13362
Merged
Merged
Conversation
Member
Author
|
@nojb I'm going through my old PRs to bring them to closure, and took the initiative of assigning you on this one. There is of course no urgency, so feel free to wait until the right time to look at this. |
nojb
approved these changes
Apr 2, 2025
nojb
left a comment
Contributor
There was a problem hiding this comment.
LGTM (modulo a cosmetic tweak)
| { | ||
| return generic_array_concat(&caml_array_gather, al); | ||
| } | ||
|
|
gasche
force-pushed
the
floatarray_concat
branch
from
April 3, 2025 07:00
b61d671 to
59dcd8d
Compare
Member
Author
|
Thanks for the review! This is good to merge if/when the CI agrees. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an immediate follow-up over #13361, sorry for the noise.
Yesterday I was intimidated by the length of the implementation of
caml_array_concat(it is 43 lines of C code that traverses an OCaml list of arrays and accumulates them and their sizes into separate arrays to callcaml_array_gather, with a cool optimization to avoid dynamic allocations below a certain input size). I gave up on the idea of finding out how to refactor it cleverly to avoid duplicating it twice into auniform_arrayand afloatarrayversion.Today I realized that I could use the power of Functional Programming, in this case, function pointers. I just abstract over the
gatherfunction, then define three one-liner instances for each usage.Note: This is the last primitive function over arrays that is implemented in C in array.c and exposed as an external in array.ml. The present PR brings Float.Array at complete parity in terms of runtime support.
(cc @nojb)