Quantcast

RFR(S): 8175096: Use Subword Analysis for set vector size

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RFR(S): 8175096: Use Subword Analysis for set vector size

Deshpande, Vivek R

Hi

 

Currently subword types cannot use entire vector width using SLP. 

This fix analyzes the subword in the loop for possibility of narrowing and sets the vector size accordingly.

 

Webrev:

http://cr.openjdk.java.net/~vdeshpande/8175096/webrev.00/

I have also updated the JBS entry.

https://bugs.openjdk.java.net/browse/JDK-8175096

Would you please review and sponsor it.

 

Regards,

Vivek

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RFR(S): 8175096: Use Subword Analysis for set vector size

Vladimir Kozlov
Hi Vivek,

This should go into jdk 10 since it is enhancement. We will consider to
backport it into jdk 9 update release later.

First, please explain why "Currently subword types cannot use entire
vector width using SLP".

The only explanation I have is that if loop has mixing types operations
then we narrow unroll factor for biggest type:

         if (cur_max_vector < max_vector) {
           max_vector = cur_max_vector;

And we start with smallest type:

int max_vector = Matcher::max_vector_size(T_BYTE);

Should we do opposite and start from long T_LONG (small unroll factor)
and widen it to smallest type (big unroll factor)?:

         if (cur_max_vector > max_vector) {
           max_vector = cur_max_vector;

Note, max_vector_size() returns number of elements and not size of
vector in bytes.

Michael, you are author of this code. What do you think?

Thanks,
Vladimir

On 2/16/17 11:45 AM, Deshpande, Vivek R wrote:

> Hi
>
>
>
> Currently subword types cannot use entire vector width using SLP.
>
> This fix analyzes the subword in the loop for possibility of narrowing
> and sets the vector size accordingly.
>
>
>
> Webrev:
>
> http://cr.openjdk.java.net/~vdeshpande/8175096/webrev.00/
>
> I have also updated the JBS entry.
>
> https://bugs.openjdk.java.net/browse/JDK-8175096
>
> Would you please review and sponsor it.
>
>
>
> Regards,
>
> Vivek
>
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: RFR(S): 8175096: Use Subword Analysis for set vector size

Berg, Michael C
I think using the current approach is the best way, it find the consistent shared vectorsize that is optimal for the loop for unrolling to act to.  This additional approach augments that by some testing of constraints as the subword types are often occluded by sign and zero extension artifacts that would otherwise have caused the next common size to surface.  These subword types are only in the integer subtype domain.

Regards,
Michael

-----Original Message-----
From: Vladimir Kozlov [mailto:[hidden email]]
Sent: Wednesday, February 22, 2017 12:09 PM
To: Deshpande, Vivek R <[hidden email]>; [hidden email]
Cc: Viswanathan, Sandhya <[hidden email]>; Berg, Michael C <[hidden email]>
Subject: Re: RFR(S): 8175096: Use Subword Analysis for set vector size

Hi Vivek,

This should go into jdk 10 since it is enhancement. We will consider to backport it into jdk 9 update release later.

First, please explain why "Currently subword types cannot use entire vector width using SLP".

The only explanation I have is that if loop has mixing types operations then we narrow unroll factor for biggest type:

         if (cur_max_vector < max_vector) {
           max_vector = cur_max_vector;

And we start with smallest type:

int max_vector = Matcher::max_vector_size(T_BYTE);

Should we do opposite and start from long T_LONG (small unroll factor) and widen it to smallest type (big unroll factor)?:

         if (cur_max_vector > max_vector) {
           max_vector = cur_max_vector;

Note, max_vector_size() returns number of elements and not size of vector in bytes.

Michael, you are author of this code. What do you think?

Thanks,
Vladimir

On 2/16/17 11:45 AM, Deshpande, Vivek R wrote:

> Hi
>
>
>
> Currently subword types cannot use entire vector width using SLP.
>
> This fix analyzes the subword in the loop for possibility of narrowing
> and sets the vector size accordingly.
>
>
>
> Webrev:
>
> http://cr.openjdk.java.net/~vdeshpande/8175096/webrev.00/
>
> I have also updated the JBS entry.
>
> https://bugs.openjdk.java.net/browse/JDK-8175096
>
> Would you please review and sponsor it.
>
>
>
> Regards,
>
> Vivek
>
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RFR(S): 8175096: Use Subword Analysis for set vector size

Vladimir Kozlov
On 2/23/17 9:03 AM, Berg, Michael C wrote:
> I think using the current approach is the best way, it find the consistent shared vectorsize that is optimal for the loop for unrolling to act to.  This additional approach augments that by some testing of constraints as the subword types are often occluded by sign and zero extension artifacts that would otherwise have caused the next common size to surface.  These subword types are only in the integer subtype domain.

"optimal" has wide meaning :)

Currently it means small number of unrolls in presence of wide (long,
double) values.

And if it is optimal why we need this additional fix (8175096)?

I still did not get answer about why "Currently subword types cannot use
entire vector width using SLP". In what cases this happen?

Thanks,
Vladimir

>
> Regards,
> Michael
>
> -----Original Message-----
> From: Vladimir Kozlov [mailto:[hidden email]]
> Sent: Wednesday, February 22, 2017 12:09 PM
> To: Deshpande, Vivek R <[hidden email]>; [hidden email]
> Cc: Viswanathan, Sandhya <[hidden email]>; Berg, Michael C <[hidden email]>
> Subject: Re: RFR(S): 8175096: Use Subword Analysis for set vector size
>
> Hi Vivek,
>
> This should go into jdk 10 since it is enhancement. We will consider to backport it into jdk 9 update release later.
>
> First, please explain why "Currently subword types cannot use entire vector width using SLP".
>
> The only explanation I have is that if loop has mixing types operations then we narrow unroll factor for biggest type:
>
>          if (cur_max_vector < max_vector) {
>            max_vector = cur_max_vector;
>
> And we start with smallest type:
>
> int max_vector = Matcher::max_vector_size(T_BYTE);
>
> Should we do opposite and start from long T_LONG (small unroll factor) and widen it to smallest type (big unroll factor)?:
>
>          if (cur_max_vector > max_vector) {
>            max_vector = cur_max_vector;
>
> Note, max_vector_size() returns number of elements and not size of vector in bytes.
>
> Michael, you are author of this code. What do you think?
>
> Thanks,
> Vladimir
>
> On 2/16/17 11:45 AM, Deshpande, Vivek R wrote:
>> Hi
>>
>>
>>
>> Currently subword types cannot use entire vector width using SLP.
>>
>> This fix analyzes the subword in the loop for possibility of narrowing
>> and sets the vector size accordingly.
>>
>>
>>
>> Webrev:
>>
>> http://cr.openjdk.java.net/~vdeshpande/8175096/webrev.00/
>>
>> I have also updated the JBS entry.
>>
>> https://bugs.openjdk.java.net/browse/JDK-8175096
>>
>> Would you please review and sponsor it.
>>
>>
>>
>> Regards,
>>
>> Vivek
>>
>>
>>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: RFR(S): 8175096: Use Subword Analysis for set vector size

Berg, Michael C
Vladimir,

The cases for this are for short and byte types stmt expressions, where the memory operations are sized to the key types, but the arithmetic components are not, but instead int as in this case:

if (!in->is_Mem() && in_bb(in) && in->bottom_type()->basic_type() == T_INT)

for the inputs on short and byte typed operations, as the node n is already bound to is_subword_type(bt).

Here is a snippet of code that would show the issue:

    static final int NUM = 1024;
    static byte[] data =  new byte[NUM],
                  data2 = new byte[NUM],
                  data3 = new byte[NUM];
    static short[] data4 =  new short[NUM],
                  data5 = new short[NUM],
                  data6 = new short[NUM];
    static int[] data7 =  new int[NUM],
                  data8 = new int[NUM],
                  data9 = new int[NUM];

    public static double count(long X) {
        long time1, time0 = System.nanoTime();
        doit2(X);
        time1 = System.nanoTime();
        return 1f*X/(time1-time0)*1e9;
    }

    public static void doit2(long X) {
        while (X > 0) {
            for (int i = 0; i < NUM; i++) {
                data[i] = (byte)(data2[i] + data3[i]);
                data4[i] = (short)(data5[i] + data6[i]);
                data7[i] = data8[i] + data9[i];
            }
            X--;
        }
    }

Where main inits the arrays to some set values for use above.  You can even break this it into two cases for each of the byte and short stmt level expressions. We can assert that this is always safe as superword by design does not allow mixed type stmt level expressions where byte and short are intermingled at that level, just the artifacts of boxing the interior components, like arithmetic as int.

Regards,
Michael

-----Original Message-----
From: Vladimir Kozlov [mailto:[hidden email]]
Sent: Friday, February 24, 2017 10:07 AM
To: Berg, Michael C <[hidden email]>; Deshpande, Vivek R <[hidden email]>; [hidden email]
Cc: Viswanathan, Sandhya <[hidden email]>
Subject: Re: RFR(S): 8175096: Use Subword Analysis for set vector size

On 2/23/17 9:03 AM, Berg, Michael C wrote:
> I think using the current approach is the best way, it find the consistent shared vectorsize that is optimal for the loop for unrolling to act to.  This additional approach augments that by some testing of constraints as the subword types are often occluded by sign and zero extension artifacts that would otherwise have caused the next common size to surface.  These subword types are only in the integer subtype domain.

"optimal" has wide meaning :)

Currently it means small number of unrolls in presence of wide (long,
double) values.

And if it is optimal why we need this additional fix (8175096)?

I still did not get answer about why "Currently subword types cannot use entire vector width using SLP". In what cases this happen?

Thanks,
Vladimir

>
> Regards,
> Michael
>
> -----Original Message-----
> From: Vladimir Kozlov [mailto:[hidden email]]
> Sent: Wednesday, February 22, 2017 12:09 PM
> To: Deshpande, Vivek R <[hidden email]>;
> [hidden email]
> Cc: Viswanathan, Sandhya <[hidden email]>; Berg,
> Michael C <[hidden email]>
> Subject: Re: RFR(S): 8175096: Use Subword Analysis for set vector size
>
> Hi Vivek,
>
> This should go into jdk 10 since it is enhancement. We will consider to backport it into jdk 9 update release later.
>
> First, please explain why "Currently subword types cannot use entire vector width using SLP".
>
> The only explanation I have is that if loop has mixing types operations then we narrow unroll factor for biggest type:
>
>          if (cur_max_vector < max_vector) {
>            max_vector = cur_max_vector;
>
> And we start with smallest type:
>
> int max_vector = Matcher::max_vector_size(T_BYTE);
>
> Should we do opposite and start from long T_LONG (small unroll factor) and widen it to smallest type (big unroll factor)?:
>
>          if (cur_max_vector > max_vector) {
>            max_vector = cur_max_vector;
>
> Note, max_vector_size() returns number of elements and not size of vector in bytes.
>
> Michael, you are author of this code. What do you think?
>
> Thanks,
> Vladimir
>
> On 2/16/17 11:45 AM, Deshpande, Vivek R wrote:
>> Hi
>>
>>
>>
>> Currently subword types cannot use entire vector width using SLP.
>>
>> This fix analyzes the subword in the loop for possibility of
>> narrowing and sets the vector size accordingly.
>>
>>
>>
>> Webrev:
>>
>> http://cr.openjdk.java.net/~vdeshpande/8175096/webrev.00/
>>
>> I have also updated the JBS entry.
>>
>> https://bugs.openjdk.java.net/browse/JDK-8175096
>>
>> Would you please review and sponsor it.
>>
>>
>>
>> Regards,
>>
>> Vivek
>>
>>
>>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: RFR(S): 8175096: Use Subword Analysis for set vector size

Deshpande, Vivek R
In reply to this post by Vladimir Kozlov
Hi Vladimir

Subwords get converted to int by broadening for the operations on them and max_vector gets set according to int, even if there are no mixed type operations, leading to short vector width instructions.

Regards,
Vivek


-----Original Message-----
From: Vladimir Kozlov [mailto:[hidden email]]
Sent: Friday, February 24, 2017 10:07 AM
To: Berg, Michael C; Deshpande, Vivek R; [hidden email]
Cc: Viswanathan, Sandhya
Subject: Re: RFR(S): 8175096: Use Subword Analysis for set vector size

On 2/23/17 9:03 AM, Berg, Michael C wrote:
> I think using the current approach is the best way, it find the consistent shared vectorsize that is optimal for the loop for unrolling to act to.  This additional approach augments that by some testing of constraints as the subword types are often occluded by sign and zero extension artifacts that would otherwise have caused the next common size to surface.  These subword types are only in the integer subtype domain.

"optimal" has wide meaning :)

Currently it means small number of unrolls in presence of wide (long,
double) values.

And if it is optimal why we need this additional fix (8175096)?

I still did not get answer about why "Currently subword types cannot use entire vector width using SLP". In what cases this happen?

Thanks,
Vladimir

>
> Regards,
> Michael
>
> -----Original Message-----
> From: Vladimir Kozlov [mailto:[hidden email]]
> Sent: Wednesday, February 22, 2017 12:09 PM
> To: Deshpande, Vivek R <[hidden email]>;
> [hidden email]
> Cc: Viswanathan, Sandhya <[hidden email]>; Berg,
> Michael C <[hidden email]>
> Subject: Re: RFR(S): 8175096: Use Subword Analysis for set vector size
>
> Hi Vivek,
>
> This should go into jdk 10 since it is enhancement. We will consider to backport it into jdk 9 update release later.
>
> First, please explain why "Currently subword types cannot use entire vector width using SLP".
>
> The only explanation I have is that if loop has mixing types operations then we narrow unroll factor for biggest type:
>
>          if (cur_max_vector < max_vector) {
>            max_vector = cur_max_vector;
>
> And we start with smallest type:
>
> int max_vector = Matcher::max_vector_size(T_BYTE);
>
> Should we do opposite and start from long T_LONG (small unroll factor) and widen it to smallest type (big unroll factor)?:
>
>          if (cur_max_vector > max_vector) {
>            max_vector = cur_max_vector;
>
> Note, max_vector_size() returns number of elements and not size of vector in bytes.
>
> Michael, you are author of this code. What do you think?
>
> Thanks,
> Vladimir
>
> On 2/16/17 11:45 AM, Deshpande, Vivek R wrote:
>> Hi
>>
>>
>>
>> Currently subword types cannot use entire vector width using SLP.
>>
>> This fix analyzes the subword in the loop for possibility of
>> narrowing and sets the vector size accordingly.
>>
>>
>>
>> Webrev:
>>
>> http://cr.openjdk.java.net/~vdeshpande/8175096/webrev.00/
>>
>> I have also updated the JBS entry.
>>
>> https://bugs.openjdk.java.net/browse/JDK-8175096
>>
>> Would you please review and sponsor it.
>>
>>
>>
>> Regards,
>>
>> Vivek
>>
>>
>>
Loading...