RFR: 8289552: Make intrinsic conversions between bit representations of half precision values and floats [v2]

Paul Sandoz psandoz at openjdk.org
Wed Aug 17 18:00:20 UTC 2022


On Wed, 17 Aug 2022 17:35:39 GMT, Smita Kamath <svkamath at openjdk.org> wrote:

>> 8289552: Make intrinsic conversions between bit representations of half precision values and floats
>
> Smita Kamath has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Added a jmh microbenchmark

test/micro/org/openjdk/bench/java/math/Fp16ConversionBenchmark.java line 38:

> 36: 
> 37:   @Param({"2048"})
> 38:   public int TESTSIZE;

Suggestion:

  public int size;

test/micro/org/openjdk/bench/java/math/Fp16ConversionBenchmark.java line 40:

> 38:   public int TESTSIZE;
> 39: 
> 40:   public short[] HFargV1;

Let's use `F16` instead of `HF`.
e.g. f16in, f16out, fin, fout.

test/micro/org/openjdk/bench/java/math/Fp16ConversionBenchmark.java line 59:

> 57:       Random r = new Random(1024);
> 58: 
> 59:       HFargV1 = new short[TESTSIZE];

If the test size is less than the number of special values then we will get an exception. I cannot quite decide if special values are that important here. Might be better to test separately?

test/micro/org/openjdk/bench/java/math/Fp16ConversionBenchmark.java line 85:

> 83:   @Benchmark
> 84:   public void floatToFloat16() {
> 85:       for (int i = 0; i < TESTSIZE; i++) {

Use the array length instead, it's more idiomatic e.g.:
Suggestion:

      for (int i = 0; i < FargV1.length; i++) {

test/micro/org/openjdk/bench/java/math/Fp16ConversionBenchmark.java line 88:

> 86:           ResHF[i] = Float.floatToFloat16(FargV1[i]);
> 87:       }
> 88:   }

Return the result array, so it's consumed by a black hole.

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

PR: https://git.openjdk.org/jdk/pull/9781


More information about the core-libs-dev mailing list