[vector] RFR 8218750: Vectorized ChaCha20 Benchmark

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Tue Feb 12 18:08:56 UTC 2019


> New webrev: https://cr.openjdk.java.net/~apetcher/8218750/webrev.01/

>> A couple of minor suggestions:
>>
>>   - I'd prefer to see the benchmark condensed into a single file.
> 
> I moved the implementation into ChaChaBench as a nested class.

Looks good.

>>   - IMO it's better to declare a dedicated @Benchmark method per 
>> vector shape instead:
>>
>>   35     @Param({"128", "256", "512"})
>>   36     private int vectorWidth;
> 
> I accomplished this (in the latest webrev) by making a subclass for each 
> shape. This organization allows the shape-specific setup to happen 
> outside of the benchmark method. There is no subclass for 64-bit, 
> because the implementation needs a minimum of 128 bits by design.

   78     @Benchmark
   79     public void encrypt() {
   80         cc20.chacha20(key, nonce, counter, in, out);
   81     }

I don't see where cc20 is instantiated to Vec128/Vec256/Vec512, but now 
I understand what the actual problem is :-) You want to instantiate 
ChaChaVector as a benchmark setup to get all the constants pre-initialized.

I suggest to shape it as follows:

   private ChaChaVector cc20_S128 = new 
ChaChaVector(Vector.Shape.S_128_BIT);

   @Benchmark
   public void encrypt128() {
       cc20_S128.chacha20(key, nonce, counter, in, out);
   }

As I understand, ChaChaBench.runKAT is a unit test. You can put it 
either into ChaChaBench.setup() or leave in ChaChaBench ctor, but use 
cc20_S128/S256/S512 instead.

Best regards,
Vladimir Ivanov


More information about the panama-dev mailing list