[lworld+fp16] RFR: 8338061: Add support for FP16 unary and ternary operations

Bhavana Kilambi bkilambi at openjdk.org
Tue Aug 20 09:05:56 UTC 2024


On Tue, 20 Aug 2024 08:34:08 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

>> This patch adds support for three unary operators - abs, neg and sqrt and a ternary operator - fma for FP16.
>> Both scalar and vector mid-end support along with aarch64 backend support are added.
>> Tested all FP16 tests successfully on aarch64.
>
> test/hotspot/jtreg/compiler/c2/irTests/ConvF2HFIdealizationTests.java line 49:
> 
>> 47: 
>> 48:     @DontCompile
>> 49:     public void assertResult(Float16 fp16) {
> 
> We can use @Check annotation to comparing the actual and expected results on the lines of following existing test https://github.com/openjdk/valhalla/blob/lworld%2Bfp16/test/hotspot/jtreg/compiler/vectorization/TestFloat16VectorOps.java 
> 
> 
> jshell> for (int i = 0; i < 65504; i++)  {
>    ...>     float fi = Float.float16ToFloat(Float.floatToFloat16((float)i));
>    ...>     if (Float16.float16ToRawShortBits(Float16.sqrt(Float16.valueOf(fi))) != Float.floatToFloat16((float)Math.sqrt(fi))) {
>    ...>        System.out.println("Fist precision mismatch at = " + fi); break;
>    ...>     }
>    ...> }
> 
> 
> We can even run through entire value ranges of Float16 type to empirically prove the equivalence..

Sure, will do that. Thanks for reviewing.

-------------

PR Review Comment: https://git.openjdk.org/valhalla/pull/1211#discussion_r1722960588


More information about the valhalla-dev mailing list