-
Notifications
You must be signed in to change notification settings - Fork 41
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
8282389: Add new vector operations to count leading and trailing zeros. #176
Conversation
👋 Welcome back swati-sha! A progress list of the required criteria for merging this PR into |
/label add panama-dev |
@swati-sha |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
/sponsor |
@swati-sha This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 1 new commit pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@jatin-bhateja, @PaulSandoz) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
@jatin-bhateja The change author (@swati-sha) must issue an |
@@ -1626,6 +1628,8 @@ DoubleVector abs() { | |||
|
|||
|
|||
|
|||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove these lines.
VECTOR_OP_CTZ = 29, | ||
VECTOR_OP_CLZ = 30, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems weird, could you please either move these two to the end of this enum or set the number to "4, 5"?
@@ -1788,6 +1794,14 @@ static int bitCount(byte a) { | |||
return Integer.bitCount((int)a & 0xFF); | |||
} | |||
|
|||
static int numberOfTrailingZeros(byte a) { | |||
return a != 0 ? Integer.numberOfTrailingZeros(a) : 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integer.numberOfTrailingZeros((int)a & 0xFF) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it not return incorrect value for a=0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be Integer.numberOfTrailingZeros(a | 0x100);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I think what he meant was the calculation of the numberOfLeadingZeros
below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
numberOfTrailingZeros
Having a special case for zero will be better from performance perspective in slow path.
We may incur one additional comparison but given that C2 will intrinsify at a VectorSupport.unaryOp level it will not hurt compiled code performance but special handlings improve fallback code performance.
Could you please update the copyright year to "2022" for all the modified files? Thanks! |
@@ -5310,6 +5318,92 @@ static void BIT_COUNTMaskedByte128VectorTests(IntFunction<byte[]> fa, | |||
|
|||
|
|||
|
|||
|
|||
static byte CTZ(byte a) { | |||
return (byte)(CTZ_scalar(a)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not directly return (byte) (a != 0 ? Integer.numberOfTrailingZeros(a) : 8);
in this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep minimal changes in the test generation template, we want to keep one interface which caters to all the primitive types.
@@ -452,6 +452,10 @@ static boolean opKind(Operator op, int bit) { | |||
public static final Unary NEG = unary("NEG", "-a", VectorSupport.VECTOR_OP_NEG, VO_ALL|VO_SPECIAL); | |||
/** Produce {@code bitCount(a)} */ | |||
public static final Unary BIT_COUNT = unary("BIT_COUNT", "bitCount", VectorSupport.VECTOR_OP_BIT_COUNT, VO_NOFP); | |||
/** Produce {@code numberOfTrailingZeros(a)} */ | |||
public static final Unary CTZ = unary("CTZ", "numberOfTrailingZeros", VectorSupport.VECTOR_OP_CTZ, VO_NOFP); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be more verbose in the names, as they will not be well understood by developers. Specifically TRAILING_ZEROS_COUNT
and LEADING_ZEROS_COUNT
, and be consistent in other places. Internally we could shorten to VECTOR_OP_TZ_COUNT
etc. to reduce the horizontal width.
/integrate |
@swati-sha |
/sponsor |
@jatin-bhateja @swati-sha Pushed as commit 801f1fd. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Hi All,
Added support for new vector operations CLZ (count number of leading zeros) and CTZ (could number of trailing zeros) for all the integral vector types(Byte/Short/Integer/Long).
Added validation and performance tests corresponding the these operations in existing VectorAPI JTREG/JMH suite.
Kindly review and share your feedback.
Thanks and Regards,
Swati Sharma
Intel
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/panama-vector pull/176/head:pull/176
$ git checkout pull/176
Update a local copy of the PR:
$ git checkout pull/176
$ git pull https://git.openjdk.java.net/panama-vector pull/176/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 176
View PR using the GUI difftool:
$ git pr show -t 176
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/panama-vector/pull/176.diff