8375631: VectorAPI part number: reformulate documentation and improve exception message#30113
8375631: VectorAPI part number: reformulate documentation and improve exception message#30113eme64 wants to merge 44 commits intoopenjdk:masterfrom
Conversation
|
👋 Welcome back epeter! A progress list of the required criteria for merging this PR into |
|
@eme64 This change is no longer ready for integration - check the PR body for details. |
|
/contributor add @rose00 |
|
@eme64 |
|
We can either add documentation to package doc or to a separate HTML file in the same package. But for this review I realize I am likely asking too much, it would be better to consider that holistically. I wonder if we can remove footnote-like text such as "(Some platforms do support a..."? and perhaps it is possible after the definitions to compress/remove most of the discussion before we focus on the various resizing operations, maybe provide a textual example for each, and then on to the table of the examples that amplifies with more examples? |
|
@PaulSandoz Thanks for the online and offline comments!
This was from @rose00 , so I have not yet dared to remove it. I think it also nicely explains the rationale behind part numbers. For example on NEON, we really currently can only use 64 and 128 bit vectors. That is a very narrow band, and makes casting less straight-forward: you need to think about inserting and selecting. With synthetic vector shapes we can probably get around this. Even vector splitting could help: casting from 128 bit to 512 bit would then automatically split the 512 bit one into 4 vectors on NEON. At that point, we may need to re-write some of these sections. @rose00 What is your opinion on this paragraph? Quoting the whole thing for reference:
|
|
I was able to shave off 60 lines in fbb2ece. I slashed a lot of the "prose" part after the "definitions". I compacted some details into the "definitions" (valid part ranges). Instead, I added some examples. And reformulated some things into this section:
Now we can probably delete this part, right?
@PaulSandoz @rose00 Does this look better now? What else would you like me to do now? |
|
FYI: thanks to @rgiulietti for pushing me towards more compact formulations in offline conversations. |
|
In 1a586e0 I now restructured the list of "resizing operations" a bit. I'm now open to more reviews now :) |
| * <p> Examples (more in the table further below): | ||
| * <ul> | ||
| * <li> Conversion {@code int[4]:128 -> float[4]:128}: | ||
| * invariant lane size (lanewise in-place, {@code ML=1}), |
There was a problem hiding this comment.
| * invariant lane size (lanewise in-place, {@code ML=1}), | |
| * length-invariant (lanewise in-place, {@code ML=1}), |
?
There was a problem hiding this comment.
Here I want to say that the lanes keep the same number of bits -> lanewise in-place. It is not about the number of lanes / length of the vector. What do you think?
There was a problem hiding this comment.
Is that not implied by it also being shape-invariant? VLENGTH in and VLENGTH out, VSHAPE in and VSHAPE out. I would be inclined to just say "length-invariant ({@code ML=1"}), otherwise it might appear you are saying something different or new and that is not the case.
There was a problem hiding this comment.
The implication can really go any way: if you have 2 corners of the triangle, you get the 3rd.
Question is if we first focus on the lane size or the number of lanes.
Generally, length-invariant does not imply ML=1.
I think length-invariant would go better with no selection/insertion here. I'll add it there.
Co-authored-by: Paul Sandoz <paul.d.sandoz@googlemail.com>
|
@PaulSandoz Thanks for the many suggestions and the offline conversation. I think I addressed everything now. |
| * <p> Examples (more in the table further below): | ||
| * <ul> | ||
| * <li> Conversion {@code int[4]:128 -> float[4]:128}: | ||
| * invariant lane size (lanewise in-place, {@code ML=1}), |
There was a problem hiding this comment.
Is that not implied by it also being shape-invariant? VLENGTH in and VLENGTH out, VSHAPE in and VSHAPE out. I would be inclined to just say "length-invariant ({@code ML=1"}), otherwise it might appear you are saying something different or new and that is not the case.
|
@PaulSandoz Ok, made another small adjustment according to what you suggested. Ready for a second review :) |
|
/template append |
|
@eme64 The pull request template has been appended to the pull request body |
|
@eme64 |
|
The total number of required reviews for this PR has been set to 2 based on the presence of this label: |
Found while working on JDK-8369699.
In general, the Vector API documentation is a bit vague around part numbers.
There was considerable confusion around expansion/contraction: are we talking about logical, physical or output expansion/contraction? Confusingly, in some places we called expansions things that go from more to fewer bits, and we called contractions that went from fewer to more bits.
And exception messages are not very helpful, for example they don't provide the legal range.
@rose00 took a first stab at improving things (#29306), and I eventually took over the project.
Principles:
Please review this PR in this order:
Vector.java. We must first agree on the definitions here, before we go and disagree elsewhere ;)convertShape,convert, andreinterpretShape.AbstractVector.java: adjust nomenclature and exception message.unsliceI realized that it does not throw for out of boundspart. So I think it is justified.In general, I'm a bit worried that the documentation is a bit too long, and feels a bit heavy/overwhelming.
To a large degree, this is due to the complexity of part numbers.
We could drop some paragraphs and some repetition. Let me know what you think is too much.
More explanations may help make things clearer, but also risk being too much and overwhelming.
I'm open to cut things down more, and any other constructive suggestions ;)
While reading the documentation and testing for
unslice, I found out that #3804 accidentally removed the bounds checks forpart. But we did not notice, because there were no tests for it. I'm adding the bounds check back in and adding tests for it as well.Progress
Issue
Reviewers
Contributors
<jrose@openjdk.org>Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/30113/head:pull/30113$ git checkout pull/30113Update a local copy of the PR:
$ git checkout pull/30113$ git pull https://git.openjdk.org/jdk.git pull/30113/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 30113View PR using the GUI difftool:
$ git pr show -t 30113Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/30113.diff
Using Webrev
Link to Webrev Comment