[vectorIntrinsics+fp16] RFR: 8300571: FP16 support for VectorAPI Transcendental operations.

Swati Sharma duke at openjdk.org
Wed Jan 25 08:15:32 UTC 2023


On Wed, 25 Jan 2023 05:52:28 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

>> Hi All,
>> 
>> The patch contains the below changes:
>> •	Support for Transcendental routines for FP16 type.
>> •	Re-enabling earlier commented out JTREG tests. 
>> 
>> Please review and provide your feedback.
>> 
>> Thanks,
>> Swati
>
> src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template line 852:
> 
>> 850:                     v0.uOp(m, (i, a) -> Halffloat.valueOf((float) Math.cosh(Halffloat.valueOf(a).floatValue())));
>> 851:             case VECTOR_OP_TANH: return (v0, m) ->
>> 852:                     v0.uOp(m, (i, a) -> Halffloat.valueOf((float) Math.tanh(Halffloat.valueOf(a).floatValue())));
> 
> All the Math.* transcendental routines accept a double argument, you can directly use Float.float16ToFloat() instead of Halffloat.valueOf(a).floatValue(), argument will get upcasted to double.

A separate patch is there to replace at all places Halffloat.valueOf(a).floatValue() with Float.float16ToFloat() , Should I do the replacement changes in this patch at all places.

> test/jdk/jdk/incubator/vector/templates/Unit-header.template line 757:
> 
>> 755:         float low = Math.nextDown(exp);
>> 756:         float high = Math.nextUp(exp);
>> 757: 
> 
> Here upcasting the result to float will check against the ULP of Float not Halffloat. But given that ULP of FP32 is always granular than ULP of FP16 intended functionality should still be honored.

Ok.

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

PR: https://git.openjdk.org/panama-vector/pull/209


More information about the panama-dev mailing list