[vector] Sparse load (simple gather) of vector from array?

Lev Serebryakov lev at serebryakov.spb.ru
Thu Mar 21 09:57:47 UTC 2019


On 21.03.2019 2:07, Vladimir Ivanov wrote:

>>   I have (long) array of floats: `float[] data`. I have Spicies of
>> FloatArray, `S`. I need to create `FloatVector` with even elements (0,
>> 2, 4, ...) set to elements from `data` array and odd elements set to
>> zero (`0.0f`).
>>
>>    So, if we use 256 bit vectors shape, it should be like this:
>>
>> {data[offest+0], 0.0f, data[offest+1], 0.0f, data[offest+2], 0.0f,
>> data[offest+3], 0.0f}
>>
>>    I could load vector from array and blend it with zero vector, but it
>> will have wrong float data from array (like `offset+0`, `offset+2`, etc).
>>
>>   What is simplest way to perform such "gather" load?
> 
> Strictly speaking, it's not a "gather" operation - the input data being
> accessed is still laid out contiguously in memory.
> 
> You can achieve your goal by adapting vector contents after it is loaded
> from memory. On API level you can achieve that by reshape + rearrange +
> blend and I see it as the idiomatic way to implement such transformation:
  Now I'm using 5-arguments form `fromArray()` (with shuffle integer array).
   I need to benchmark these two methods, but, as far as I understand,
backend is not ready for serious benchmarking.

   Now I have full library of real and complex vector operations (in DSP
sense — not in 3D-graphics sense, so, "vector" is infinite sequence of
real or complex numbers, not something like vector-row or
vector-columns), implemented both in pure Java and with Vector API, but
benchmarks results are very strange on my custom build of
"foreign+vector" branch. I need 2-3 day to clean it up and I'll publish
code with some my (strange) result.

-- 
// Black Lion AKA Lev Serebryakov



More information about the panama-dev mailing list