Mailing List Archive

[Lucene] confusion in posting encoding
Hi Adrien,

I have some confusion about the method collapse8(long[ ] arr) in ForUtil class




On line 85, the loop times are 16, because there are 128 elements in arr, and eight elements were processed at a time.

My question is why not choose the elements in order , like in the first loop, arr[0] ~ arr[7] were chosen, in the second loop, arr[8] ~ arr[15] were chosen …

Is it cause the compiler cann’t generate SIMD instructions or just something else?

Could you help me find the answer here?
Re: [Lucene] confusion in posting encoding [ In reply to ]
Hello,

It is indeed because I could get the compiler to use SIMD instructions with
the loop written this way.

On Wed, Jan 13, 2021 at 11:29 AM LuXugang <xuganglu@icloud.com.invalid>
wrote:

> Hi Adrien,
>
> I have some confusion about the method collapse8(long[ ] arr) in* ForUtil*
> class
>
>
>
>
> On line 85, the loop times are 16, because there are 128 elements in arr,
> and eight elements were processed at a time.
>
> My question is why not choose the elements in order , like in the first
> loop, arr[0] ~ arr[7] were chosen, in the second loop, arr[8] ~ arr[15]
> were chosen …
>
> Is it cause the compiler cann’t generate SIMD instructions or just
> something else?
>
> Could you help me find the answer here?
>


--
Adrien
Re: [Lucene] confusion in posting encoding [ In reply to ]
Thanks for your answer, Adrien.

> 2021?1?13? ??9:26?Adrien Grand <jpountz@gmail.com> ???
>
> Hello,
>
> It is indeed because I could get the compiler to use SIMD instructions with the loop written this way.
>
> On Wed, Jan 13, 2021 at 11:29 AM LuXugang <xuganglu@icloud.com.invalid> wrote:
> Hi Adrien,
>
> I have some confusion about the method collapse8(long[ ] arr) in ForUtil class
>
> <?????-1.png>
>
>
> On line 85, the loop times are 16, because there are 128 elements in arr, and eight elements were processed at a time.
>
> My question is why not choose the elements in order , like in the first loop, arr[0] ~ arr[7] were chosen, in the second loop, arr[8] ~ arr[15] were chosen …
>
> Is it cause the compiler cann’t generate SIMD instructions or just something else?
>
> Could you help me find the answer here?
>
>
> --
> Adrien